Skip to content

Enable nullable reference types and refactor code#217

Merged
rido-min merged 1 commit intomainfrom
rido/fix/nullable
Jul 21, 2025
Merged

Enable nullable reference types and refactor code#217
rido-min merged 1 commit intomainfrom
rido/fix/nullable

Conversation

@rido-min
Copy link
Copy Markdown
Member

Our samples should be warning free. The AspNetExtensions.cs file will be copied to other projects, and VS uses nullable by default.

This PR fixes the nullable related warnings from the extension, and other places.

This commit introduces nullable reference types across various files, enhancing code safety by explicitly indicating which properties can be null. Key changes include:

  • Updated AspNetExtensions.cs to use the null-forgiving operator ! for method calls and property accesses.
  • Changed a private field in AuthAgent.cs from mutable to readonly to prevent modification after initialization.
  • Modified WeatherForecastAgent and WeatherForecastAgentResponse classes to use nullable types for properties.
  • Updated project files (.csproj) to enable nullable reference types.
  • Cleaned up Program.cs files by removing unnecessary using directives and ensuring configuration values are treated as non-nullable.
  • Minor refactoring for improved readability and maintainability, including the use of target-typed new() expressions.

These changes collectively aim to improve code quality and maintainability.

This commit introduces nullable reference types across various files, enhancing code safety by explicitly indicating which properties can be null. Key changes include:

- Updated `AspNetExtensions.cs` to use the null-forgiving operator `!` for method calls and property accesses.
- Changed a private field in `AuthAgent.cs` from mutable to readonly to prevent modification after initialization.
- Modified `WeatherForecastAgent` and `WeatherForecastAgentResponse` classes to use nullable types for properties.
- Updated project files (`.csproj`) to enable nullable reference types.
- Cleaned up `Program.cs` files by removing unnecessary using directives and ensuring configuration values are treated as non-nullable.
- Minor refactoring for improved readability and maintainability, including the use of target-typed `new()` expressions.

These changes collectively aim to improve code quality and maintainability.
@github-actions github-actions bot added the Samples Changes to Samples label Jul 18, 2025
@rido-min rido-min merged commit c4c9130 into main Jul 21, 2025
3 checks passed
@rido-min rido-min deleted the rido/fix/nullable branch July 21, 2025 14:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Samples Changes to Samples

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants