Context
C# 8.0 has this features of non-nullable reference types.
string notNull = "Hello";
string? nullable = default;
notNull = nullable!; // null forgiveness
Question
What reasons are there to not always enable non-nullability in the *.csproj file?
Do you have a checklist? Like, "Don't <Nullable>enable</Nullable>
if ... a)... b)... c)..."?
What I can think of
The only reason I can think of is backwards compatibility with existing code. Meaning: turning on the feature and fixing all compiler errors and adjusting code might be just too time-consuming and therefore expensive; perhaps also error-prone.
I've googled but haven't found any other reasons: when not to use non-nullable refernce types in c# - Google Search
Documentation
- Microsoft Docs → Nullable reference types
- This blog article gives a lot of illustrative code examples: Containing Null with C# 8 Nullable References, Frank A. Krueger
P.S.
Please let me know if Stack Overflow is the wrong place to ask this question and which other Stack Exchange site would be better suited.
I thought Stack Exchange could be the right placed because of What topics can I ask about here?
- "a practical, answerable problem that is unique to software development"