Skip to content

Commit 61cfc40

Browse files
authored
Upgrade to .NET 10 RC 2 (#6)
1 parent 3d0de01 commit 61cfc40

38 files changed

+556
-457
lines changed

.certs/AspNetDev.pfx

2.68 KB
Binary file not shown.

.devcontainer/devcontainer.json

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
22
// README at: https://github.com/devcontainers/templates/tree/main/src/dotnet
33
{
4-
"name": "Bank API dotnet9",
5-
"image": "mcr.microsoft.com/devcontainers/dotnet:dev-9.0-bookworm", // bookworm is more up to date (with .NET SDK) than noble
4+
"name": "Bank API dotnet10",
5+
"image": "mcr.microsoft.com/devcontainers/dotnet:dev-10.0-noble", // https://mcr.microsoft.com/en-us/artifact/mar/devcontainers/dotnet/tags
66
"customizations": {
77
"vscode": {
88
"extensions": [
@@ -22,16 +22,18 @@
2222
"containerEnv": {
2323
"DOTNET_LAUNCH_PROFILE": "http",
2424
// Zscaler proxy support when reading custom rulesets over https in Spectral
25-
"NODE_EXTRA_CA_CERTS": "${containerWorkspaceFolder}/.certs/ZscalerRootCA.crt"
25+
"NODE_EXTRA_CA_CERTS": "${containerWorkspaceFolder}/.certs/ZscalerRootCA.crt"
2626
},
2727
// Features to add to the dev container. More info: https://containers.dev/features.
2828
"features": {
2929
"ghcr.io/devcontainers/features/dotnet:2": {
3030
"version": "none", // already pre-installed with image
31-
"aspNetCoreRuntimeVersions": "8.0" // for: https://github.com/microsoft/vscode-dotnettools/issues/1094
31+
"aspNetCoreRuntimeVersions": "9.0" // for: https://github.com/microsoft/vscode-dotnettools/issues/1094
3232
},
3333
"ghcr.io/devcontainers/features/azure-cli:1": {}, // for using the host az cli credentials
34-
"ghcr.io/devcontainers/features/docker-in-docker:2": {} // for .NET Aspire resource emulation
34+
"ghcr.io/devcontainers/features/docker-in-docker:2": {
35+
"moby": false
36+
} // for .NET Aspire resource emulation
3537
},
3638
"mounts": [
3739
// Bind the azure (credential) folder, requires an unencrypted token cache (assuming host is Windows).
@@ -40,10 +42,10 @@
4042
"source=${localEnv:HOME}${localEnv:USERPROFILE}/.azure,target=/home/vscode/.azure,type=bind",
4143
// Bind the Visual Studio Token provider folder
4244
"source=${localEnv:HOME}${localEnv:LOCALAPPDATA}/.IdentityService,target=/home/vscode/.IdentityService,type=bind",
43-
// Bind ASP.NET user secrets folder (please see https://learn.microsoft.com/en-us/aspnet/core/security/app-secrets?view=aspnetcore-9.0&tabs=windows#how-the-secret-manager-tool-works)
45+
// Bind ASP.NET user secrets folder (please see https://learn.microsoft.com/en-us/aspnet/core/security/app-secrets#how-the-secret-manager-tool-works)
4446
"source=${localEnv:APPDATA}/Microsoft/UserSecrets,target=/home/vscode/.microsoft/usersecrets,type=bind"
4547
],
4648
// Remove absolutely every file on the .gitignore list, so we don't run into permission issues.
4749
// Also see https://github.com/microsoft/vscode-remote-release/issues/9099#issuecomment-2541564211
48-
"postStartCommand": "git clean -xdf && dotnet dev-certs https --trust"
50+
"postStartCommand": "git clean -xdf && dotnet dev-certs https --clean --import ${containerWorkspaceFolder}/.certs/AspNetDev.pfx -p ''"
4951
}

.spectral/main.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,6 @@ extends:
22
- ruleset.bank.yml #Bank API project ruleset
33
- https://unpkg.com/@stoplight/spectral-owasp-ruleset/dist/ruleset.mjs #OWASP API Security Top 10 - v2023
44
- https://static.developer.overheid.nl/adr/ruleset.yaml #Dutch Public Sector (NLGov) REST API Design Rules, includes Spectral "oas" ruleset
5+
6+
rules:
7+
openapi3: "off" # NLGov rule to check for openapi version is too strict in the current version, already changed in a newer version of the ruleset, but not yet released

.spectral/ruleset.bank.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ rules:
2525
- Administrative
2626

2727
bank:header-requires-hyphenated-pascal-case:
28-
description: HTTP headers must be in Hyphenated-Pascal-Case, exceptions are API-Version and WWW-Authenticate.
29-
message: HTTP header is not in Hyphenated-Pascal-Case, exceptions are API-Version and WWW-Authenticate.
28+
description: HTTP headers must be in Hyphenated-Pascal-Case, exceptions are API-Version, WWW-Authenticate and X-JWS-Signature.
29+
message: HTTP header is not in Hyphenated-Pascal-Case, exceptions are API-Version, WWW-Authenticate and X-JWS-Signature.
3030
severity: warn
3131
given:
3232
- "$..responses..headers"
@@ -36,7 +36,7 @@ rules:
3636
field: "@key"
3737
function: pattern
3838
functionOptions:
39-
match: "^(API-Version|WWW-Authenticate|([A-Z][a-z0-9]*)(-[A-Z][a-z0-9]*)*)$"
39+
match: "^(API-Version|WWW-Authenticate|X-JWS-Signature|([A-Z][a-z0-9]*)(-[A-Z][a-z0-9]*)*)$"
4040

4141
bank:property-requires-camel-case:
4242
description: Property names, acronyms, path parameters and query parameters must be in camelCase.

BankApi.Core/BankApi.Core.csproj

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

33
<PropertyGroup>
4-
<TargetFramework>net9.0</TargetFramework>
4+
<TargetFramework>net10.0</TargetFramework>
55
<Nullable>enable</Nullable>
66
<ImplicitUsings>enable</ImplicitUsings>
77
<OutputType>Library</OutputType>
88
</PropertyGroup>
99

1010
<ItemGroup>
1111
<PackageReference Include="Aspire.Azure.Storage.Blobs" Version="9.*" />
12-
<PackageReference Include="AspNetCore.Authentication.ApiKey" Version="8.*" />
12+
<PackageReference Include="AspNetCore.Authentication.ApiKey" Version="9.*" />
1313
<PackageReference Include="Gridify" Version="2.*" />
1414
<PackageReference Include="Gridify.EntityFramework" Version="2.*" />
15-
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="9.*" />
16-
<PackageReference Include="Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore" Version="9.*" />
17-
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="9.*" />
18-
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="9.*" />
15+
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="10.*-*" />
16+
<PackageReference Include="Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore" Version="10.*-*" />
17+
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="10.*-*" />
18+
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="10.*-*" />
1919
<PackageReference Include="Microsoft.Extensions.Caching.Hybrid" Version="9.*" />
2020
<PackageReference Include="Microsoft.Extensions.Compliance.Redaction" Version="9.*" />
2121
<PackageReference Include="Microsoft.Extensions.Http.Resilience" Version="9.*" />
2222
<PackageReference Include="Microsoft.Extensions.ServiceDiscovery" Version="9.*" />
2323
<PackageReference Include="Microsoft.Kiota.Bundle" Version="1.*" />
24-
<PackageReference Include="OpenTelemetry.Exporter.OpenTelemetryProtocol" Version="1.11.*" />
25-
<PackageReference Include="OpenTelemetry.Extensions.Hosting" Version="1.11.*" />
26-
<PackageReference Include="OpenTelemetry.Instrumentation.EntityFrameworkCore" Version="1.*-*" />
27-
<PackageReference Include="OpenTelemetry.Instrumentation.AspNetCore" Version="1.11.*" />
28-
<PackageReference Include="OpenTelemetry.Instrumentation.Http" Version="1.11.*" />
24+
<PackageReference Include="Microsoft.OpenApi" Version="2.*" />
25+
<PackageReference Include="OpenTelemetry.Exporter.OpenTelemetryProtocol" Version="1.13.*" />
26+
<PackageReference Include="OpenTelemetry.Extensions.Hosting" Version="1.13.*" />
27+
<PackageReference Include="OpenTelemetry.Instrumentation.EntityFrameworkCore" Version="1.12.*-*" />
28+
<PackageReference Include="OpenTelemetry.Instrumentation.AspNetCore" Version="1.12.*" />
29+
<PackageReference Include="OpenTelemetry.Instrumentation.Http" Version="1.12.*" />
2930
<PackageReference Include="Scalar.AspNetCore" Version="2.*" />
3031
<PackageReference Include="jose-jwt" Version="5.*" />
3132
</ItemGroup>

BankApi.Core/Defaults/Attribute.Identity.cs

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,4 @@
11
using System.ComponentModel;
2-
using System.ComponentModel.DataAnnotations;
3-
4-
/// <summary>
5-
/// Attribute used to enforce a maximum length of 36 for GUIDs.
6-
/// Inherits from MaxLengthAttribute to set the maximum length for GUIDs to 36 characters.
7-
/// </summary>
8-
public class IdAttribute : MaxLengthAttribute
9-
{
10-
public IdAttribute() : base(36) { }
11-
}
122

133
/// <summary>
144
/// Attribute used to describe the ID of a bank.

BankApi.Core/Defaults/Builder.AzureClients.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
1+
using Azure.Identity;
12
using Azure.Storage.Blobs;
23

34
public static partial class ApiBuilder
45
{
56
public static IHostApplicationBuilder AddAzureClients(this IHostApplicationBuilder builder)
67
{
7-
builder.AddAzureBlobClient("BankStorage", options =>
8+
var credential = new DefaultAzureCredential();
9+
10+
builder.AddAzureBlobServiceClient("BankStorage", options =>
811
{
9-
options.DisableHealthChecks = false;
12+
options.Credential = credential;
1013
});
1114

1215
return builder;
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
using System.Text.Json.Serialization;
2+
3+
public static partial class ApiBuilder
4+
{
5+
public static IServiceCollection ConfigureJson(this IServiceCollection services)
6+
{
7+
services.Configure<Microsoft.AspNetCore.Http.Json.JsonOptions>(options =>
8+
{
9+
options.SerializerOptions.UnmappedMemberHandling = JsonUnmappedMemberHandling.Disallow;
10+
options.SerializerOptions.NumberHandling = JsonNumberHandling.Strict;
11+
});
12+
return services;
13+
}
14+
}

BankApi.Core/Defaults/Builder.OpenApi.cs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,19 @@
1+
using AspNetCore.Authentication.ApiKey;
12
using Scalar.AspNetCore;
23

34
public static partial class ApiBuilder
45
{
56
public static IServiceCollection AddOpenApiServices(this IServiceCollection services)
67
{
7-
services.AddOpenApi(GlobalConfiguration.ApiDocument!.Info.Version, options =>
8+
services.AddOpenApi(GlobalConfiguration.ApiDocument!.Info.Version!, options =>
89
{
910
options.AddDocumentTransformer<TransformerDocInfo>();
1011
options.AddDocumentTransformer<TransformerComponentSchemas>();
1112
options.AddDocumentTransformer<TransformerComponentHeaders>();
1213
options.AddDocumentTransformer<TransformerComponentResponses>();
1314
options.AddDocumentTransformer<TransformerSecurityScheme>();
1415
options.AddSchemaTransformer<TransformerExampleSchema>();
16+
options.AddSchemaTransformer<TransformerGuidSchema>();
1517
options.AddOperationTransformer<TransformerOperation>();
1618
});
1719

@@ -23,9 +25,10 @@ public static void AddOpenApiScalarReference(this IEndpointRouteBuilder app)
2325
app.MapScalarApiReference(options =>
2426
{
2527
options.Theme = ScalarTheme.DeepSpace;
26-
options.WithApiKeyAuthentication(options =>
28+
options.ForceDarkMode();
29+
options.AddApiKeyAuthentication($"{ApiKeyDefaults.AuthenticationScheme}-Header", options =>
2730
{
28-
options.Token = "Lifetime Subscription";
31+
options.Value = "Lifetime Subscription";
2932
});
3033
options.Title = $"{GlobalConfiguration.ApiDocument!.Info.Title} docs | {GlobalConfiguration.ApiDocument.Info.Version}";
3134
});

BankApi.Core/Defaults/GlobalConfiguration.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
using Microsoft.Extensions.Caching.Hybrid;
22
using Microsoft.IdentityModel.Tokens;
3-
using Microsoft.OpenApi.Any;
4-
using Microsoft.OpenApi.Models;
3+
using Microsoft.OpenApi;
4+
using System.Text.Json.Nodes;
55
using System.Threading.RateLimiting;
66

77
public static class GlobalConfiguration
88
{
99
public static OpenApiDocument? ApiDocument { get; set; }
1010

11-
public static IOpenApiAny? ApiExamples { get; set; }
11+
public static JsonObject? ApiExamples { get; set; }
1212

1313
public static SettingsModel? ApiSettings { get; set; }
1414

0 commit comments

Comments
 (0)