dotnet / android

.NET for Android provides open-source bindings of the Android SDK for use with .NET managed languages such as C#
MIT License
1.94k stars 533 forks source link

[Xamarin.Android.Build.Tasks] fix NRT warnings & other warnings #9483

Closed jonathanpeppers closed 6 days ago

jonathanpeppers commented 3 weeks ago

Introduces the setting to Xamarin.Android.Build.Tasks.csproj:

<WarningsAsErrors>Nullable</WarningsAsErrors>

Then I fixed the existing warnings. Down the road this will make it easier to adopt #enable nullable, and eventually Nullable=enable the entire project. Trying to do that now results in 1,000+ warnings...

Most of these are types that could easily be null, and they weren't marked as nullable with ?. Luckily, the code appears to be checking for null in these places already.

jpobst commented 6 days ago

As a further future step, we should also multitarget to net9.0 (even if only locally) and fix those warnings, as the netstandard2.0 BCL isn't fully annotated with nullable annotations.

dellis1972 commented 6 days ago

As a further future step, we should also multitarget to net9.0 (even if only locally) and fix those warnings, as the netstandard2.0 BCL isn't fully annotated with nullable annotations.

maybe upgrading to netstandard2.1 might be better?

jonathanpeppers commented 6 days ago

The two test failures we can ignore:

image

image