Skip to content

Commit 431adb4

Browse files
committed
dotnet 10 upgrade
1 parent 2be1719 commit 431adb4

File tree

21 files changed

+393
-402
lines changed

21 files changed

+393
-402
lines changed

Directory.Build.props

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,25 @@
11
<Project>
22
<PropertyGroup>
33
<TreatWarningsAsErrors>false</TreatWarningsAsErrors>
4-
<TargetFramework>net9.0</TargetFramework>
4+
<TargetFramework>net10.0</TargetFramework>
55
<Nullable>enable</Nullable>
66
<ImplicitUsings>enable</ImplicitUsings>
7+
8+
<!-- Never run analyzers as part of compilation (local, CI, dotnet build/test/publish) -->
9+
<RunAnalyzersDuringBuild>false</RunAnalyzersDuringBuild>
10+
11+
<!-- Keep background/live analysis in the IDE -->
12+
<RunAnalyzersDuringLiveAnalysis>true</RunAnalyzersDuringLiveAnalysis>
13+
14+
<!-- Optional: ensure code-style analyzers don't run during build either -->
15+
<EnforceCodeStyleInBuild>false</EnforceCodeStyleInBuild>
716
</PropertyGroup>
17+
18+
<ItemGroup>
19+
<PackageReference Include="Pandatech.Analyzers" Version="1.6.0"/>
20+
<PackageReference Include="SonarAnalyzer.CSharp" Version="10.17.0.131074">
21+
<PrivateAssets>all</PrivateAssets>
22+
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
23+
</PackageReference>
24+
</ItemGroup>
825
</Project>

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM mcr.microsoft.com/dotnet/aspnet:9.0 AS base
1+
FROM mcr.microsoft.com/dotnet/aspnet:10.0 AS base
22
WORKDIR /app
33
COPY ["./publish/", "./"]
44
ENTRYPOINT ["dotnet", "Pandatech.VerticalSlices.dll"]

Dockerfile.Local

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
FROM mcr.microsoft.com/dotnet/aspnet:9.0 AS base
1+
FROM mcr.microsoft.com/dotnet/aspnet:10.0 AS base
22
USER $APP_UID
33
WORKDIR /app
44
EXPOSE 80
55

6-
FROM mcr.microsoft.com/dotnet/sdk:9.0 AS build
6+
FROM mcr.microsoft.com/dotnet/sdk:10.0 AS build
77
ARG BUILD_CONFIGURATION=Release
88
WORKDIR /build
99
COPY ["Directory.Build.props", "."]

Pandatech.VerticalSlices.sln

Lines changed: 0 additions & 49 deletions
This file was deleted.

Pandatech.VerticalSlices.slnx

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<Solution>
2+
<Folder Name="/Solution Items/">
3+
<File Path=".editorconfig" />
4+
<File Path=".gitignore" />
5+
<File Path="Directory.Build.props" />
6+
<File Path="docker-compose.yml" />
7+
<File Path="Dockerfile" />
8+
<File Path="Dockerfile.Local" />
9+
<File Path="global.json" />
10+
<File Path="nuget.config" />
11+
<File Path="Readme.md" />
12+
</Folder>
13+
<Folder Name="/src/">
14+
<Project Path="src/Pandatech.VerticalSlices/Pandatech.VerticalSlices.csproj" />
15+
</Folder>
16+
<Folder Name="/tests/">
17+
<Project Path="test/Pandatech.VerticalSlices.Tests/Pandatech.VerticalSlices.Tests.csproj" />
18+
</Folder>
19+
</Solution>

global.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"sdk": {
3-
"version": "9.0.100",
3+
"version": "10.0.101",
44
"rollForward": "latestMinor"
55
}
66
}

src/Pandatech.VerticalSlices/Context/PostgresContext.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
using EFCore.AuditBase;
2-
using GridifyExtensions.DbContextFunction;
32
using MassTransit.PostgresOutbox.Abstractions;
43
using MassTransit.PostgresOutbox.Entities;
54
using MassTransit.PostgresOutbox.Extensions;
@@ -10,7 +9,7 @@ namespace Pandatech.VerticalSlices.Context;
109

