Nullable Reference Types: CS8618 and/or CS8625 should be consistently reported for static fields/properties. #27014
Labels
Area-Compilers
Bug
Feature - Nullable Reference Types
Nullable Reference Types
Resolution-Duplicate
The described behavior is tracked in another issue
Milestone
Version Used: 05/14/18 Nullable Reference Types Preview (
csc
reports2.8.0.62830 (e595ee27)
) with Visual Studio 15.7.1Demonstration Code:
(For your convenience, here's all of the examples in this issue in one project: PathogenPlayground/InconsistentWarningsOnStaticFieldsAndProperties)
Expected Behavior:
A CS8618 warning is reported for all four fields/properties.
Actual Behavior:
CS8618 is only reported for the instance field/property:
Variations
While reporting this issue, I ended up finding out that adding null initializers and a static constructor changed the behavior as observed in the examples below:
Adding a static constructor does not change anything:
Adding null initializers does not change anything:
Adding both null initializers and a static constructor does change things:
The text was updated successfully, but these errors were encountered: