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.

Potential bug in the nullability data flow?

See original GitHub issue

Version Used: I’m on the latest net5.0 RC1 SDK

Steps to Reproduce: As I was adding nullable annotations to System.Net.HttpListener, I ran into this. I have this method:

internal static void FillFromString(NameValueCollection nvc, string s, bool urlencoded, Encoding encoding)
            {
                int l = (s != null) ? s.Length : 0;
                int i = (s.Length > 0 && s[0] == '?') ? 1 : 0;

I see an error at s.Length saying "Dereference of possible null reference. But sis defined as astring(notstring?) so it can never be null. I suspect the s != nullline is changing the nullability information. If I changes != nulltos != “foo”`, the error goes away.

Expected Behavior: No error at s.Length. Potentially report that the ternary operator at (s != null) can be removed (this is not strictly required to fix this bug)

Actual Behavior: Error at s.Length.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:7 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
RikkiGibsoncommented, Aug 31, 2020

Will close this out now, feel free to follow up here if you have questions.

0reactions
pgovindcommented, Sep 2, 2020

Apologies, I was busy with .NET 5 stuff. If this is by design, I agree that this can be closed!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why do we get possible dereference null reference ...
As humans, we can look at this code and obviously understand that it cannot throw a null reference exception. But the way the...
Read more >
DataFlow possible bug?
I have a mapping table in DataFlow, which am merging with other tables coming (non-DataFlow) in the PBI desktop Dataset.
Read more >
Data Flows with null in boolean
The most common scenario when you will get null-values in booleans in dataverse, is if you for instance have a table with 1M...
Read more >
'Nullability and data flow problems' false negative when ...
'Nullability and data flow problems' false negative when checked before, and with IF statement ; Priority, Normal N ; Type, Bug ; State,...
Read more >
Proposal: Nullable reference types and nullability checking ...
Detect and warn on cases where nullable types are dereferenced, or when null is values are assigned to (or left in) non-nullable variables....
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