Nullable Reference Types are supported since C# 8 in .NET and allow us to minimize the likelihood that our code causes the runtime to throw System.NullReferenceException.
NRT warnings are enabled by default from .NET 6 onwards.
I was curious how many devs kept them enabled either as warnings or errors so I ran a poll on my LinkedIn and Twitter profiles.
The results are below …
After over 800 votes we can see that the amount of devs who have them enabled (either as warnings or errors) is largely consistent between LinkedIn and Twitter at around 70%. While around 26-28% have them disabled altogether.
On Twitter the ‘Yes – As Errors’ vote was as high as 25.2% which surprised me. I do think enabling them as errors is the way to go though, as let’s be honest it’s too easy to ignore warnings right?
Do you enable NRTs in your C# 8+ apps?
Let me know your thoughts …