Nullable Reference Types

All projects MUST enable <Nullable>enable</Nullable>. Treat warnings as design signals — string means non-null, string? means nullable.

  • The null-forgiving operator (!) SHOULD NOT be used — prefer ?? throw or guard clauses
  • Use required properties and constructor parameters for non-null initialization
  • Use [NotNull], [MaybeNull], [NotNullWhen] from System.Diagnostics.CodeAnalysis for contracts the compiler cannot infer
// Good: required + guard clause
public required string Name { get; init; }

public void Process(string? input)
{
    ArgumentNullException.ThrowIfNull(input);
    // input is now non-null
}
version
1.0.0
tags
csharp, language, nullable-reference-types
author
Mike Fullerton
modified
2026-03-27

Change History

Version Date Author Summary
1.0.0 2026-03-27 Mike Fullerton Initial creation