Open rmunn opened 1 week ago
After some discussion in the office, we will hold off on merging this until we can understand more about the effort it will take to upgrade to .Net 8 windows forms. Upgrading will eliminate some compiler warnings and reveal the ones that are actually a problem.
This fixes some of the compiler warnings about nullable reference types that you get when you build this with a modern C# compiler. It doesn't fix nearly all of them, because I realized that a lot of these can't be easily fixed as long as the project is targeting
net461
. For example, this section of code produces a compiler warning on line 276 thatswitchToCitationForm
might be null:https://github.com/sillsdev/solid/blob/96dc3322a1b3514c43bedea07b354b3ba86b65f8/src/SolidGui/QuickFixer.cs#L269-L276
It's immediately obvious that
switchToCitationForm
cannot be null on line 276, but the compiler doesn't know that as long as the target framework isnet461
. That's because the annotations that tell the compiler "If this function returns true/false, then its parameter can/cannot be null" were added to library code sometime during the .NET Core / .NET 5 era, and the net461 framework libraries don't have those annotations. So the compiler can't infer anything about the nullness of the parameter to string.IsNullOrEmpty, and therefore it gives a warning. You could suppress it by using the!
operator, as I did in this particular case, but doing that everywhere is tedious. And ultimately pointless, when switching to a more modern .NET target will end up fixing the issue anyway.Therefore, I suggest postponing the rest of this work until after the code is switched to target a more modern version of .NET, say 6 or 8. At that point many of the compiler warnings will go away, and the ones that are left will be ones actually worth fixing.