NullableEnforcer 1.0.0

The owner has unlisted this package. This could mean that the package is deprecated, has security vulnerabilities or shouldn't be used anymore.
dotnet add package NullableEnforcer --version 1.0.0
                    
NuGet\Install-Package NullableEnforcer -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="NullableEnforcer" 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="NullableEnforcer" Version="1.0.0" />
                    
Directory.Packages.props
<PackageReference Include="NullableEnforcer">
  <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 NullableEnforcer --version 1.0.0
                    
#r "nuget: NullableEnforcer, 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 NullableEnforcer@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=NullableEnforcer&version=1.0.0
                    
Install as a Cake Addin
#tool nuget:?package=NullableEnforcer&version=1.0.0
                    
Install as a Cake Tool

NullableEnforcer

A zero-dependency NuGet package that automatically enables and enforces nullable reference type warnings in your .NET projects.

Features

  • Enables nullable reference types
  • Converts nullable warnings to compiler errors
  • Enforces strict null checking across your entire solution
  • No runtime dependencies
  • Compatible with all .NET projects supporting nullable reference types (C# 8.0+)

Installation

Install via NuGet Package Manager:

Install-Package NullableEnforcer

Or using the .NET CLI:

dotnet add package NullableEnforcer

Or by adding directly to your .csproj:

<PackageReference Include="NullableEnforcer" Version="1.0.0" />

What It Does

When added to your project, this package automatically sets the following MSBuild properties:

<Nullable>enable</Nullable>
<WarningsAsErrors>nullable</WarningsAsErrors>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>

This means:

  1. Nullable reference types are enabled
  2. All nullable warnings are treated as errors
  3. Your code won't compile if there are any nullable reference type violations

Example

Without NullableEnforcer:

public class User
{
    public string Name { get; set; }  // Compiles, but could be null
    
    public void PrintName()
    {
        Console.WriteLine(Name.ToUpper());  // Potential NullReferenceException
    }
}

With NullableEnforcer:

public class User
{
    public string Name { get; set; }  // Error: Must be nullable or initialized
    
    // Fixed version:
    public string Name { get; set; } = "";
    // Or:
    public string? Name { get; set; }
}

Benefits

  • Catch null reference issues at compile-time rather than runtime
  • Improve code quality and reduce null-related bugs
  • Force explicit handling of nullable cases
  • No configuration needed - works immediately after installation

Requirements

  • .NET projects that support nullable reference types (C# 8.0 or later)
  • For .NET Core 3.1+ or .NET 5+

License

MIT

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

There are no supported framework assets in this package.

Learn more about Target Frameworks and .NET Standard.

  • .NETStandard 2.0

    • 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