Shane32.Analyzers 2.0.1

dotnet add package Shane32.Analyzers --version 2.0.1
                    
NuGet\Install-Package Shane32.Analyzers -Version 2.0.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="Shane32.Analyzers" Version="2.0.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="Shane32.Analyzers" Version="2.0.1" />
                    
Directory.Packages.props
<PackageReference Include="Shane32.Analyzers">
  <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 Shane32.Analyzers --version 2.0.1
                    
#r "nuget: Shane32.Analyzers, 2.0.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.
#addin nuget:?package=Shane32.Analyzers&version=2.0.1
                    
Install Shane32.Analyzers as a Cake Addin
#tool nuget:?package=Shane32.Analyzers&version=2.0.1
                    
Install Shane32.Analyzers as a Cake Tool

Shane32.Analyzers

NuGet Coverage Status

Analyzers

This package contains a collection of Roslyn analyzers and code fixes that can be used to enforce coding standards and best practices in C# code.

  1. IQueryable cast analyzer

Prevents casting IQueryable<T> to IEnumerable<T>. This is a common mistake that can cause performance issues by preventing the query from being executed asynchronously.

To fix this warning, call ToListAsync() to asynchronously execute the query before casting it to IEnumerable<T>.

Explicit casts and AsEnumerable() calls will not trigger this warning.

  1. Synchronous IQueryable method call analyzer

Prevents calling Queryable methods that synchronously execute the query such as Single() or FirstOrDefault().

To fix this warning, use the asynchronous version of the method such as SingleAsync() or FirstOrDefaultAsync().

  1. Async methods must have CancellationToken parameter analyzer

Ensures that methods ending with "Async" in non-Controller classes have a CancellationToken parameter. This enforces the best practice of supporting cancellation in all asynchronous operations.

To fix this warning, add a CancellationToken parameter to the method signature. The parameter can be optional with a default value of default.

Credits

Glory to Jehovah, Lord of Lords and King of Kings, creator of Heaven and Earth, who through his Son Jesus Christ, has reedemed me to become a child of God. -Shane32

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
2.0.1 625 4/3/2025
2.0.0 156 4/3/2025
1.0.1 13,456 4/11/2024
1.0.0 258 4/11/2024