diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index b1f001f..f76baea 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -30,7 +30,7 @@ jobs: - name: Install .NET Core uses: actions/setup-dotnet@v5 with: - dotnet-version: '9.x.x' + dotnet-version: '10.x.x' - name: Initialize CodeQL uses: github/codeql-action/init@v4 diff --git a/.github/workflows/dependency-check.yml b/.github/workflows/dependency-check.yml index 987a3a7..0f2c92f 100644 --- a/.github/workflows/dependency-check.yml +++ b/.github/workflows/dependency-check.yml @@ -20,7 +20,7 @@ jobs: uses: actions/setup-dotnet@v5 with: dotnet-version: | - 9.x.x + 10.x.x 6.x.x - name: Restore dependencies diff --git a/.github/workflows/dotnet.yml b/.github/workflows/dotnet.yml index a5e1fcb..f0d525b 100644 --- a/.github/workflows/dotnet.yml +++ b/.github/workflows/dotnet.yml @@ -27,7 +27,7 @@ jobs: uses: actions/setup-dotnet@v5 with: dotnet-version: | - 9.x.x + 10.x.x - name: Restore dependencies run: dotnet restore diff --git a/CleanArchitecture.Api/CleanArchitecture.Api.csproj b/CleanArchitecture.Api/CleanArchitecture.Api.csproj index f46b205..b08148f 100644 --- a/CleanArchitecture.Api/CleanArchitecture.Api.csproj +++ b/CleanArchitecture.Api/CleanArchitecture.Api.csproj @@ -1,14 +1,14 @@ - net9.0 + net10.0 enable 64377c40-44d6-4989-9662-5d778f8b3b92 Linux - + @@ -17,17 +17,17 @@ - - - + + + all runtime; build; native; contentfiles; analyzers; buildtransitive - - - - - + + + + + diff --git a/CleanArchitecture.Api/Extensions/ServiceCollectionExtension.cs b/CleanArchitecture.Api/Extensions/ServiceCollectionExtension.cs index 793d22f..ed72bb3 100644 --- a/CleanArchitecture.Api/Extensions/ServiceCollectionExtension.cs +++ b/CleanArchitecture.Api/Extensions/ServiceCollectionExtension.cs @@ -1,12 +1,11 @@ -using System.Collections.Generic; -using System.Text; +using System.Text; using CleanArchitecture.Api.Swagger; using CleanArchitecture.Domain.Settings; using Microsoft.AspNetCore.Authentication.JwtBearer; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.IdentityModel.Tokens; -using Microsoft.OpenApi.Models; +using Microsoft.OpenApi; namespace CleanArchitecture.Api.Extensions; @@ -38,23 +37,10 @@ public static IServiceCollection AddSwagger(this IServiceCollection services) c.ParameterFilter(); c.SupportNonNullableReferenceTypes(); - - c.AddSecurityRequirement(new OpenApiSecurityRequirement + + c.AddSecurityRequirement((document) => new OpenApiSecurityRequirement() { - { - new OpenApiSecurityScheme - { - Reference = new OpenApiReference - { - Type = ReferenceType.SecurityScheme, - Id = "Bearer" - }, - Scheme = "oauth2", - Name = "Bearer", - In = ParameterLocation.Header - }, - new List() - } + [new OpenApiSecuritySchemeReference("Bearer", document)] = ["readAccess", "writeAccess"] }); }); return services; diff --git a/CleanArchitecture.Api/Swagger/SortableFieldsAttributeFilter.cs b/CleanArchitecture.Api/Swagger/SortableFieldsAttributeFilter.cs index 6dd403c..1113895 100644 --- a/CleanArchitecture.Api/Swagger/SortableFieldsAttributeFilter.cs +++ b/CleanArchitecture.Api/Swagger/SortableFieldsAttributeFilter.cs @@ -1,13 +1,13 @@ using System.Linq; using System.Reflection; -using Microsoft.OpenApi.Models; +using Microsoft.OpenApi; using Swashbuckle.AspNetCore.SwaggerGen; namespace CleanArchitecture.Api.Swagger; public sealed class SortableFieldsAttributeFilter : IParameterFilter { - public void Apply(OpenApiParameter parameter, ParameterFilterContext context) + public void Apply(IOpenApiParameter parameter, ParameterFilterContext context) { if (context.ParameterInfo is null) { diff --git a/CleanArchitecture.AppHost/CleanArchitecture.AppHost.csproj b/CleanArchitecture.AppHost/CleanArchitecture.AppHost.csproj index 94db9b1..a347fcf 100644 --- a/CleanArchitecture.AppHost/CleanArchitecture.AppHost.csproj +++ b/CleanArchitecture.AppHost/CleanArchitecture.AppHost.csproj @@ -1,10 +1,8 @@ - - - + Exe - net9.0 + net10.0 enable enable true @@ -12,10 +10,9 @@ - - - - + + + diff --git a/CleanArchitecture.AppHost/Program.cs b/CleanArchitecture.AppHost/Program.cs index a05ade9..3d6c5d1 100644 --- a/CleanArchitecture.AppHost/Program.cs +++ b/CleanArchitecture.AppHost/Program.cs @@ -2,12 +2,10 @@ var redis = builder.AddRedis("Redis").WithRedisInsight(); -var rabbitPasswordRessource = new ParameterResource("password", _ => "guest"); -var rabbitPasswordParameter = - builder.AddParameter("username", rabbitPasswordRessource.Value); +var rabbitPassword = builder.AddParameter("rabbit-password", secret: false); var rabbitMq = builder - .AddRabbitMQ("RabbitMQ", null, rabbitPasswordParameter, 5672) + .AddRabbitMQ("RabbitMQ", null, rabbitPassword, 5672) .WithManagementPlugin(); var sqlServer = builder.AddSqlServer("SqlServer"); diff --git a/CleanArchitecture.AppHost/appsettings.Development.json b/CleanArchitecture.AppHost/appsettings.Development.json index 289f257..3b9d8ed 100644 --- a/CleanArchitecture.AppHost/appsettings.Development.json +++ b/CleanArchitecture.AppHost/appsettings.Development.json @@ -5,5 +5,8 @@ "Microsoft.AspNetCore": "Warning" } }, - "EnableHttpTraces": false + "EnableHttpTraces": false, + "Parameters": { + "rabbit-password": "guest", + } } diff --git a/CleanArchitecture.Application.Tests/CleanArchitecture.Application.Tests.csproj b/CleanArchitecture.Application.Tests/CleanArchitecture.Application.Tests.csproj index d90d5cc..ebd9ddb 100644 --- a/CleanArchitecture.Application.Tests/CleanArchitecture.Application.Tests.csproj +++ b/CleanArchitecture.Application.Tests/CleanArchitecture.Application.Tests.csproj @@ -1,7 +1,7 @@ - net9.0 + net10.0 enable false @@ -13,7 +13,7 @@ all runtime; build; native; contentfiles; analyzers; buildtransitive - + diff --git a/CleanArchitecture.Application/CleanArchitecture.Application.csproj b/CleanArchitecture.Application/CleanArchitecture.Application.csproj index 1627d99..eb95917 100644 --- a/CleanArchitecture.Application/CleanArchitecture.Application.csproj +++ b/CleanArchitecture.Application/CleanArchitecture.Application.csproj @@ -1,12 +1,12 @@ - net9.0 + net10.0 enable - + diff --git a/CleanArchitecture.Domain.Tests/CleanArchitecture.Domain.Tests.csproj b/CleanArchitecture.Domain.Tests/CleanArchitecture.Domain.Tests.csproj index 163ab8b..86ca183 100644 --- a/CleanArchitecture.Domain.Tests/CleanArchitecture.Domain.Tests.csproj +++ b/CleanArchitecture.Domain.Tests/CleanArchitecture.Domain.Tests.csproj @@ -1,7 +1,7 @@ - net9.0 + net10.0 enable false @@ -14,7 +14,7 @@ all runtime; build; native; contentfiles; analyzers; buildtransitive - + diff --git a/CleanArchitecture.Domain/CleanArchitecture.Domain.csproj b/CleanArchitecture.Domain/CleanArchitecture.Domain.csproj index 03cb9f1..1c90f1d 100644 --- a/CleanArchitecture.Domain/CleanArchitecture.Domain.csproj +++ b/CleanArchitecture.Domain/CleanArchitecture.Domain.csproj @@ -1,16 +1,15 @@ - net9.0 + net10.0 enable - + - diff --git a/CleanArchitecture.Infrastructure.Tests/CleanArchitecture.Infrastructure.Tests.csproj b/CleanArchitecture.Infrastructure.Tests/CleanArchitecture.Infrastructure.Tests.csproj index 40733a5..fac253f 100644 --- a/CleanArchitecture.Infrastructure.Tests/CleanArchitecture.Infrastructure.Tests.csproj +++ b/CleanArchitecture.Infrastructure.Tests/CleanArchitecture.Infrastructure.Tests.csproj @@ -1,7 +1,7 @@ - net9.0 + net10.0 enable false @@ -13,7 +13,7 @@ all runtime; build; native; contentfiles; analyzers; buildtransitive - + diff --git a/CleanArchitecture.Infrastructure/CleanArchitecture.Infrastructure.csproj b/CleanArchitecture.Infrastructure/CleanArchitecture.Infrastructure.csproj index 8047c44..6a112a4 100644 --- a/CleanArchitecture.Infrastructure/CleanArchitecture.Infrastructure.csproj +++ b/CleanArchitecture.Infrastructure/CleanArchitecture.Infrastructure.csproj @@ -1,7 +1,7 @@ - net9.0 + net10.0 enable @@ -12,10 +12,10 @@ - - - - + + + + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/CleanArchitecture.IntegrationTests/CleanArchitecture.IntegrationTests.csproj b/CleanArchitecture.IntegrationTests/CleanArchitecture.IntegrationTests.csproj index b93be11..5c7e97f 100644 --- a/CleanArchitecture.IntegrationTests/CleanArchitecture.IntegrationTests.csproj +++ b/CleanArchitecture.IntegrationTests/CleanArchitecture.IntegrationTests.csproj @@ -1,7 +1,7 @@ - net9.0 + net10.0 enable false @@ -13,11 +13,11 @@ all runtime; build; native; contentfiles; analyzers; buildtransitive - - - + + + - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/CleanArchitecture.Proto/CleanArchitecture.Proto.csproj b/CleanArchitecture.Proto/CleanArchitecture.Proto.csproj index 120ffc6..bd36021 100644 --- a/CleanArchitecture.Proto/CleanArchitecture.Proto.csproj +++ b/CleanArchitecture.Proto/CleanArchitecture.Proto.csproj @@ -1,7 +1,7 @@ - net9.0 + net10.0 enable diff --git a/CleanArchitecture.ServiceDefaults/CleanArchitecture.ServiceDefaults.csproj b/CleanArchitecture.ServiceDefaults/CleanArchitecture.ServiceDefaults.csproj index b18922a..55f4e2f 100644 --- a/CleanArchitecture.ServiceDefaults/CleanArchitecture.ServiceDefaults.csproj +++ b/CleanArchitecture.ServiceDefaults/CleanArchitecture.ServiceDefaults.csproj @@ -1,7 +1,7 @@ - net9.0 + net10.0 enable enable true @@ -10,8 +10,8 @@ - - + + diff --git a/CleanArchitecture.Shared/CleanArchitecture.Shared.csproj b/CleanArchitecture.Shared/CleanArchitecture.Shared.csproj index 579369f..0c2e7a5 100644 --- a/CleanArchitecture.Shared/CleanArchitecture.Shared.csproj +++ b/CleanArchitecture.Shared/CleanArchitecture.Shared.csproj @@ -1,7 +1,7 @@ - net9.0 + net10.0 enable diff --git a/CleanArchitecture.gRPC.Tests/CleanArchitecture.gRPC.Tests.csproj b/CleanArchitecture.gRPC.Tests/CleanArchitecture.gRPC.Tests.csproj index 9585280..6aa2ebc 100644 --- a/CleanArchitecture.gRPC.Tests/CleanArchitecture.gRPC.Tests.csproj +++ b/CleanArchitecture.gRPC.Tests/CleanArchitecture.gRPC.Tests.csproj @@ -1,7 +1,7 @@ - net9.0 + net10.0 enable false @@ -12,7 +12,7 @@ all runtime; build; native; contentfiles; analyzers; buildtransitive - + diff --git a/CleanArchitecture.gRPC/CleanArchitecture.gRPC.csproj b/CleanArchitecture.gRPC/CleanArchitecture.gRPC.csproj index 581e4cb..0910c53 100644 --- a/CleanArchitecture.gRPC/CleanArchitecture.gRPC.csproj +++ b/CleanArchitecture.gRPC/CleanArchitecture.gRPC.csproj @@ -1,7 +1,7 @@  - net9.0 + net10.0 enable diff --git a/Dockerfile b/Dockerfile index 3247ed9..18fac04 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,8 +1,8 @@ -FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/aspnet:9.0 AS base +FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/aspnet:10.0 AS base USER $APP_UID WORKDIR /app -FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/sdk:9.0 AS build +FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/sdk:10.0 AS build ARG BUILD_CONFIGURATION=Release ARG TARGETARCH WORKDIR /src diff --git a/Readme.md b/Readme.md index 0ae2fc3..d483c74 100644 --- a/Readme.md +++ b/Readme.md @@ -1,4 +1,4 @@ -# Clean Architecture Dotnet 9 API Project +# Clean Architecture Dotnet 10 API Project ![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/alex289/CleanArchitecture/dotnet.yml) @@ -83,4 +83,4 @@ To run the tests, follow these steps: This project uses GitHub Actions to build and test the project on every commit to the main branch. The workflow consists of several steps, including restoring packages, building the project and running tests. ## Conclusion -This project is a sample implementation of the Clean Architecture principles, Onion Architecture, MediatR, and Entity Framework. It demonstrates how to organize a .NET 9 API project into layers, how to use the MediatR library to implement the mediator pattern, and how to use Entity Framework to access data. It also includes unit tests for all layers and integration tests using xUnit. +This project is a sample implementation of the Clean Architecture principles, Onion Architecture, MediatR, and Entity Framework. It demonstrates how to organize a .NET 10 API project into layers, how to use the MediatR library to implement the mediator pattern, and how to use Entity Framework to access data. It also includes unit tests for all layers and integration tests using xUnit.