Consider this program:
using System;
#nullable enable
namespace NullnessExample
{
class Program
{
public void M(string? theString)
{
// In the project file, this warning code is suppressed, but the nowarn is ignored.
Console.WriteLine($"Length is {theString.Length}");
}
static void Main(string[] args)
{
// Explicitly trigger a warning here, note that is gets suppressed
while (false) { Console.Write(""); }
Console.WriteLine("Hello World!");
}
}
}
And a corresponding project file:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.2</TargetFramework>
<LangVersion>8.0</LangVersion>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<NoWarn>1701;1702; 8602; 0162</NoWarn>
</PropertyGroup>
</Project>
Expected
No nullability warning.
Actual
The CS8602 warning is still emitted.
The CS0162 warning, by comparison, is correctly suppressed.
Consider this program:
And a corresponding project file:
Expected
No nullability warning.
Actual
The
CS8602warning is still emitted.The
CS0162warning, by comparison, is correctly suppressed.