Open daniel-lerch opened 3 weeks ago
The problem is that I'm still trying to support .NET Framework which doesn't have this.
I'm not saying it can't be done, it's just a lot of work to #if/#else/#endif everything.
As far as I know this should work in .net framework. You probably have to upgrade to language version 8 or higher.
I can confirm that nullable reference types as such do work with .NET Framework. Some very useful attributes like [NotNullWhen]
or [MemberNotNull]
require .NET Standard 2.1 or .NET 5.0.
I enabled this feature for some classes in #1068 and added #if
statements to add attributes for more modern .NET versions.
I would be willing to contribute further pull request to enable nullable reference types for more classes. Enabling for the entire project would be too much work at once for me, though.
FWIW, I created a new branch for this work. I also added compatibility attributes to reduce #if/#else's littering the codebase.
I just need to find time to work on it more, haha.
I wonder if I should look into writing a Roslyn-based tool to automate this.
Is your feature request related to a problem? Please describe. I just came across a
NullReferenceException
in my app which uses nullable reference types because I did not read MimeKit's documentation properly and missed that a type can be null.Describe the solution you'd like I consider nullable reference types a great feature of C# that makes you as a developer think twice whether you can really omit a null check. In my opinion it would be great if MimeKit would at least add nullable attributes to its public API. It might even make sense to enable nullable reference types for the entire code base.
Describe alternatives you've considered N/A
Additional context N/A