dotnet / arcade

Tools that provide common build infrastructure for multiple .NET Foundation projects.
MIT License
673 stars 347 forks source link

Cannot opt into C# 8 nullable references in csproj #1899

Closed roji closed 5 years ago

roji commented 5 years ago

I'm a bit of a newcomer so I hope I'm posting in the right place with the right details.

While working on introducing C# 8 nullable reference annotations into the Entity Framework Core codebase, it would seem that the <NullableReferenceTypes> attribute isn't getting properly picked up from the project's csproj, but only when building with Visual Studio 2019 Preview2. When trying to build, I'm getting warnings of the following type for each null-annotated type:

error CS8632: The annotation for nullable reference types should only be used in code within a '#nullable' context.

Building the same project from the cmdline succeeds. Building a regular, non-Arcade project from VS also succeeds. Placing #nullable enable in the source file also works, so the problem really seems to be with the csproj property.

VS version: 2019 Preview 2 dotnet SDK: 3.0.100-preview-010010

benaadams commented 5 years ago

The reddits say its changed to <NullableContextOptions>enable</NullableContextOptions>

roji commented 5 years ago

Thanks @benaadams, that works :) I'm guessing that my EF Core build was on a newer SDK because of arcade, while the standalone project was on an older version with the previous property.