question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Enable C# 8's nullable annotations

See original GitHub issue

After #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 parameter atom 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 return null? to fix predefinedFormula!.RootAtom! (TexFormulaParser.cs:648)
  • make Radical.BaseAtom non-nullable
  • remove TODO / fix the issue with RowAtom ctor (see RowAtom(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 remove TODO or fix them
  • review any remaining comments about // Nullable

Issue Analytics

  • State:open
  • Created 4 years ago
  • Comments:9 (9 by maintainers)

github_iconTop GitHub Comments

1reaction
ForNeVeRcommented, Aug 16, 2020

I’ve decided to keep this issue open even after merging #277. Remaining small pieces of work are enumerated in the opening post.

1reaction
ygracommented, Aug 14, 2020

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 😉).

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found