Skip to content

Commit ce44aec

Browse files
committed
feat(runtime): upgrade project to latest .NET version
BREAKING CHANGE: dropped support for non-LTS .NET versions
1 parent 3dc7d0d commit ce44aec

19 files changed

Lines changed: 211 additions & 160 deletions

File tree

samples/1_AspNet.Default/AspNet.Default.csproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
<Project Sdk="Microsoft.NET.Sdk.Web">
22

33
<PropertyGroup>
4-
<TargetFramework>net8.0</TargetFramework>
4+
<TargetFrameworks>net8.0;net9.0;net10.0</TargetFrameworks>
55
<Nullable>enable</Nullable>
66
<IsPackable>false</IsPackable>
77
<ImplicitUsings>enable</ImplicitUsings>
88
</PropertyGroup>
99

1010
<ItemGroup>
11-
<PackageReference Include="Bogus" Version="34.0.2" />
12-
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.5.0" />
11+
<PackageReference Include="Bogus" Version="35.6.5" />
12+
<PackageReference Include="Swashbuckle.AspNetCore" Version="10.1.1" />
1313
</ItemGroup>
1414

1515
<ItemGroup>
Lines changed: 15 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,33 @@
11
using System.Security.Claims;
22
using Bogus;
3-
using Microsoft.OpenApi.Models;
3+
using Microsoft.OpenApi;
44

55
namespace AspNet.Default
66
{
77
public static class FakeClaims
88
{
99
public static Faker<Claim> GenerateClaim()
10-
{
11-
return new Faker<Claim>().CustomInstantiator(f => new Claim(f.Internet.DomainName(), f.Lorem.Text()));
12-
}
10+
=> new Faker<Claim>()
11+
.CustomInstantiator(f => new Claim(f.Internet.DomainName(), f.Lorem.Text()));
1312
}
1413

1514
public static class CustomSwagger
1615
{
1716
public static void AddSwagger(this IServiceCollection services)
1817
{
1918
services.AddSwaggerGen(c =>
20-
{
21-
c.AddSecurityDefinition("Bearer", new OpenApiSecurityScheme
22-
{
23-
Description = "Bearer {token}",
24-
Name = "Authorization",
25-
Scheme = "Bearer",
26-
BearerFormat = "JWT",
27-
In = ParameterLocation.Header,
28-
Type = SecuritySchemeType.ApiKey
29-
});
19+
{
20+
c.AddSecurityDefinition("Bearer", new OpenApiSecurityScheme
21+
{
22+
Description = "Bearer {token}",
23+
Name = "Authorization",
24+
In = ParameterLocation.Header,
25+
Type = SecuritySchemeType.Http,
26+
Scheme = "bearer",
27+
BearerFormat = "JWT",
28+
});
3029

31-
c.AddSecurityRequirement(new OpenApiSecurityRequirement
32-
{
33-
{
34-
new OpenApiSecurityScheme
35-
{
36-
Reference = new OpenApiReference
37-
{
38-
Type = ReferenceType.SecurityScheme,
39-
Id = "Bearer"
40-
}
41-
},
42-
new string[] { }
43-
}
44-
});
45-
});
30+
});
4631
}
4732
}
48-
}
33+
}

samples/1_AspNet.Default/Program.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
using System.Collections.Generic;
2+
using System.Linq;
13
using System.Security.Claims;
24
using AspNet.Default;
35
using Microsoft.AspNetCore.Authentication.JwtBearer;

samples/2_AspNet.Store.EntityFramework/AspNet.Store.EntityFramework.csproj

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,34 @@
11
<Project Sdk="Microsoft.NET.Sdk.Web">
22

33
<PropertyGroup>
4-
<TargetFramework>net8.0</TargetFramework>
4+
<TargetFrameworks>net8.0;net9.0;net10.0</TargetFrameworks>
55
<Nullable>enable</Nullable>
66
<IsPackable>false</IsPackable>
77
<ImplicitUsings>enable</ImplicitUsings>
88
</PropertyGroup>
99

