Conversation
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.




PR summary: .NET 8 → .NET 10
This PR upgrades the contracts-api solution from .NET 8 to .NET 10. Package versions and application behaviour are unchanged except where the .NET 10 SDK otherwise fails restore or build, plus the hosting bootstrap needed to drop obsolete
WebHostAPIs without rewritingStartupor the Lambda entry point.Final setup
Target framework, CI, Docker, Lambda packaging
ContractsApiandContractsApi.Tests:net8.0→net10.0mcr.microsoft.com/dotnet/sdk:8.0→sdk:10.0docker-dotnetexecutor:sdk:10.0serverless.yml:runtime: dotnet10; artifact./bin/release/net10.0/contracts-api.zipbuild.sh/build.cmd:--framework net10.0and zip undernet10.0No
global.json. The SDK 10 Docker/CI images pin the toolchain.Restore compatibility
Both projects already use
TreatWarningsAsErrors. The .NET 10 SDK audits transitive packages by default; restore then surfaced NU1902/NU1903 on existing transitives (for exampleMicrosoft.Data.SqlClient,Newtonsoft.Json9.0.1,Npgsql4.1.3). Those packages were not upgraded.NuGetAuditModeisdirectso restore still audits direct references only.Local / Docker hosting (
ASPDEPR008)WebHost/IWebHost/IWebHostBuilder.Build()are obsolete in ASP.NET Core 10.Program.csno longer usesWebHost.CreateDefaultBuilder. Local and Dockerdotnet ContractsApi.dlluse the documented replacement that still supportsStartup:CreateWebHostBuilderwas renamed toCreateHostBuilder(IHostBuilder) soWebApplicationFactory<Startup>builds anIHostinstead of calling obsoleteIWebHostBuilder.Build().Startupis unchanged.ASPDEPR008is not inNoWarn(the API project still suppresses XML-doc1591only).WebApplication.CreateBuilderwas not used: that model cannot keepUseStartupand would require a Lambda hosting package upgrade.AWS Lambda (unchanged path)
Lambda does not use
Program.Main. The deployed handler is still:ContractsApi::ContractsApi.LambdaEntryPoint::FunctionHandlerAsyncLambdaEntryPointstill inheritsAPIGatewayProxyFunction(Amazon.Lambda.AspNetCoreServer5.1.1) and still callsInit(IWebHostBuilder)withUseStartup<Startup>(). The Lambda library creates its own host and registers the Lambda server instead of Kestrel.Tests
MockWebApplicationFactorynow follows the generic-host path. That exposed two issues the oldWebHostpath hid; both are fixed in the factory only:Startupregisters X-Ray for all AWS services before the fixture'sConfigureServicesruns. Fixture DynamoDB calls happen during host build with no active segment, andappsettings.jsonsetsXRay:UseRuntimeErrors. The factory now setsAWS_XRAY_CONTEXT_MISSING=LOG_ERRORviaEnsureEnvVarConfigured.Host.CreateDefaultBuilderenablesValidateOnBuildin Development;WebHost.CreateDefaultBuilderdid not. TheHackney.Core.Testingfixtures fail that check (singletonIDynamoDbFixtureconsuming scopedIDynamoDBContext;ISnsEventVerifierneeding unregisteredIAmazonSQS). Neither is resolved through this provider. The factory setsValidateOnBuild = falseviaUseDefaultServiceProvider. Scope validation stays on.DynamoDbMockWebApplicationFactoryhas the same shape but is unused; it was left alone.Files that differ from master for this upgrade
serverless.yml/build.sh/build.cmd/ CircleCIContractsApi/Program.cs— generic hostContractsApi/ContractsApi.csproj—net10.0,NuGetAuditMode, noASPDEPR008ContractsApi.Tests/ContractsApi.Tests.csproj—net10.0,NuGetAuditMode, noASPDEPR008ContractsApi.Tests/MockWebApplicationFactory.cs— X-Ray env var andValidateOnBuild = falseLambdaEntryPoint.cs,Startup.cs, and allPackageReferenceversions are unchanged.Amazon.Lambda.Toolsremains4.0.0inbuild.sh.Validation
ASPDEPR008.TZ=UTC, DynamoDB Local on:8000, LocalStack on:4566.dotnet runstarts Kestrel, serves Swagger UI, and returns the same healthcheck and contracts responses as the pre-hosting-change build.dotnet lambda package --framework net10.0succeeded.Known limitations (pre-existing, not fixed)
GET /api/v1/healthcheck/pingreturns 500 (Type Contract does not have the DynamoDBTable attribute applied to it) and/swagger/v1/swagger.jsonreturns 404. Swagger UI and the contracts endpoints respond. Identical before and after this PR.DynamoDbGatewayTests.PatchContractSuccessfullyUpdatesAContractcan fail underTZ=Europe/London(DynamoDbDateTimeConverterplus AutoFixtureDateTime). It passes underTZ=UTC.Intentionally not in this PR
Microsoft.CodeAnalysis.NetAnalyzers6.0.0, EF 3.1.3, Swashbuckle, xunit, Hackney.Core.*, AWS SDK,Amazon.Lambda.AspNetCoreServer5.1.1, and so on).WebApplication.CreateBuilder/ inliningStartup.How to verify
dotnet restore ContractsApi.sln dotnet build ContractsApi.sln TZ=UTC dotnet test ContractsApi.slnTests need DynamoDB Local (
:8000) and LocalStack (:4566), as indocker-compose/ CircleCIbuild-and-test. Deploy packaging usesbuild.sh/serverless.ymlwithdotnet10andnet10.0.