Safer Code with C# 8 Non-Null Reference Types

Matt Eland on September 14, 2019

Null reference exceptions are one of the most frequent errors encountered in .NET applications. As powerful as the framework is, it's built around ... [Read Full]
markdown guide
 

I left C# years ago when I found out that TypeScript already had non-nullable reference types. I’ve been very happy and productive since then with my NodeJS services. Even my ORM stuff has been a joy. I might return to C# libraries start to migrate to C# 8.

Matt, how long do you think it will be before LINQ to SQL integrates this? I know that NodaTime already has started porting to C#8’s non-nullable ref types.

 

TypeScript is actually my favorite programming language, though I miss LINQ. F# is pretty cool, but I'm still learning the ins and outs of it.

With .NET Core 3 expected to be official around the 23rd - 25th, I think we're most likely to see additional polish and support around the feature alongside 3.1 or a stand-alone 'service pack' style update to Visual Studio. I'd be surprised if we had to wait until Visual Studio 2021 to get more royal support for non-null types, but anything is possible.

When I look at all of the options for improving code quality out there, this feature is probably the one I'd recommend to my department once the IDE supports it more out of the box. Until then, I'm pushing for use of Jetbrains.Annotations in critical areas for more explicit null checking on a large legacy codebase.

 

Yea, ImmutableJS has helped fill the gap left by LINQ. But it doesn’t do SQL generation, so I’ve been fine with TypeORM (which is actually pretty stellar).

And you’re right about the Jetbrains.Annotations. They’re basically a must-have.

I've found Jetbrains.Annotations to be a subjective thing. While I love them, as a senior / lead dev on a team, I'd only use them in areas largely maintained by me, not the more shared areas of our codebase. Now as a technology manager, I get to set standards and it's part of the standard I set.

I wasn't aware ImmutableJS did anything beyond help freeze your objects. I love it for that. Does it offer advanced querying capabilities or other capabilities from things like underscore or lodash?

ImmutableJS has Seq<T> which offers you lazy-evaluation so you can write functional chains while reducing the number of iterations (just like LINQ does).

 

I'm really looking forward to start adding this to code!

 

Hello to me it would be something new in my developments, I want to use it, thanks

code of conduct - report abuse