KSP-CKAN / CKAN

The Comprehensive Kerbal Archive Network
https://forum.kerbalspaceprogram.com/index.php?/topic/197082-*
Other
1.99k stars 348 forks source link

Nullable references, net8.0, blend registry alert dot, netkan fixes #4171

Closed HebaruSan closed 2 months ago

HebaruSan commented 2 months ago

Motivation

References in C#'s default type system can be either an object or null, and if you try to use a null reference as if it was an object, a null reference exception is thrown, which can wreck things for end users. The only way to avoid this is to track in your brain whether every reference can be null, which generally requires checking for null frequently, which is tedious and easy to forget.

C# 8 added the ability to make references non-nullable by default. This means that a variable or function's type can indicate that parameters and return values can't be null, and the compiler can enforce it. References can be made nullable by appending ? to the type, just like for the already existing nullable types, and the compiler will check the code and emit warnings if such references are used in a way that could cause null reference exceptions.

https://learn.microsoft.com/en-us/dotnet/csharp/nullable-references

This feature provides the tools to eliminate null reference exceptions via compile-time checks, which is a tremendous step forward.

Changes

Additional fixes and small features

While working on the above, a few other problems and ideas came up.