NServiceBus icon indicating copy to clipboard operation
NServiceBus copied to clipboard

Introduce support for nullable reference types

Open lailabougria opened this issue 4 years ago • 5 comments

CSharp 8 introduced nullable reference types. Developers of libraries and frameworks can enable nullability and annotate their types and methods with nullable attributes to make sure consumers of their APIs can compiler enforced warnings and hints.

It is possible to support nullable reference types even if you are targetting netstandard 2.0 as long as you are careful of only using the csharp 8 features that are supported like nullable reference types. Either way, CSharp 8 is enabled almost everywhere. For projects targeting .NET Framework, t is possible to bring the nullable attributes as well.

It is possible to gradually introduce nullable reference types on a "component by component"-base and even a "file by file"-base by adding #nullable enable to the file and from there start addressing the nullability issues until everything is in place to enable nullable on the project directly.

This can be done in a non-breaking manner. You can expose the attributes, as attributes don't need to be public like the actual types you expose in APIs do. You can declare them as internal when on the NS2.0 TFM, use them in all your public APIs, and consumers on any TFM will still benefit from them as you'd expect.

When this is picked up, please document guidance for downstream components to follow in the future. The work can be split into components (in which case issues should be opened for the components lacking support), or taken on as a whole.

lailabougria avatar Feb 09 '22 09:02 lailabougria

this would be great to see in V8. Or at least decorate the public APIs with nullable attributes

SimonCropp avatar Jun 20 '22 04:06 SimonCropp