Skip to content

Commit bc2e4ec

Browse files
authored
Merge pull request #15 from babaktaremi/feature/updated-to-net-9
feature/updated-to-net-9
2 parents 8f176d7 + f57384d commit bc2e4ec

File tree

69 files changed

+687
-686
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

69 files changed

+687
-686
lines changed

CleanArcTemplate.nuspec

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@
33
<metadata>
44

55
<id>Bobby.CleanArcTemplate</id>
6-
<version>5.2.0</version>
6+
<version>9.0.0</version>
77
<title>Clean Architecture Solution Template</title>
88
<authors>BabakTaremi</authors>
9-
<description>Clean Architecture Solution Template for and .NET 8. With many features available out of the box</description>
9+
<description>Clean Architecture Solution Template for and .NET 9. With many features available out of the box</description>
1010
<summary>
1111
Ready to develop template based on clean architecture principles. Supports ASP NET Core Identity integrated with JWE tokens, OTP authentication, stand alone plugin development, CQRS pattern using MediatR library and dynamic permission management system out of the box
1212
</summary>
1313
<releaseNotes>
14-
Package updates. Fix a bug in auto register Automapper profiles where class did not have default constructor
14+
Update To NET 9, Package Updates, Replaced Swashbuckle With NSwag ,Validation Errors No longer Throw Exceptions ,Removed Dependency of IServiceProvider in Base validator class, Monitoring Project ( Health Checks And Metrics ) Added With OpenTelemetry And Prometheus ,Added Metrics Related To Commands/Queries ,Updated AutoMapper Sample For Supporting Record Types, Dockerfile updated for .NET9 SDK, Added Custom Produce Response attribute to add ApiResult type example
1515
</releaseNotes>
1616

1717

