According to the C# 8 announcement video the "nullable reference types" feature can be enabled for the whole project.
But how to enable it for the project? I did not find any new appropriate option in the Project Properties window in Visual Studio 2019 Preview 1.
Can it be enabled for 'legacy' .csproj
projects if the C# language version is changed to 8.0?
In Visual Studio 16.2 (from preview 1), the property name is changed to Nullable
, which is simpler and aligns with the command line argument.
<PropertyGroup>
...
<Nullable>enable</Nullable>
<LangVersion>8.0</LangVersion>
</PropertyGroup>
Note that if you're targeting netcoreapp3.0
or later, you don't need to specify a LangVersion
of 8, as that is the default in .NET Core 3.
For older Visual Studio versions:
NullableContextOptions
to enable
.NullableReferenceTypes
to true
.