CommunityToolkit / WindowsCommunityToolkit

The Windows Community Toolkit is a collection of helpers, extensions, and custom controls. It simplifies and demonstrates common developer tasks building .NET apps with UWP and the Windows App SDK / WinUI 3 for Windows 10 and Windows 11. The toolkit is part of the .NET Foundation.
https://docs.microsoft.com/windows/communitytoolkit/
Other
5.89k stars 1.38k forks source link

Enable nullable annotations for the whole Toolkit #3958

Open Sergio0694 opened 3 years ago

Sergio0694 commented 3 years ago

Overview

C# introduced nullable reference types in C# 8.0, but due to some limitations in frameworks such as UWP we haven't enabled them in the entire Toolkit just yet. That said, as I've documented here, it's still possible to use them, and we should gradually extend support for them in the whole Toolkit, especially in preparation for the WinUI 3 support that's already work in progress, since that targets .NET 5. Right now I have already enabled annotations in the .NET packages, and in some other specific files of the UWP projects, but they're not complete there. I propose the following roadmap:

NOTE: this will take some time to actually complete and I wouldn't expect this to be done by the next minor release, so this issue is meant to just be used to track progress as we gradually add more and more annotations to the Toolkit 😄

Tracking nullability

Here's a list of all projects and their status with respect to nullability annotations:

.NET

UWP

UWP.UI

Unit

Rosuavio commented 3 years ago

I think this is a really good initiative! I think we might discover and solve a few bugs from these changes. I think this will bring to light any accidental behavior that was not accounted for and help use lean on the compiler to catch errors for us more often!

Sergio0694 commented 3 years ago

Yeah that's absolutely one good advantage that this would bring, it'd both make it easier for consumers to more reliably integrate our APIs into their codebases, and it'd also certainly help us catch little bugs that probably have gotten past us so far 😄 Really glad you like the proposal!