Skip to main content

Miscellaneous collection of additional analyzers

Total Downloads
59.5K
59,526
Published
Jul 25, 2025
1y ago

Get Started

dotnet add package Shane32.Analyzers --version 2.0.2

No framework information available.

README

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

Downloads by Version

Depended On By

Find packages that declare this package as a dependency. NuGet does not provide a reverse-dependency endpoint, so candidates are checked on demand.

Adoption Assessment

A verified publisher signal is available. Assess fit from the package's supported frameworks, license and dependency graph rather than popularity alone.

No target framework metadata is available. Confirm compatibility in a representative project before standardising on this package.

Related Guides & Workflows

Learn how to evaluate, integrate, or audit this package in your .NET project.