|
We do, and at first I hated it, but now I've embraced it. We find it cuts down on lots of null-ref opportunities.
Sure, it can be annoying sometimes, but the occasional "!" on the end of a var, combined with the much nicer "if x is not null" makes the code very clear. Assuming you know what a trailing ! is...
cheers
Chris Maunder
|
|
|
|
|
Chris Maunder wrote: Assuming you know what a trailing ! is You nailed it on its ! head. Time to google. Technology keeps leaping forward and I am stumbling around trying to keep up while at the same time wondering why I'm trying to keep up.
|
|
|
|
|
I hear ya.
Reminds me of the 2 day long conversation Matthew and I had about the extra negation inif not "!arg_name:enableGPU=!" == "!arg_name!" . I didn't see the double negation. He's pointing at his screen (over FaceTime) saying "there!". The issue was the "!" meant delayed expansion of a variable substitution in the Batch file, but to any reasonable developer it's "not arg_name".
We imbue symbols with way too much meaning.
cheers
Chris Maunder
|
|
|
|
|
All the time, and I fix the warnings if they come up. It’s greatly reduced the number of null exceptions that get thrown. I’d prefer it though if they were reported as build failures by default.
Eagles may soar, but weasels don't get sucked into jet engines
|
|
|
|
|
I have been using it on all of my work and hobby projects since it was introduced to .NET.
#nullable #enable 🤣.
|
|
|
|
|
Agree these warnings are pretty annoying in a project that didn't start out using nullable ref types correctly from the start. I have a large project in this situation, and fixing all these warnings is pretty daunting, requiring significant rework and refactoring. But I've come to see the value of using nullable ref types, so I've adopted it in smaller projects, and have been using it going forward. It's just not feasible to retrofit in all cases.
|
|
|
|
|
Yes, I use it, and I like it very much. Removed all possible NRE, and it's perfect to make sure juniors do not introduce tons of bugs. Sometimes a IF xx != null is enough, some other times we need "!", I hope the compiler could become smarter like Typescript is.
|
|
|
|
|
rallets wrote: and it's perfect to make sure juniors do not introduce tons of bugs
Null pointers are not significant, to me, in production.
Logic errors however are.
And the only way to prevent that for juniors and seniors is meaningful code reviews.
|
|
|
|
|
This entire push to eliminate Null is misguided. The reason is that in the real world sometimes you really have no information, which is what Null represents. Look at numeric data types, zero is not the same as NULL. Zero is a value but NULL represents no value. This is a fundamental semantic difference.
|
|
|
|
|
Generally the idea is thus...
Someone misused it - thus it must be a problem.
Then they come up with an idiom that could fix it, that single problem, while introducing other potential problems (like using magic values for no value) and then proclaim that the world is a wonderful place.
Thus hoping that a technology fix can absolve them of relying on process (non-technology) solutions which have been proven (studies) to reduce problems.
|
|
|
|
|
I fully agree with everything you wrote, however, nullable checking is not necessarily about eliminating the use of null per se. It's about telling things that can legitimately be null (then it reminds you to check) apart from things which should never be null (then it reminds you to not put a null in there).
|
|
|
|
|
Not using .Net 7 yet, but using this in .Net 4.8, .Net Core 31, 5, and 6.
Yeah, the warnings can be annoying, but the benefit can be significant too. Especially with junior devs who aren't used to null checking everywhere/don't have the experience to spot all the potential problems... but it's good for us oldies too, everybody misses stuff sometimes.
The first warning in that list is the one that annoys me most. There are several potential work arounds depending on the specifics, but I often feel none are good
|
|
|
|
|
It only makes sense for ASP.NET services or maybe new code bases that its critical you don't have null.
.NETFW, Unity3D or other C# projects that heavily use older .NET frameworks its a nightmare.
Only new code that uses new APIs does it work well.
|
|
|
|
|
Rear meat game (10)
In a closed society where everybody's guilty, the only crime is getting caught. In a world of thieves, the only final sin is stupidity. - Hunter S Thompson - RIP
|
|
|
|
|
Too easy! Better double!
Software rusts. Simon Stephenson, ca 1994. So does this signature. me, 2012
|
|
|
|
|
They're always easy if you know the answer Peter and I think you meant bet double
In a closed society where everybody's guilty, the only crime is getting caught. In a world of thieves, the only final sin is stupidity. - Hunter S Thompson - RIP
|
|
|
|
|
One of those ones that leap out of the screen. Better bet double, maybe.
Software rusts. Simon Stephenson, ca 1994. So does this signature. me, 2012
|
|
|
|
|
Nice one!
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
OK, 3 hours is enough...
BACK rear
GAMMON meat
BACKGAMMON game
Software rusts. Simon Stephenson, ca 1994. So does this signature. me, 2012
|
|
|
|
|
Good man YAUT
In a closed society where everybody's guilty, the only crime is getting caught. In a world of thieves, the only final sin is stupidity. - Hunter S Thompson - RIP
|
|
|
|
|
If he hadn't taken it, I would have.
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
Or if you would wait until at least 6 in the morning I would have answered as well 
|
|
|
|
|
Where do fish go on vacation?
"A little time, a little trouble, your better day"
Badfinger
|
|
|
|
|
Finland.
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
winner
"A little time, a little trouble, your better day"
Badfinger
|
|
|
|