Skip to content

SergeyTeplyakov/ErrorProne.NET

Repository files navigation

Error Prone .NET

ErrorProne.NET is a set of Roslyn-based analyzers that will help you to write correct code. The idea is similar to Google's error-prone but instead of Java, the analyzers are focusing on correctness (and, maybe, performance) of C# programs.

Installation

Add the following nuget package to you project: https://www.nuget.org/packages/ErrorProne.NET.CoreAnalyzers/

Rules

Rules

Async Analyzers

Id Description
EPC14 ConfigureAwait(false) call is redundant
EPC15 ConfigureAwait(false) must be used
EPC16 Awaiting a result of a null-conditional expression will cause NullReferenceException
EPC17 Avoid async-void delegates
EPC18 A task instance is implicitly converted to a string
EPC26 Do not use tasks in using block
EPC27 Avoid async void methods
EPC31 Do not return null for Task-like types
EPC32 TaskCompletionSource should use RunContinuationsAsynchronously
EPC33 Do not use Thread.Sleep in async methods
EPC35 Do not block unnecessarily in async methods
EPC36 Do not use async delegates with Task.Factory.StartNew and TaskCreationOptions.LongRunning
EPC37 Do not validate arguments in async methods

Generic Bugs and Code Smells

Id Description
EPC19 Observe and Dispose a 'CancellationTokenRegistration' to avoid memory leaks
EPC20 Avoid using default ToString implementation
EPC28 Do not use ExcludeFromCodeCoverage on partial classes
EPC29 ExcludeFromCodeCoverageAttribute should provide a message
EPC30 Method calls itself recursively
ERP041 EventSource class should be sealed
ERP042 EventSource implementation is not correct

Concurrency

Id Description
ERP031 The API is not thread-safe

Error Handling Issues

Id Description
EPC11 Suspicious equality implementation
EPC12 Suspicious exception handling: only the 'Message' property is observed in the catch block
EPC13 Suspiciously unobserved result
EPC34 Method return value marked with MustUseResultAttribute must be used
ERP021 Incorrect exception propagation
ERP022 Unobserved exception in a generic exception handler

Performance

Id Description
EPC23 Avoid using Enumerable.Contains on HashSet
EPC24 A hash table "unfriendly" type is used as the key in a hash table
EPC25 Avoid using default Equals or HashCode implementation from structs

About

Set of roslyn-based analyzers for catching common C# errors (inspired by Google's error-prone)

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 14