Is there a compiler directive for C# 8 or detecting if <nullable>enable</nullable> is set?
I have a source code only Nuget package that could stand to help with the nullable reference types story. I'd like to conditionally set the #nullable enable directive if this is set, such as:
#ifdef ICANHASNULLABLE
#nullable enable
#endif
and
#ifdef ICANHASNULLABLE
string Foo(string? val)
#else
string Foo(string val)
#endif
I have a mix of stuff built with the .NET Core 2.1 SDK and am working to bring things to .NET Core 3.1, albeit slowly and not just by flipping a switch. The directive only points to the framework versions, not language version.