Skip to content

feat(csharp): upgrade from .NET 8 to .NET 10#428

Open
davideme wants to merge 6 commits intomainfrom
claude/eloquent-feynman
Open

feat(csharp): upgrade from .NET 8 to .NET 10#428
davideme wants to merge 6 commits intomainfrom
claude/eloquent-feynman

Conversation

@davideme
Copy link
Owner

Summary

  • Upgrade TargetFramework from net8.0 to net10.0
  • Upgrade all Microsoft.* packages to 10.0.x versions
  • Remove explicit System.Text.Json package reference (now built into .NET 10)
  • Update global.json SDK to 10.0.103
  • Update CI workflow to use dotnet-version: 10.x
  • Regenerate packages.lock.json for .NET 10
  • Fix ASP0027: remove redundant public partial class Program {}
  • Fix CA1873: migrate ILogger calls to [LoggerMessage] source generation in PostgresLampRepository
  • Fix pre-commit hook: use dotnet format whitespace instead of dotnet format to avoid MSBuild file lock contention (MSB4018) during commits

Test plan

  • dotnet build --configuration Release passes
  • dotnet test passes
  • dotnet format whitespace --verify-no-changes passes
  • CI workflow completes successfully with .NET 10

🤖 Generated with Claude Code

davideme and others added 3 commits February 26, 2026 14:05
Delete the local Claude settings file that contained a large list of allowed Bash commands. This file is environment-specific and potentially exposes permissions; removing it cleans up the repository and prevents committing local config. Consider adding this path to .gitignore if it should remain local.
- Update TargetFramework to net10.0 in both project files
- Upgrade all .NET-versioned packages to 10.0.x
- Remove redundant System.Text.Json (built into .NET 10)
- Update global.json SDK to 10.0.103
- Update CI workflow dotnet-version from 8.x to 10.x
- Regenerate packages.lock.json for .NET 10

Fix analyzer warnings introduced by .NET 10 analyzers:
- Remove public partial class Program (ASP0027: no longer needed)
- Migrate ILogger calls to [LoggerMessage] source generation (CA1873)
- Suppress CA1873 false positive in Moq.Verify lambda in tests
- Fix SA1204: move static LoggerMessage methods before instance methods

Fix pre-commit hook for .NET 10 compatibility:
- Replace dotnet format (full) with dotnet format whitespace to avoid
  MSB4018 file lock errors caused by the internal build that dotnet format
  triggers conflicting with the subsequent Release build
- The Release build still validates all analyzer rules as warnings

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Update TargetFramework from net8.0 to net10.0
- Upgrade all Microsoft.* packages to 10.0.x versions
- Remove explicit System.Text.Json dependency (built into .NET 10)
- Update global.json SDK to 10.0.103
- Update CI workflow to use dotnet-version: 10.x
- Regenerate packages.lock.json for .NET 10
- Remove public partial class Program {} (fixes ASP0027)
- Migrate ILogger calls to [LoggerMessage] source generation (fixes CA1873)
- Suppress CA1873 false positive in test mock verification
- Regenerate packages.lock.json with updated dependencies

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings February 28, 2026 09:50
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR upgrades the C# LampControlApi solution to .NET 10, updating core framework targets, package references/lock files, and CI/pre-commit tooling to align with the new runtime and analyzers.

Changes:

  • Retarget projects from net8.0 to net10.0 and refresh NuGet dependencies/lock file accordingly.
  • Update logging in PostgresLampRepository to use [LoggerMessage] source generation (CA1873-related).
  • Adjust CI matrix to .NET 10.x and tweak pre-commit formatting to use dotnet format whitespace.

Reviewed changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/csharp/LampControlApi/packages.lock.json Regenerated lock file for net10.0 dependency graph.
src/csharp/LampControlApi/global.json Pins SDK version to 10.0.103 (but see comment about discovery from CI/scripts).
src/csharp/LampControlApi/Services/PostgresLampRepository.cs Migrates debug logs to [LoggerMessage] source-generated logging methods.
src/csharp/LampControlApi/Program.cs Removes explicit public partial class Program block.
src/csharp/LampControlApi/LampControlApi.csproj Retargets to net10.0, updates package versions, removes explicit System.Text.Json.
src/csharp/LampControlApi.Tests/LampControllerImplementationTests.cs Modernizes MSTest Assert.IsInstanceOfType usage.
src/csharp/LampControlApi.Tests/LampControlApi.Tests.csproj Retargets to net10.0 and updates test-time ASP.NET/EF packages.
src/csharp/LampControlApi.Tests/Infrastructure/PostgresLampRepositoryUnitTests.cs Adds CA1873 suppression around Moq logger verification.
src/csharp/LampControlApi.Tests/Infrastructure/LampControlDbContextTests.cs Modernizes MSTest Assert.IsInstanceOfType usage.
scripts/hooks/csharp.sh Switches pre-commit formatting to dotnet format whitespace.
.github/workflows/csharp-ci.yml Updates CI to run on .NET 10.x.
.claude/settings.local.json Removes local Claude settings file from repo.

davideme and others added 3 commits February 28, 2026 11:20
- Move global.json from LampControlApi/ to src/csharp/ so the SDK pin
  is discovered by dotnet CLI when running from src/csharp/ (CI/scripts)
- Enable RestorePackagesWithLockFile in test project and commit generated
  packages.lock.json, fixing missing cache-dependency-path in CI
- Fix indentation of Npgsql.EntityFrameworkCore.PostgreSQL PackageReference

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Upgrade Swashbuckle.AspNetCore 6.6.2 → 10.1.4: the old version's
  SwaggerGenerator did not implement the updated ISwaggerProvider.GetSwagger
  interface added in .NET 10, causing TypeLoadException in all tests
  that spin up the WebApplication host
- Fix Operations_ShouldLogDebugMessages: [LoggerMessage] source-generated
  methods call ILogger.IsEnabled() before Log(); since Moq returns false
  by default the log calls were short-circuited. Added
  mockLogger.Setup(l => l.IsEnabled(LogLevel.Debug)).Returns(true) in
  TestInitialize so Log() is actually invoked
- Regenerate packages.lock.json for both projects

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…class

Swashbuckle 10.x derives the swagger operation tag by stripping the
"Controller" suffix from the class name. The NSwag-generated class is
literally named "Controller", so stripping the suffix yields an empty
string and throws ArgumentNullException (referenceId) when generating
the swagger document.

Override TagActionsBy in AddSwaggerGen to fall back to "Lamps" when the
route controller value is empty, so /swagger/v1/swagger.json returns 200.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants