Code inspection: '??' condition is never null according to nullable reference types' annotations
This inspection reports a ?? or ??= expression when nullable annotations or API contracts already say the left side should never be null. In that case, the fallback value is unreachable and usually indicates redundant code or a mismatched nullability annotation.
Example
#nullable enable
using System.Diagnostics.CodeAnalysis;
class C
{
[DisallowNull]
private string? _name = "";
string GetName()
{
return _name ?? "Unknown";
}
}
#nullable enable
using System.Diagnostics.CodeAnalysis;
class C
{
[DisallowNull]
private string? _name = "";
string GetName()
{
return _name;
}
}
Quick-fix
Depending on the situation, the quick-fix can also make the member or parameter nullable instead of removing the unreachable fallback.
13 April 2026