CleanArcTemplate.sln

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Infrastructure", "Infrastru
4343
EndProject
4444
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CleanArc.Test.Infrastructure.Identity", "src\Tests\CleanArc.Test.Infrastructure.Identity\CleanArc.Test.Infrastructure.Identity\CleanArc.Test.Infrastructure.Identity.csproj", "{54203B4F-3CE8-4EBA-B5E2-F7C985FACE60}"
4545
EndProject
46+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CleanArc.Infrastructure.Monitoring", "src\Infrastructure\CleanArc.Infrastructure.Monitoring\CleanArc.Infrastructure.Monitoring.csproj", "{7699705C-2C15-467F-957D-4C5EBE4FD92E}"
47+
EndProject
4648
Global
4749
GlobalSection(SolutionConfigurationPlatforms) = preSolution
4850
Debug|Any CPU = Debug|Any CPU
@@ -93,6 +95,10 @@ Global
9395
{54203B4F-3CE8-4EBA-B5E2-F7C985FACE60}.Debug|Any CPU.Build.0 = Debug|Any CPU
9496
{54203B4F-3CE8-4EBA-B5E2-F7C985FACE60}.Release|Any CPU.ActiveCfg = Release|Any CPU
9597
{54203B4F-3CE8-4EBA-B5E2-F7C985FACE60}.Release|Any CPU.Build.0 = Release|Any CPU
98+
{7699705C-2C15-467F-957D-4C5EBE4FD92E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
99+
{7699705C-2C15-467F-957D-4C5EBE4FD92E}.Debug|Any CPU.Build.0 = Debug|Any CPU
100+
{7699705C-2C15-467F-957D-4C5EBE4FD92E}.Release|Any CPU.ActiveCfg = Release|Any CPU
101+
{7699705C-2C15-467F-957D-4C5EBE4FD92E}.Release|Any CPU.Build.0 = Release|Any CPU
96102
EndGlobalSection
97103
GlobalSection(SolutionProperties) = preSolution
98104
HideSolutionNode = FALSE
@@ -117,6 +123,7 @@ Global
117123
{33AF382A-9E22-42F0-82E5-4F78BCFD40C1} = {34B1F72E-A991-4705-ACC5-08E65E46D26E}
118124
{45FA88C0-9986-40E5-A2E2-7742302518D2} = {77986571-8153-4120-AD08-36729310A56B}
119125
{54203B4F-3CE8-4EBA-B5E2-F7C985FACE60} = {45FA88C0-9986-40E5-A2E2-7742302518D2}
126+
{7699705C-2C15-467F-957D-4C5EBE4FD92E} = {2373AFFC-1389-4D78-8465-074AB22084AF}
120127
EndGlobalSection
121128
GlobalSection(ExtensibilityGlobals) = postSolution
122129
SolutionGuid = {05C223B9-EA89-44B2-B9F5-D01181F85DFE}

Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
#See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging.
22

3-
FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base
3+
FROM mcr.microsoft.com/dotnet/aspnet:9.0 AS base
44
WORKDIR /app
55
EXPOSE 80
66
EXPOSE 443
77

8-
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
8+
FROM mcr.microsoft.com/dotnet/sdk:9.0 AS build
99
WORKDIR /src
1010
COPY ["src/API/CleanArc.Web.Api/CleanArc.Web.Api.csproj", "src/API/CleanArc.Web.Api/"]
1111
COPY ["src/API/CleanArc.WebFramework/CleanArc.WebFramework.csproj", "src/API/CleanArc.WebFramework/"]
Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,30 @@
11
<Project Sdk="Microsoft.NET.Sdk.Web">
22

33
<PropertyGroup>
4-
<TargetFramework>net8.0</TargetFramework>
4+
<TargetFramework>net9.0</TargetFramework>
55
<ImplicitUsings>enable</ImplicitUsings>
66
<IsPackable>true</IsPackable>
7-
</PropertyGroup>
8-
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
9-
<DocumentationFile>Project.xml</DocumentationFile>
10-
<OutputPath>bin\Debug\</OutputPath>
7+
<GenerateDocumentationFile>true</GenerateDocumentationFile>
118
<NoWarn>$(NoWarn);1591</NoWarn>
129
</PropertyGroup>
1310
<ItemGroup>
14-
<PackageReference Include="Carter" Version="8.0.0" />
15-
<PackageReference Include="Serilog.AspNetCore" Version="8.0.1" />
16-
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="8.0.3" />
17-
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.5.0" />
18-
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="8.0.3">
11+
<PackageReference Include="Carter" Version="8.2.1" />
12+
<PackageReference Include="Serilog.AspNetCore" Version="8.0.3" />
13+
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="9.0.0" />
14+
<PackageReference Include="Swashbuckle.AspNetCore" Version="7.0.0" />
15+
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="9.0.0">
1916
<PrivateAssets>all</PrivateAssets>
2017
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
2118
</PackageReference>
22-
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="8.0.2" />
19+
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="9.0.0" />
2320
<PackageReference Include="AutoMapper" Version="13.0.1" />
24-
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="8.0.0" />
21+
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="9.0.0" />
2522
</ItemGroup>
2623

2724
<ItemGroup>
25+
<ProjectReference Include="..\..\Infrastructure\CleanArc.Infrastructure.Monitoring\CleanArc.Infrastructure.Monitoring.csproj" />
2826
<ProjectReference Include="..\CleanArc.WebFramework\CleanArc.WebFramework.csproj" />
2927
<ProjectReference Include="..\Plugins\CleanArc.Web.Plugins.Grpc\CleanArc.Web.Plugins.Grpc.csproj" />
3028
</ItemGroup>
3129

32-
<ItemGroup>
33-
<None Update="Project.xml">
34-
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
35-
</None>
36-
</ItemGroup>
37-
3830
</Project>

src/API/CleanArc.Web.Api/Controllers/V1/Admin/AdminManagerController.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
using Asp.Versioning;
22
using CleanArc.Application.Features.Admin.Commands.AddAdminCommand;
33
using CleanArc.Application.Features.Admin.Queries.GetToken;
4+
using CleanArc.Application.Models.Jwt;
5+
using CleanArc.WebFramework.Attributes;
46
using CleanArc.WebFramework.BaseController;
5-
using CleanArc.WebFramework.WebExtensions;
67
using Mediator;
78
using Microsoft.AspNetCore.Authorization;
89
using Microsoft.AspNetCore.Mvc;
@@ -15,6 +16,7 @@ namespace CleanArc.Web.Api.Controllers.V1.Admin
1516
public class AdminManagerController(ISender sender) : BaseController
1617
{
1718
[HttpPost("Login")]
19+
[ProducesOkApiResponseType<AccessToken>]
1820
public async Task<IActionResult> AdminLogin(AdminGetTokenQuery model)
1921
{
2022
var query = await sender.Send(model);
@@ -24,6 +26,7 @@ public async Task<IActionResult> AdminLogin(AdminGetTokenQuery model)
2426

2527
[Authorize(Roles = "admin")]
2628
[HttpPost("NewAdmin")]
29+
[ProducesOkApiResponseType]
2730
public async Task<IActionResult> AddNewAdmin(AddAdminCommand model)
2831
{
2932
var commandResult = await sender.Send(model);

src/API/CleanArc.Web.Api/Controllers/V1/Admin/OrderManagementController.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
using System.ComponentModel.DataAnnotations;
55
using Asp.Versioning;
66
using CleanArc.Application.Features.Order.Queries.GetAllOrders;
7+
using CleanArc.WebFramework.Attributes;
78
using CleanArc.WebFramework.BaseController;
8-
using CleanArc.WebFramework.WebExtensions;
99
using Mediator;
1010

1111
namespace CleanArc.Web.Api.Controllers.V1.Admin
@@ -25,6 +25,7 @@ public OrderManagementController(ISender sender)
2525
}
2626

2727
[HttpGet("OrderList")]
28+
[ProducesOkApiResponseType<List<GetAllOrdersQueryResult>>]
2829
public async Task<IActionResult> GetOrders()
2930
{
3031
var queryResult = await _sender.Send(new GetAllOrdersQuery());

src/API/CleanArc.Web.Api/Controllers/V1/Admin/RoleManagerController.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
using CleanArc.Application.Features.Role.Queries.GetAllRolesQuery;
66
using CleanArc.Application.Features.Role.Queries.GetAuthorizableRoutesQuery;
77
using CleanArc.Infrastructure.Identity.Identity.PermissionManager;
8+
using CleanArc.WebFramework.Attributes;
89
using CleanArc.WebFramework.BaseController;
9-
using CleanArc.WebFramework.WebExtensions;
1010
using Mediator;
1111
using Microsoft.AspNetCore.Authorization;
1212
using Microsoft.AspNetCore.Mvc;
@@ -22,6 +22,7 @@ namespace CleanArc.Web.Api.Controllers.V1.Admin
2222
public class RoleManagerController(ISender sender) : BaseController
2323
{
2424
[HttpGet("Roles")]
25+
[ProducesOkApiResponseType<List<GetAllRolesQueryResponse>>]
2526
public async Task<IActionResult> GetRoles()
2627
{
2728
var queryResult = await sender.Send(new GetAllRolesQuery());
@@ -30,6 +31,7 @@ public async Task<IActionResult> GetRoles()
3031
}
3132

3233
[HttpGet("AuthRoutes")]
34+
[ProducesOkApiResponseType<List<GetAuthorizableRoutesQueryResponse>>]
3335
public async Task<IActionResult> GetAuthRoutes()
3436
{
3537
var queryModel = await sender.Send(new GetAuthorizableRoutesQuery());
@@ -43,6 +45,7 @@ public async Task<IActionResult> GetAuthRoutes()
4345
/// <param name="model"></param>
4446
/// <returns></returns>
4547
[HttpPut("UpdateRolePermissions")]
48+
[ProducesOkApiResponseType]
4649
public async Task<IActionResult> UpdateRolePermissions(UpdateRoleClaimsCommand model)
4750
{
4851
var commandResult =
@@ -52,6 +55,7 @@ public async Task<IActionResult> UpdateRolePermissions(UpdateRoleClaimsCommand m
5255
}
5356

5457
[HttpPost("NewRole")]
58+
[ProducesOkApiResponseType]
5559
public async Task<IActionResult> AddRole(AddRoleCommand model)
5660
{
5761
var commandResult = await sender.Send(model);

src/API/CleanArc.Web.Api/Controllers/V1/Admin/UserManagementController.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
using System.ComponentModel.DataAnnotations;
55
using Asp.Versioning;
66
using CleanArc.Application.Features.Users.Queries.GetUsers;
7+
using CleanArc.WebFramework.Attributes;
78
using CleanArc.WebFramework.BaseController;
8-
using CleanArc.WebFramework.WebExtensions;
99
using Mediator;
1010

1111
namespace CleanArc.Web.Api.Controllers.V1.Admin
@@ -25,6 +25,7 @@ public UserManagementController(ISender sender)
2525
}
2626

2727
[HttpGet("CurrentUsers")]
28+
[ProducesOkApiResponseType<List<GetUsersQueryResponse>>]
2829
public async Task<IActionResult> GetAllUsers()
2930
{
3031
var queryResult = await _sender.Send(new GetUsersQuery());

src/API/CleanArc.Web.Api/Controllers/V1/Order/OrderController.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
using Asp.Versioning;
22
using CleanArc.Application.Features.Order.Commands;
33
using CleanArc.Application.Features.Order.Queries.GetUserOrders;
4+
using CleanArc.WebFramework.Attributes;
45
using CleanArc.WebFramework.BaseController;
5-
using CleanArc.WebFramework.WebExtensions;
66
using Mediator;
77
using Microsoft.AspNetCore.Authorization;
88
using Microsoft.AspNetCore.Mvc;
@@ -16,6 +16,7 @@ namespace CleanArc.Web.Api.Controllers.V1.Order;
1616
public class OrderController(ISender sender) : BaseController
1717
{
1818
[HttpPost("CreateNewOrder")]
19+
[ProducesOkApiResponseType]
1920
public async Task<IActionResult> CreateNewOrder(AddOrderCommand model)
2021
{
2122
model.UserId = base.UserId;
@@ -25,6 +26,7 @@ public async Task<IActionResult> CreateNewOrder(AddOrderCommand model)
2526
}
2627

2728
[HttpGet("GetUserOrders")]
29+
[ProducesOkApiResponseType<List<GetUsersQueryResultModel>>]
2830
public async Task<IActionResult> GetUserOrders()
2931
{
3032
var query = await sender.Send(new GetUserOrdersQueryModel(UserId));
@@ -33,6 +35,7 @@ public async Task<IActionResult> GetUserOrders()
3335
}
3436

3537
[HttpPut("UpdateOrder")]
38+
[ProducesOkApiResponseType]
3639
public async Task<IActionResult> UpdateOrder(UpdateUserOrderCommand model)
3740
{
3841
model.UserId=base.UserId;
@@ -43,6 +46,7 @@ public async Task<IActionResult> UpdateOrder(UpdateUserOrderCommand model)
4346
}
4447

4548
[HttpDelete("DeleteAllUserOrders")]
49+
[ProducesOkApiResponseType]
4650
public async Task<IActionResult> DeleteAllUserOrders()
4751
=> base.OperationResult(await sender.Send(new DeleteUserOrdersCommand(base.UserId)));
4852
}

src/API/CleanArc.Web.Api/Controllers/V1/UserManagement/UserController.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@
44
using CleanArc.Application.Features.Users.Commands.RequestLogout;
55
using CleanArc.Application.Features.Users.Queries.GenerateUserToken;
66
using CleanArc.Application.Features.Users.Queries.TokenRequest;
7+
using CleanArc.Application.Models.Jwt;
8+
using CleanArc.WebFramework.Attributes;
79
using CleanArc.WebFramework.BaseController;
810
using CleanArc.WebFramework.Swagger;
9-
using CleanArc.WebFramework.WebExtensions;
1011
using Mediator;
1112
using Microsoft.AspNetCore.Authentication;
1213
using Microsoft.AspNetCore.Authentication.JwtBearer;
@@ -28,6 +29,7 @@ public UserController(IMediator mediator)
2829
}
2930

3031
[HttpPost("Register")]
32+
[ProducesOkApiResponseType<UserCreateCommandResult>]
3133
public async Task<IActionResult> CreateUser(UserCreateCommand model)
3234
{
3335
var command = await _mediator.Send(model);
@@ -37,6 +39,7 @@ public async Task<IActionResult> CreateUser(UserCreateCommand model)
3739

3840

3941
[HttpPost("TokenRequest")]
42+
[ProducesOkApiResponseType<UserTokenRequestQueryResponse>]
4043
public async Task<IActionResult> TokenRequest(UserTokenRequestQuery model)
4144
{
4245
var query = await _mediator.Send(model);
@@ -45,6 +48,7 @@ public async Task<IActionResult> TokenRequest(UserTokenRequestQuery model)
4548
}
4649

4750
[HttpPost("LoginConfirmation")]
51+
[ProducesOkApiResponseType<AccessToken>]
4852
public async Task<IActionResult> ValidateUser(GenerateUserTokenQuery model)
4953
{
5054
var result = await _mediator.Send(model);
@@ -54,6 +58,7 @@ public async Task<IActionResult> ValidateUser(GenerateUserTokenQuery model)
5458

5559
[HttpPost("RefreshSignIn")]
5660
[RequireTokenWithoutAuthorization]
61+
[ProducesOkApiResponseType<AccessToken>]
5762
public async Task<IActionResult> RefreshUserToken(RefreshUserTokenCommand model)
5863
{
5964
var checkCurrentAccessTokenValidity =await HttpContext.AuthenticateAsync(JwtBearerDefaults.AuthenticationScheme);
@@ -68,6 +73,7 @@ public async Task<IActionResult> RefreshUserToken(RefreshUserTokenCommand model)
6873

6974
[HttpPost("Logout")]
7075
[Authorize]
76+
[ProducesOkApiResponseType]
7177
public async Task<IActionResult> RequestLogout()
7278
{
7379
var commandResult = await _mediator.Send(new RequestLogoutCommand(base.UserId));

src/API/CleanArc.Web.Api/Endpoints/UserEndpoints.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,6 @@
88
using CleanArc.SharedKernel.Extensions;
99
using CleanArc.WebFramework.WebExtensions;
1010
using Mediator;
11-
using Microsoft.AspNetCore.Authentication;
12-
using Microsoft.AspNetCore.Authentication.JwtBearer;
13-
using Microsoft.AspNetCore.Mvc;
1411

1512
namespace CleanArc.Web.Api.Endpoints;
1613

0 commit comments

Comments
 (0)