1110
//dotnet ef migrations add --project src\Pandatech.VerticalSlices\Pandatech.VerticalSlices.csproj --configuration Debug --output-dir Context/Migrations
1211
public class PostgresContext(DbContextOptions<PostgresContext> options)
13-
: PostgresFunctions(options), IOutboxDbContext, IInboxDbContext
12+
: DbContext(options), IOutboxDbContext, IInboxDbContext
1413
{
1514
public DbSet<Token> Tokens { get; set; }
1615
public DbSet<User> Users { get; set; }

src/Pandatech.VerticalSlices/Features/Auth/Api/AuthenticationEndpoints.cs

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,7 @@ public void AddRoutes(IEndpointRouteBuilder app)
2525
var groupApp = app
2626
.MapGroup(RoutePrefix)
2727
.WithTags(TagName)
28-
.WithGroupName(ApiHelper.GroupVertical)
29-
.DisableAntiforgery()
30-
.WithOpenApi();
28+
.WithGroupName(ApiHelper.GroupVertical);
3129

3230

3331
groupApp.MapPost("/login",
@@ -36,9 +34,9 @@ public void AddRoutes(IEndpointRouteBuilder app)
3634
HttpContext httpContext,
3735
IHostEnvironment environment,
3836
IConfiguration configuration,
39-
CancellationToken token) =>
37+
CancellationToken ct) =>
4038
{
41-
var response = await sender.Send(command, token);
39+
var response = await sender.Send(command, ct);
4240
var clientType = httpContext.TryParseClientType()
4341
.ConvertToEnum();
4442

@@ -63,11 +61,11 @@ public void AddRoutes(IEndpointRouteBuilder app)
6361
HttpContext httpContext,
6462
IHostEnvironment environment,
6563
IConfiguration configuration,
66-
CancellationToken token) =>
64+
CancellationToken ct) =>
6765
{
6866
var refreshTokenSignature =
6967
httpContext.TryParseRefreshTokenSignature(environment);
70-
var response = await sender.Send(new RefreshTokenCommand(refreshTokenSignature), token);
68+
var response = await sender.Send(new RefreshTokenCommand(refreshTokenSignature), ct);
7169
var clientType = httpContext.TryParseClientType()
7270
.ConvertToEnum();
7371

@@ -87,19 +85,19 @@ public void AddRoutes(IEndpointRouteBuilder app)
8785

8886

8987
groupApp.MapGet("/state",
90-
async (ISender sender, CancellationToken token) =>
88+
async (ISender sender, CancellationToken ct) =>
9189
{
92-
var identity = await sender.Send(new GetIdentityStateQuery(), token);
90+
var identity = await sender.Send(new GetIdentityStateQuery(), ct);
9391
return TypedResults.Ok(identity);
9492
})
9593
.Authorize(UserRole.User)
9694
.WithDescription("This endpoint is used to get the current user state.");
9795

9896

9997
groupApp.MapPatch("/password/force",
100-
async (ISender sender, UpdatePasswordForcedCommand command, CancellationToken token) =>
98+
async (ISender sender, UpdatePasswordForcedCommand command, CancellationToken ct) =>
10199
{
102-
await sender.Send(command, token);
100+
await sender.Send(command, ct);
103101
return TypedResults.Ok();
104102
})
105103
.Authorize(UserRole.User)

src/Pandatech.VerticalSlices/Features/Auth/Helpers/ApiAuth/MinimalApiExtensions/MinimalApiAuthExtensions.cs

Lines changed: 43 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -6,49 +6,52 @@ namespace Pandatech.VerticalSlices.Features.Auth.Helpers.ApiAuth.MinimalApiExten
66

77
public static class MinimalApiAuthExtensions
88
{
9-
public static RouteHandlerBuilder Authorize(this RouteHandlerBuilder builder,
10-
UserRole minimalUserRole = UserRole.Admin)
9+
extension(RouteHandlerBuilder builder)
1110
{
12-
builder.Add(endpointBuilder =>
11+
public RouteHandlerBuilder Authorize(UserRole minimalUserRole = UserRole.Admin)
1312
{
14-
var original = endpointBuilder.RequestDelegate;
15-
16-
endpointBuilder.RequestDelegate = async context =>
13+
builder.Add(endpointBuilder =>
1714
{
18-
var forceToChangePassword =
19-
context.GetEndpoint()
20-
?.Metadata
21-
.GetMetadata<ForcedPasswordChangeMetadata>() != null;
22-
var ignoreClientType = context.GetEndpoint()
23-
?.Metadata
24-
.GetMetadata<IgnoreClientTypeMetadata>() != null;
25-
var sender = context.RequestServices.GetRequiredService<ISender>();
26-
27-
28-
await sender.Send(new AuthQuery(context,
29-
minimalUserRole,
30-
false,
31-
forceToChangePassword,
32-
ignoreClientType),
33-
context.RequestAborted);
34-
35-
36-
await original!(context);
37-
// Post-execution logic
38-
};
39-
});
40-
41-
return builder;
42-
}
43-
public static RouteHandlerBuilder ForcedPasswordChange(this RouteHandlerBuilder builder)
44-
{
45-
builder.WithMetadata(new ForcedPasswordChangeMetadata());
46-
return builder;
47-
}
15+
var original = endpointBuilder.RequestDelegate;
4816

49-
public static RouteHandlerBuilder IgnoreClientType(this RouteHandlerBuilder builder)
50-
{
51-
builder.WithMetadata(new IgnoreClientTypeMetadata());
52-
return builder;
17+
endpointBuilder.RequestDelegate = async context =>
18+
{
19+
var forceToChangePassword =
20+
context.GetEndpoint()
21+
?.Metadata
22+
.GetMetadata<ForcedPasswordChangeMetadata>() != null;
23+
var ignoreClientType = context.GetEndpoint()
24+
?.Metadata
25+
.GetMetadata<IgnoreClientTypeMetadata>() != null;
26+
var sender = context.RequestServices.GetRequiredService<ISender>();
27+
28+
29+
await sender.Send(new AuthQuery(context,
30+
minimalUserRole,
31+
false,
32+
forceToChangePassword,
33+
ignoreClientType),
34+
context.RequestAborted);
35+
36+
37+
await original!(context);
38+
// Post-execution logic
39+
};
40+
});
41+
42+
return builder;
43+
}
44+
45+
public RouteHandlerBuilder ForcedPasswordChange()
46+
{
47+
builder.WithMetadata(new ForcedPasswordChangeMetadata());
48+
return builder;
49+
}
50+
51+
public RouteHandlerBuilder IgnoreClientType()
52+
{
53+
builder.WithMetadata(new IgnoreClientTypeMetadata());
54+
return builder;
55+
}
5356
}
5457
}

0 commit comments

Comments
 (0)