Enable C# 8's nullable annotations
See original GitHub issueAfter #228 is merged, we should be able to enable the new nullable reference types all over our project. It’s important so we could provide the nullability information through our API for the users.
Remaining points to do:
- fix this: https://github.com/ForNeVeR/wpf-math/blob/c8c6a5f4efc88ddbc0f6807693c7f09906470e20/src/WpfMath/Atoms/RowAtom.cs#L62
-
BigOperatorAtom.BaseAtom
should become non-nullable -
ScriptsAtom.BaseAtom
should become non-nullable - make
StyledAtom
’s constructor parameteratom
non-nullable, add asserts - make
TypedAtom.Atom
non-nullable, add asserts - make
UnderlinedAtom.Atom
non-nullable - make
VerticalCenteredAtom.Atom
non-nullable - make
OverUnderBox.ScriptBox
non-nullable -
PredefinedFormulaParser
shouldn’t returnnull
? to fixpredefinedFormula!.RootAtom!
(TexFormulaParser.cs:648
) - make
Radical.BaseAtom
non-nullable - remove TODO / fix the issue with
RowAtom
ctor (seeRowAtom(SourceSpan? source, IEnumerable<Atom?> elements)
) - fix an issue with
RowAtom(SourceSpan? source, Atom? baseAtom)
(see the comment there) - review any remaining comments about
// Nullable TODO
and removeTODO
or fix them - review any remaining comments about
// Nullable
Issue Analytics
- State:
- Created 4 years ago
- Comments:9 (9 by maintainers)
Top Results From Across the Web
Nullable reference types
Nullable contexts enable fine-grained control for how the compiler interprets reference type variables. The nullable annotation context ...
Read more >The annotation for nullable reference types should only be ...
The nullable annotation context of any given source line is either enabled or disabled. You can think of the pre-C# 8.0 compiler as...
Read more >Update your codebase to use nullable reference types
Nullable reference types enable you to declare if variables of a reference type should or shouldn't be assigned a null value.
Read more >C# 8.0 nullable references: getting started in an existing ...
In an earlier post in this series, "non-nullable is the new default", I described how enabling C# 8.0's new nullable references feature ...
Read more >C# 8.0 nullable references: conditional post-conditions
C# 8.0 nullable references enable us to annotate our code with information that lets the compiler discover possible null-related bugs. C# 8.0 ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I’ve decided to keep this issue open even after merging #277. Remaining small pieces of work are enumerated in the opening post.
Ok, I’ve stashed the mishmash of fixes I’ve had to far (down to 47 warnings) and decided to start anew with a gradual approach (I can still pick changes from the stash to avoid duplicating work). This makes it easier to commit piecemeal enablings and fixes as well as making it easier to track what nullability inclusion now brought nullable types all over everything (there were a few very viral parts that could perhaps better be tackled at the source to not let them be
null
to begin with).I’ll probably issue the first partial PR today or tomorrow, since I’m offline for a week after that and building a WPF library on my Linux laptop won’t work so great.
One thing I noticed is that with TargetFramework=net452 the analyzer seems less smart and ignores things like
Debug.Assert
and other things. This made a few!
necessary. I’ve commented all of them for now and if someone has a better idea to solve a particular instance we can fix them in another way (!
is just the quickest fix to silence the diagnostic, of course 😉).