TA.Analyzers.InvalidNullChecks 1.0.0

dotnet add package TA.Analyzers.InvalidNullChecks --version 1.0.0
                    
NuGet\Install-Package TA.Analyzers.InvalidNullChecks -Version 1.0.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="TA.Analyzers.InvalidNullChecks" Version="1.0.0">
  <PrivateAssets>all</PrivateAssets>
  <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="TA.Analyzers.InvalidNullChecks" Version="1.0.0" />
                    
Directory.Packages.props
<PackageReference Include="TA.Analyzers.InvalidNullChecks">
  <PrivateAssets>all</PrivateAssets>
  <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add TA.Analyzers.InvalidNullChecks --version 1.0.0
                    
#r "nuget: TA.Analyzers.InvalidNullChecks, 1.0.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package TA.Analyzers.InvalidNullChecks@1.0.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=TA.Analyzers.InvalidNullChecks&version=1.0.0
                    
Install as a Cake Addin
#tool nuget:?package=TA.Analyzers.InvalidNullChecks&version=1.0.0
                    
Install as a Cake Tool

Reduce bugs by finding unneeded null checks and suppressions of known not-null values.

namespace InvalidNullChecksTest
{
	internal class Program
	{
		static void Main(string[] args)
		{
			if (_s1 == null) return;
			if (_s2 == null) return;
			if (_s2 is null) return;

			_s2 ??= "def";

			if (_s3 is not null)
			{
				if (_s3 is null) return;
				if (_s3 == null) return;
			}

			if (_s3 != null)
			{
				if (_s3 is null) return;
				if (_s3 == null) return;
			}

			string r1 = _s1!.Trim();
			string r2 = _s2!.Trim();
		}
		static string? _s1;
		static string _s2 = "abc";
		static string? _s3;
	}
}

Resulting warnings

There are no supported framework assets in this package.

Learn more about Target Frameworks and .NET Standard.

This package has no dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.0 390 3/18/2024