-
Notifications
You must be signed in to change notification settings - Fork 105
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Enable nullable reference types #277
Conversation
The `as` operator has been changed to pattern matching to avoid null checks entirely.
Unconstrained generics make a `!` necessary.
This poses a bit of a problem in the StyledAtom ctor in that an Atom? is eventually passed to RowAtom(source, elements), where elements is supposed to not contain null values at all.
There's a few problems that stem from other parts of the code, e.g. ExtensionChar.Repeat being nullable, but used in CharBox, or OverUnderBox using a nullable ScriptBox as if it were not null.
OK, I do see build failures on my end as well, but seemingly only for net452: Seems like the Nullable NuGet package doesn't seem to work as expected.
The build seems to work for netcoreapp3.0, which results in the compiled assembly. Subsequent builds in VS (Ctrl+Shift+B) then tell me "Build successful", as the build system apparently thinks all artifacts are there. |
Apparently this is the problem: manuelroemer/Nullable#11 I guess I'll probably go with conditional compilation for the respective lines and we'll miss a bit nullability fidelity in net452. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hell of a work you did here, thanks a lot! I've reviewed every single change, and left some comments.
I've decided to move some of the remaining work (see the TODOs I've added to the initial post) to a new issue though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your work!
Well, thanks for giving me an opportunity to try such a migration. Still planning to do so at work, albeit on a larger, more confusing code base where the only benefit is that I know it fairly well :-) And I fear the amount of left over todos is probably normal for old code. |
Long list of commits, but perhaps that makes reviewing a bit easier, as the changes are somewhat scoped.
#nullable disable
and the build succeeds and the example still runs.There have been a few problematic places, though, that have been annotated with comments, and sometimes pointed out in the commit message. Most of those have been silenced for now with a somewhat minimal set of
!
operators.See #230.
TODO (F):
ScriptsAtom.BaseAtom
being (supposedly) non-nullableStyledAtom
's constructor parameteratom
non-nullable, add assertsTypedAtom.Atom
non-nullable, add assertsUnderlinedAtom.Atom
VerticalCenteredAtom.Atom
OverUnderBox.ScriptBox
PredefinedFormulaParser
shouldn't returnnull
? to fixpredefinedFormula!.RootAtom!
(TexFormulaParser.cs:648
)Radical.BaseAtom
RowAtom
ctorRowAtom(SourceSpan? source, IEnumerable<Atom?> elements)
RowAtom(SourceSpan? source, Atom? baseAtom)
(see the comment)