MissingAnalyzers 0.2.1

There is a newer version of this package available.
See the version list below for details.
dotnet add package MissingAnalyzers --version 0.2.1
                    
NuGet\Install-Package MissingAnalyzers -Version 0.2.1
                    
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="MissingAnalyzers" Version="0.2.1">
  <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="MissingAnalyzers" Version="0.2.1" />
                    
Directory.Packages.props
<PackageReference Include="MissingAnalyzers">
  <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 MissingAnalyzers --version 0.2.1
                    
#r "nuget: MissingAnalyzers, 0.2.1"
                    
#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 MissingAnalyzers@0.2.1
                    
#: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=MissingAnalyzers&version=0.2.1
                    
Install as a Cake Addin
#tool nuget:?package=MissingAnalyzers&version=0.2.1
                    
Install as a Cake Tool

Unused variables analyzer

What is this?

This is a C# code analyzer to warn you about unused variables. You can add it to your project, run dotnet build and see the warnings.

Why?

This project was created specifically because the default behavior of the compiler skips over unused variables. You might say that that's not true, that you've seen unused variable warnings before.

Yes, it exists, but unfortunately it's pretty limited. Specifically, the right hand side must be a compile time constant.

So:

public void Foo()
{
    var x = "unused"; // this is detected
    var y = new System.Text.StringBuilder(); // this is NOT detected
}

So basically it only catches the simplest case. In other words: it's useless.

This project is meant to fix this.

How to use it?

There are 2 main ways of installing and using this analyzer, depending on what type of project you're working on:

  • the simple, single project one
  • central package management with .props files

choose the approach that suits you best.

Add to a project

This project is on NuGet, so you can add it through dotnet CLI:

dotnet add package MissingAnalyzers

or add this to your .csproj file:

<ItemGroup>
  <PackageReference Include="MissingAnalyzers" Version="0.2.1" />
</ItemGroup>

Add to all projects

If you're using "central package version management" you can add this to the Directory.Packages.props file

<ItemGroup>
  <PackageVersion Include="MissingAnalyzers" Version="0.2.1" />
</ItemGroup>

and this to Directory.Build.props file

<ItemGroup>
  <PackageReference Include="MissingAnalyzers" />
</ItemGroup>

What's next?

  • catch unused variables and report a compiler warning
  • publish the package on NuGet
  • fill AnalyzerReleases.Shipped.md (whatever those are)
  • maybe support versions older than net8.0? netstandard2.0 supported
  • fix a bug with shadowing names in lambdas
  • add tests
  • add another analyzer if I see another problem
There are no supported framework assets in this package.

Learn more about Target Frameworks and .NET Standard.

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
0.6.0 254 11/6/2025
0.5.0 188 11/6/2025
0.4.0 183 9/8/2025
0.3.0 187 8/12/2025
0.2.1 183 8/12/2025
0.2.0 191 8/12/2025
0.1.1 221 8/8/2025
0.1.0 638 8/8/2025