1010
<ItemGroup>
11-
<PackageReference Include="Bogus" Version="34.0.2" />
12-
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="8.0.0" />
13-
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="8.0.0" />
14-
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="8.0.0" />
15-
<PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="8.0.0" />
16-
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.5.0" />
11+
<PackageReference Include="Bogus" Version="35.6.5" />
12+
<PackageReference Include="Swashbuckle.AspNetCore" Version="10.1.1" />
13+
</ItemGroup>
14+
15+
<ItemGroup Condition="'$(TargetFramework)' == 'net8.0'">
16+
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="8.0.23" />
17+
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="8.0.23" />
18+
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="8.0.23" />
19+
<PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="8.0.1" />
20+
</ItemGroup>
21+
<ItemGroup Condition="'$(TargetFramework)' == 'net9.0'">
22+
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="9.0.12" />
23+
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="9.0.12" />
24+
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="9.0.12" />
25+
<PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="9.0.12" />
26+
</ItemGroup>
27+
<ItemGroup Condition="'$(TargetFramework)' == 'net10.0'">
28+
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="10.0.2" />
29+
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="10.0.2" />
30+
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="10.0.2" />
31+
<PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="10.0.2" />
1732
</ItemGroup>
1833

1934
<ItemGroup>

samples/2_AspNet.Store.EntityFramework/CustomDemoSettings.cs

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
using System.Security.Claims;
22
using Bogus;
3-
using Microsoft.OpenApi.Models;
3+
using Microsoft.OpenApi;
44

55
namespace AspNet.Store.EntityFramework
66
{
@@ -27,21 +27,7 @@ public static void AddSwagger(this IServiceCollection services)
2727
In = ParameterLocation.Header,
2828
Type = SecuritySchemeType.ApiKey
2929
});
30-
31-
c.AddSecurityRequirement(new OpenApiSecurityRequirement
32-
{
33-
{
34-
new OpenApiSecurityScheme
35-
{
36-
Reference = new OpenApiReference
37-
{
38-
Type = ReferenceType.SecurityScheme,
39-
Id = "Bearer"
40-
}
41-
},
42-
new string[] { }
43-
}
44-
});
30+
4531
});
4632
}
4733
}

samples/2_AspNet.Store.EntityFramework/Program.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
using Microsoft.IdentityModel.JsonWebTokens;
88
using Microsoft.IdentityModel.Logging;
99
using Microsoft.IdentityModel.Tokens;
10-
using Microsoft.OpenApi.Models;
1110
using NetDevPack.Security.Jwt.Core.Interfaces;
1211

1312

samples/3_IdentityServer4/AspNet.IdentityServer4.csproj

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,18 @@
11
<Project Sdk="Microsoft.NET.Sdk.Web">
22

33
<PropertyGroup>
4-
<TargetFramework>net8.0</TargetFramework>
4+
<TargetFrameworks>net8.0;net9.0;net10.0</TargetFrameworks>
55
<IsPackable>false</IsPackable>
66
</PropertyGroup>
77

8-
<ItemGroup>
9-
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="8.0.0" />
8+
<ItemGroup Condition="'$(TargetFramework)' == 'net8.0'">
9+
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="8.0.23" />
10+
</ItemGroup>
11+
<ItemGroup Condition="'$(TargetFramework)' == 'net9.0'">
12+
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="9.0.12" />
13+
</ItemGroup>
14+
<ItemGroup Condition="'$(TargetFramework)' == 'net10.0'">
15+
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="10.0.2" />
1016
</ItemGroup>
1117
<ItemGroup>
1218
<ProjectReference Include="..\..\src\NetDevPack.Security.Jwt.AspNetCore\NetDevPack.Security.Jwt.AspNetCore.csproj" />
Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,24 @@
11
<Project Sdk="Microsoft.NET.Sdk.Web">
22

33
<PropertyGroup>
4-
<TargetFramework>net8.0</TargetFramework>
4+
<TargetFrameworks>net8.0;net9.0;net10.0</TargetFrameworks>
55
<Nullable>enable</Nullable>
66
<ImplicitUsings>enable</ImplicitUsings>
77
</PropertyGroup>
88

99
<ItemGroup>
10-
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="8.0.0" />
11-
<PackageReference Include="NetDevPack.Security.JwtExtensions" Version="7.0.0" />
12-
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.5.0" />
10+
<PackageReference Include="NetDevPack.Security.JwtExtensions" Version="8.0.0" />
11+
<PackageReference Include="Swashbuckle.AspNetCore" Version="10.1.1" />
12+
</ItemGroup>
13+
14+
<ItemGroup Condition="'$(TargetFramework)' == 'net8.0'">
15+
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="8.0.23" />
16+
</ItemGroup>
17+
<ItemGroup Condition="'$(TargetFramework)' == 'net9.0'">
18+
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="9.0.12" />
19+
</ItemGroup>
20+
<ItemGroup Condition="'$(TargetFramework)' == 'net10.0'">
21+
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="10.0.2" />
1322
</ItemGroup>
1423

