UnitsNet
UnitsNet copied to clipboard
Use C#8 nullable reference types
C#8 is due in the fall of 2019 and one interesting feature we can take advantage of is nullable reference types, instead of JetBrains' [NotNull]
and [CanBeNull]
attributes that don't really give much value to the consumers of the library.
With nullable reference types I believe we can communicate to consumers whether a returned object can be null or not. We use struct value types for all quantities today so I'm not sure how much impact it will make, but we are discussing moving to class instead and at that point it will probably give a lot more value.
Anyway, it's a cool new language feature and if anyone wants to do a PR to play with it, this can be a good start. If no one else does, I'll probably take a stab at it sometime.
I'm looking at using Nullable Reference Types as well. From what I understand though it's a compiler only thing. It will not validate at runtime. So it's only usable at compile time with static analysis.
Yes that's right. It only has an effect at compile time. Also, it is an optional feature that consumers of the nuget will have to enable in their projects to benefit from. Still, the idea of communicating nullability to nuget consumers is pretty great.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
Keeping this one up for a bit in case someone wants to pick it up and run with it.