Shane32.Analyzers
2.0.1
dotnet add package Shane32.Analyzers --version 2.0.1
NuGet\Install-Package Shane32.Analyzers -Version 2.0.1
<PackageReference Include="Shane32.Analyzers" Version="2.0.1"> <PrivateAssets>all</PrivateAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets> </PackageReference>
<PackageVersion Include="Shane32.Analyzers" Version="2.0.1" />
<PackageReference Include="Shane32.Analyzers"> <PrivateAssets>all</PrivateAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets> </PackageReference>
paket add Shane32.Analyzers --version 2.0.1
#r "nuget: Shane32.Analyzers, 2.0.1"
#addin nuget:?package=Shane32.Analyzers&version=2.0.1
#tool nuget:?package=Shane32.Analyzers&version=2.0.1
Shane32.Analyzers
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.
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.
- 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()
.
- 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
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.