1524
</Project>
Lines changed: 17 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
using Microsoft.AspNetCore.Authentication.JwtBearer;
22
using Microsoft.AspNetCore.Authorization;
3-
using Microsoft.OpenApi.Models;
3+
using Microsoft.OpenApi;
44
using NetDevPack.Security.JwtExtensions;
55

66
var builder = WebApplication.CreateBuilder(args);
@@ -17,28 +17,13 @@
1717
In = ParameterLocation.Header,
1818
Type = SecuritySchemeType.ApiKey
1919
});
20-
21-
c.AddSecurityRequirement(new OpenApiSecurityRequirement
22-
{
23-
{
24-
new OpenApiSecurityScheme
25-
{
26-
Reference = new OpenApiReference
27-
{
28-
Type = ReferenceType.SecurityScheme,
29-
Id = "Bearer"
30-
}
31-
},
32-
new string[] { }
33-
}
34-
});
3520
});
3621

3722
builder.Services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme).AddJwtBearer(x =>
3823
{
3924
x.RequireHttpsMetadata = true;
4025
x.SaveToken = true;
41-
26+
4227
x.SetJwksOptions(new JwkOptions("https://localhost:5080/jwks", issuer: "https://www.devstore.academy", audience: "NetDevPack.Security.Jwt.AspNet"));
4328
});
4429
builder.Services.AddAuthorization();
@@ -60,24 +45,24 @@
6045
"Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching"
6146
};
6247

63-
app.MapGet("/weatherforecast", [Authorize] () =>
64-
{
65-
var forecast = Enumerable.Range(1, 5).Select(index =>
66-
new WeatherForecast
67-
(
68-
DateOnly.FromDateTime(DateTime.Now.AddDays(index)),
69-
Random.Shared.Next(-20, 55),
70-
summaries[Random.Shared.Next(summaries.Length)]
71-
))
72-
.ToArray();
73-
return forecast;
74-
})
75-
.WithName("GetWeatherForecast")
76-
.WithOpenApi();
48+
app.MapGet("/weatherforecast", [Authorize]() =>
49+
{
50+
var forecast = Enumerable.Range(1, 5).Select(index =>
51+
new WeatherForecast
52+
(
53+
DateOnly.FromDateTime(DateTime.Now.AddDays(index)),
54+
Random.Shared.Next(-20, 55),
55+
summaries[Random.Shared.Next(summaries.Length)]
56+
))
57+
.ToArray();
58+
return forecast;
59+
})
60+
.WithName("GetWeatherForecast")
61+
.WithOpenApi();
7762

7863
app.Run();
7964

8065
internal record WeatherForecast(DateOnly Date, int TemperatureC, string? Summary)
8166
{
8267
public int TemperatureF => 32 + (int)(TemperatureC / 0.5556);
83-
}
68+
}

samples/Microservice.Sample/Identity/Identity.csproj

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,31 @@
11
<Project Sdk="Microsoft.NET.Sdk.Web">
22

33
<PropertyGroup>
4-
<TargetFramework>net8.0</TargetFramework>
4+
<TargetFrameworks>net8.0;net9.0;net10.0</TargetFrameworks>
55
<Nullable>enable</Nullable>
66
<ImplicitUsings>enable</ImplicitUsings>
77
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
88
<DockerfileContext>..\..\..\src</DockerfileContext>
99
</PropertyGroup>
1010

1111
<ItemGroup>
12-
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="8.0.4" />
13-
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="8.0.4" />
14-
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="8.0.4" />
15-
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.5.0" />
12+
<PackageReference Include="Swashbuckle.AspNetCore" Version="10.1.1" />
13+
</ItemGroup>
14+
15+
<ItemGroup Condition="'$(TargetFramework)' == 'net8.0'">
16+
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="8.0.23" />
17+
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="8.0.23" />
18+
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="8.0.23" />
19+
</ItemGroup>
20+
<ItemGroup Condition="'$(TargetFramework)' == 'net9.0'">
21+
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="9.0.12" />
22+
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="9.0.12" />
23+
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="9.0.12" />
24+
</ItemGroup>
25+
<ItemGroup Condition="'$(TargetFramework)' == 'net10.0'">
26+
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="10.0.2" />
27+
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="10.0.2" />
28+
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="10.0.2" />
1629
</ItemGroup>
1730

1831
<ItemGroup>

0 commit comments

Comments
 (0)