dotnet/roslyn-sdk

Nullability annotations are wrong

tom-englert opened this issue · 2 comments

Both TestCode and FixedCode properties accept null, but are marked as not-null

public string TestCode
{
set
{
if (value != null)
{
TestState.Sources.Add(value);
}
}
}

Why would a user need to assign null here? Seems like we would instead keep the current annotations, and over time if/when a user is assigning null and enables nullable reference types, they would be discouraged from that practice.

Just to be able to continue using this when nullable is enabled:

public class AnalyzerTest<TAnalyzer> : CSharpAnalyzerTest<TAnalyzer, Verifier>
    where TAnalyzer : DiagnosticAnalyzer, new()
{
    public AnalyzerTest(string? source = null)
    {
        TestCode = source;
        ReferenceAssemblies = ReferenceAssemblies.Net.Net60;
    }
}