Skip to content

C# nullable reference types and TreatWarningsAsErrors across the solution #191

@indcoder

Description

@indcoder

Enable C# nullable reference types and treat warnings as errors across the solution to improve null-safety and catch issues earlier in development.

Why

  • Nullable enables C#'s null-reference static analysis:
    • Warns about potential null reference issues
    • Forces explicit handling of nullable types
    • Makes null safety visible in your code
  • TreatWarningsAsErrors turns warnings into build failures:
    • Code won't compile until null issues (and other warnings) are fixed
    • Catches problems during development rather than production

Proposal
Add these settings to a Directory.Build.props file placed next to the solution (.sln) so they apply to all projects:

Suggested Directory.Build.props


enable
true

Suggested rollout checklist

  • Add Directory.Build.props (near solution file) with above settings
  • Run solution build to collect warnings
  • Fix null-related and other warnings or suppress justified ones
  • Create PR with changes and request reviews
  • Optionally: add a CI job to ensure builds fail on warnings

Metadata

Metadata

Assignees

Labels

buildAffects Builds or External dependencieschoreOther changes that do not modify src or test filesciChanges to CI scriptsdocsDocumentation only changes

Type

Projects

Status

No status

Relationships

None yet

Development

No branches or pull requests

Issue actions