Potential bug in the nullability data flow?
See original GitHub issueVersion 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 a
string(not
string?) so it can never be
null. I suspect the
s != nullline is changing the nullability information. If I change
s != nullto
s != “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:
- Created 3 years ago
- Comments:7 (5 by maintainers)
Top 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 >
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 Free
Top 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
Will close this out now, feel free to follow up here if you have questions.
Apologies, I was busy with .NET 5 stuff. If this is by design, I agree that this can be closed!