MissingAnalyzers 0.2.0
See the version list below for details.
dotnet add package MissingAnalyzers --version 0.2.0
NuGet\Install-Package MissingAnalyzers -Version 0.2.0
<PackageReference Include="MissingAnalyzers" Version="0.2.0"> <PrivateAssets>all</PrivateAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets> </PackageReference>
<PackageVersion Include="MissingAnalyzers" Version="0.2.0" />
<PackageReference Include="MissingAnalyzers"> <PrivateAssets>all</PrivateAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets> </PackageReference>
paket add MissingAnalyzers --version 0.2.0
#r "nuget: MissingAnalyzers, 0.2.0"
#:package MissingAnalyzers@0.2.0
#addin nuget:?package=MissingAnalyzers&version=0.2.0
#tool nuget:?package=MissingAnalyzers&version=0.2.0
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
.propsfiles
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 MissingAnalyzers
or add this to your .csproj file:
<ItemGroup>
<PackageReference Include="MissingAnalyzers" Version="0.2.0" />
</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.0" />
</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.0supported - fix a bug with shadowing names in lambdas
- add another analyzer if I see another problem
Learn more about Target Frameworks and .NET Standard.
-
.NETStandard 2.0
- Microsoft.CodeAnalysis.CSharp (>= 4.0.1)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.