Open pchaurasia14 opened 1 year ago
Took a brief look, and there definitely needs to be made some calls now and then on behavior around null. Just the first class I hit looking a bit at this, and you see something like this:
https://github.com/dotnet/wpf/blob/c37ab558d3aebf3bfe0038c86e8a4be78d09e03c/src/Microsoft.DotNet.Wpf/src/System.Xaml/System/Windows/Markup/ArrayExtension.cs#L37-L41
It's clear that _arrayType
is not nullable, since we don't allow null in the constructor.
It is furthermore confirmed when looking in the ProvideValue
method:
https://github.com/dotnet/wpf/blob/c37ab558d3aebf3bfe0038c86e8a4be78d09e03c/src/Microsoft.DotNet.Wpf/src/System.Xaml/System/Windows/Markup/ArrayExtension.cs#L107-L110
However, in the property setter, no null check is made, so it could become null after all:
https://github.com/dotnet/wpf/blob/c37ab558d3aebf3bfe0038c86e8a4be78d09e03c/src/Microsoft.DotNet.Wpf/src/System.Xaml/System/Windows/Markup/ArrayExtension.cs#L83-L87
So that begs the question: Should we make the Type argument nullable. And if we do that, should we remove the null check in the constructor? Or if we decide to not make the type property nullable, then should we start throwing in the property setter if the value provided is null? Both cases are slight changes in behavior. Or do we just mark it not-nullable (since it seems that is the intent), yet keep the current behavior where we do allow a null to sneak in there?
In general I think there is much higher chance of the whole annotation project make it if it is metadata changes only, avoiding any changes in behaviour.
In general I think there is much higher chance of the whole annotation project make it if it is metadata changes only, avoiding any changes in behaviour.
That's how it was done in the runtime. And separate issues were created to fix !
s
Cc @stephentoub in case he has suggestions or thoughts about organizing this process in WPF based on what we learned.
There’s also guidance here
Certainly the more the community can do here, and it’s super susceptible to parallelization across interested folks, the more time the WPF maintainers can put on features.
in case he has suggestions or thoughts about organizing this process in WPF based on what we learned
I was pleased with the process we followed in dotnet/runtime. It was painstaking work, but the net result was very good.
The process was effectively this:
#nullable enable
, annotate all its public members, get it to compile, move on to the next file. Then once we'd successfully marked all files and everything was compiling, flip the assembly to be <Nullable>enable</Nullable>
and remove all the #nullable enable
s from the individual files.// TODO-NULLABLE https://link/to/issue: Figure out what to do about blah
kind of comment in the code.
c) Places where there was an obvious bug due to improperly handling nulls. If these were truly bugs, we'd fix it and include a test, but in general we'd prefer to instead open an issue for subsequent analysis and follow-up. One of our goals to keep things simple was that, in general, the annotation PRs shouldn't affect the IL at all, other than metadata, preferring to leave changes that could impact the resulting IL to subsequent dedicated PRs.Finalized the plan for nullability annotations support - top post is updated now.
Will be updating it with more warnings that need to be suppressed.
Using Microsoft.CodeAnalysis.PublicApiAnalyzers was a prerequisite for the winforms repo (see dotnet/winforms#2705). Is it also the case here?
@halgab This project has its own baseline component. So I don't think Microsoft.CodeAnalysis.PublicApiAnalyzers is necessary
[Plan finalized - 3/28]
Based on community feedback, here is the plan for supporting Nullability annotations.
List of assemblies and respective groups:
Thanks @dotMorten for the suggestion