Skip to content

Conversation

christiannagel
Copy link
Contributor

PR Classification

Code cleanup and modernization to align with .NET best practices.

PR Summary

This PR replaces outdated .sln files with .slnx files, introduces source-generated JSON serialization, and updates project compatibility and dependencies.

  • Replaced .sln files with .slnx files for a cleaner, XML-based solution format.
  • GamesClient.cs: Refactored to use GamesClientJsonContext for source-generated JSON serialization, removing s_jsonOptions.
  • Codebreaker.GameAPIs.Client.csproj: Added <IsAotCompatible> property and updated Microsoft.Extensions.Logging.Abstractions to version 9.0.9.
  • CreateGameRequest.cs: Removed conditional compilation for JsonStringEnumConverter.

Replaced traditional .sln files with simplified .slnx files for all solutions, including:
- Codebreaker.Analyzers
- Codebreaker.Backend.Cosmos
- Codebreaker.Backend.Models
- Codebreaker.Backend.Postgres
- Codebreaker.Backend.SqlServer
- Codebreaker.GameAPIs.Client

The .slnx format provides a cleaner, XML-based structure with `<Solution>` and `<Project>` elements, omitting detailed configuration and platform settings. This change improves simplicity, maintainability, and compatibility with modern tooling.
Added `<IsAotCompatible>true</IsAotCompatible>` to the project file for AOT compatibility. Updated `Microsoft.Extensions.Logging.Abstractions` to version `9.0.9` for `net9.0`. Replaced static `JsonSerializerOptions` with a source-generated `GamesClientJsonContext` for JSON serialization in `GamesClient.cs`.

Refactored all HTTP client methods to use `GamesClientJsonContext` for improved performance and maintainability. Introduced a new partial class `GamesClientJsonContext` with `[JsonSourceGenerationOptions]` and `[JsonSerializable]` attributes to define serializable types.

These changes enhance performance, reduce runtime overhead, and improve compatibility with AOT scenarios.
Simplified `GameType` enum in `CreateGameRequest.cs` by removing conditional compilation and redundant `JsonConverter` attributes. Compatibility with .NET 7 is no longer required.
@christiannagel christiannagel linked an issue Sep 17, 2025 that may be closed by this pull request
@christiannagel christiannagel merged commit e52d278 into main Sep 17, 2025
3 checks passed
@christiannagel christiannagel deleted the 325-gameapisclient-aot-compatible branch September 17, 2025 17:09
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.

Make Codebreaker.GameAPIs.Client AOT compatible
1 participant