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.

Consistency: Chains a call to NotNull

See original GitHub issue

In all of the other methods that validate the parameter is not null, we’re explicitly testing if (value is null) with a comment that reads

// To whoever is doing random code cleaning:
// Consider the performance when changing the code to delegate to NotNull.
// In general do not chain call to another function, check first and return as earlier as possible.

However, in Requires.NotNullOrEmpty we don’t do that and instead, call NotNull. Should we change this so it’s consistent?

https://github.com/AArnott/Validation/blob/2378284a62d732a89454564afca189b48e7ba5ba/src/Validation/Requires.cs#L249

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
scottdormancommented, Sep 27, 2020

I can change them to call NotNull and add a ThrowHelper.

I don’t know how to validate what the JIT inlines, though, short of looking at the compiled code in something like JustDecompile…or is that what you’re thinking of?

I’ll submit a separate PR for this, and then once it gets approved will submit one to vs-validation. That way, any changes that might be needed can be done here first and the PR to vs-validation ends up being cleaner.

0reactions
scottdormancommented, Sep 28, 2020

Nice. I didn’t know the ETW events included explanations. I’ll have to check that out.

Read more comments on GitHub >

github_iconTop Results From Across the Web

C# null check chain in method call
Starting with C# 6.0 you can use Null-Conditional Operator, which lets you make null-checking implicitly: var result = possiblyNull?
Read more >
Releases · AArnott/Validation
#45: Consistency: Chains a call to NotNull; #48: Replaces the single-iteration foreach loops. This list of changes was auto generated.
Read more >
Fetching a value without having to null check in Java
I think it is better to know where exactly the chain is broken than to silently get a null that could be hiding...
Read more >
`foo?.bar.yolo.stop()` - Mixed Nullable & Non- ...
Finding the first question mark in the call chain is easy, but it requires me to continuously scan call chains for question marks....
Read more >
Consistent gets growth fast when running FLASHBACK QUERY
Hi all! I have running a simple flashback version query on table and query completes after 2 or 3 hours and requires too...
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