manuelroemer / Nullable

A source code only package which allows you to use .NET's nullable attributes in older target frameworks like .NET Standard 2.0 or the "old" .NET Framework.
https://www.nuget.org/packages/Nullable
MIT License
184 stars 8 forks source link

Use props to hide files instead of .pp extension #26

Closed gtbuchanan closed 2 years ago

gtbuchanan commented 2 years ago

The workaround of using the .pp extension no longer works in MSBuild 17.2.1 when using TargetFrameworks. Builds fail with an error like this:

error CS0122: 'NotNullIfNotNullAttribute' is inaccessible due to its protection level

or this (depending on the situation):

error CS0246: The type or namespace name 'NotNullWhen' could not be found

Using the Visible MSBuild property makes the intent more clear anyway. The approach is adapted from here.

Related to https://github.com/manuelroemer/IsExternalInit/pull/14

manuelroemer commented 2 years ago

That looks absolutely fantastic, many many thanks @gtbuchanan! I will do some local tests and then look into publishing a new version of the package if nothing else seems to break.