Skip to content

Roslyn Analyzer which enforces the usage of 'is null' and 'is not null' over '== null' and '!= null'.

License

Notifications You must be signed in to change notification settings

CollinAlpert/IsNullEnforcer

Repository files navigation

IsNullEnforcer

This Roslyn Analyzer was inspired by this tweet.
It searches for conditions in your code which perform null checks using the "==" or the "!=" operator and forces you to use the "is" or "is not" patterns instead. Here's an example:

using System;

string? s = null;
if (s == null) {
    Console.WriteLine("Is null!")
}

The condition would be highlighted as an error and a code fix would be offered, changing the code to s is null.

Disclaimer: I am not saying this is a good idea and/or should be included in every code base. This is just a demonstration to show what is possible.

About

Roslyn Analyzer which enforces the usage of 'is null' and 'is not null' over '== null' and '!= null'.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages