Version Used: 05/14/18 Nullable Reference Types Preview (csc reports 2.8.0.62830 (e595ee27)) with Visual Studio 15.7.1
Demonstration Code:
public class TestClass
{
private string x;
public TestClass()
{
Console.WriteLine(x.ToString()); // No warning, CS8602 is expected
x = "Hello, world!";
}
}
Expected Behavior:
A warning is reported when x is dereferenced.
Actual Behavior:
There is no compile-time warning and a runtime exception occurs when the code is executed.
Additional info:
The current behavior is the same with a property.