Skip to content

Latest commit

 

History

History
64 lines (48 loc) · 5.85 KB

README.md

File metadata and controls

64 lines (48 loc) · 5.85 KB

GitHub last commit (master) Build (master) Coverage NuGet Version NuGet Downloads Gitter

NetFabric.Hyperlinq.Analyzer

A Roslyn Analyzer that contains several rules to help improve enumeration performance when using C#.

Note: This analyzer is independent of NetFabric.Hyperlinq. The rules may be useful when you only use foreach, IEnumerable<T>, IAsyncEnumerable<T>, System.Linq or System.Linq.Async.

Rule ID Category Severity Notes
HLQ001 Performance Warning Assigment to interface causes boxing of enumerator
HLQ002 Compiler Error Enumerable cannot be null.
HLQ003 Performance Warning Public methods should return highest admissible level interface.
HLQ004 Performance Warning The enumerator returns a reference to the item.
HLQ005 Performance Warning Avoid use of Single() and SingleOrDefault()
HLQ006 Performance Warning GetEnumerator() or GetAsyncEnumerator() should return a value type.
HLQ007 Performance Warning Consider returning a non-disposable enumerator.
HLQ008 Performance Info The enumerable is a value type. Consider making it readonly.
HLQ009 Performance Info Consider removing an empty optional enumerator method.
HLQ011 Compiler Error Mutable value-type enumerators cannot be stored in a readonly field.
HLQ012 Performance Warning Consider using CollectionsMarshal.AsSpan() when iterating a List<T>.
HLQ013 Performance Warning Consider using foreach when iterating an array or a Span<T>.

Usage

Visual Studio Marketplace

Install the NetFabric.Hyperlinq.Analyzer extension from the Visual Studio Marketplace.

Nuget package

Add the NetFabric.Hyperlinq.Analyzer package to your project using your favorite NuGet client.

If added manually to the .csproj, make sure to set PrivateAssets to all so that it's not added as a dependency. A floating version can be used to get the latest version.

<PackageReference Include="NetFabric.Hyperlinq.Analyzer" Version="2.*">
  <PrivateAssets>all</PrivateAssets>
  <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>

References

Credits

The following open-source projects are used to build and test this project: