The list below describes per rule what its analyzer reports on.
AV1000: A class or interface should have a single purpose
This analyzer reports when a type has the word "And" in its name.
AV1008: Avoid static classes
This analyzer reports when:
- the name of a static class does not end in "Extensions"
- a static class whose name ends in "Extensions" contains a public or internal non-extension method.
AV1010: Don't suppress compiler warnings using the new
keyword
This analyzer reports when a member has the new
modifier in its signature.
AV1115: A property, method or local function should do only one thing
This analyzer reports when a member has the word "And" in its name.
AV1130: Return an IEnumerable<T>
or ICollection<T>
instead of a concrete collection class
This analyzer reports when the return type of a public or internal method implements IEnumerable
and is changeable (for example: List<string>
or ICollection<int>
). Instead, return IEnumerable<T>
, IAsyncEnumerable<T>
, IQueryable<T>
, IReadOnlyCollection<T>
, IReadOnlyList<T>
, IReadOnlySet<T>
, IReadOnlyDictionary<TKey, TValue>
or an immutable collection.
AV1135: Properties, arguments and return values representing strings or collections should never be null
This analyzer reports when null
is returned from a method, local function, lambda expression or property getter which has a return type of string, collection or task.
AV1210: Don't swallow errors by catching generic exceptions
This analyzer reports when a handler catches Exception
, SystemException
or ApplicationException
without a when
filter.
AV1225: Use a protected virtual method to raise each event
This analyzer reports when an event is raised:
- not from a method (for example, from a lambda expression or local function)
- from a method that is not protected and virtual
- from a method whose name does not match the pattern On{EventName}, for example: OnValueChanged.
AV1235: Don't pass null
as the sender
argument when raising an event
This analyzer reports when:
- 'sender' argument is null when raising a non-static event
- 'args' argument is null when raising an event.
AV1250: Evaluate the result of a LINQ expression before returning it
This analyzer reports when the return type of a public method is IEnumerable
or IEnumerable<T>
and it returns:
- the result of a method call that uses deferred execution (for example:
Where
,Select
,Concat
) - the result of a query (LINQ expression)
- an expression of type
IQueryable
orIQueryable<T>
.
AV1500: Methods should not exceed 7 statements
This analyzer reports when a method body (such as a method, property getter or local function) contains more than 7 statements.
Note: This rule can be customized using a configuration file by setting MaxStatementCount to a value in range 0-255.
AV1502: Avoid conditions with double negatives
This analyzer reports when the logical not operator is applied on an argument that has the word "No" or "Not" in its name.
AV1505: Name assemblies after their contained namespace
This analyzer reports when:
- a namespace does not match with the assembly name
- a type is declared in a namespace that does not match with the assembly name
- a type is not declared in a namespace.
AV1506: Name a source file to the type it contains
This analyzer reports when:
- a file is not named using pascal casing
- a file name contains an underscore
- a file name includes generic arity.
AV1507: Limit the contents of a source code file to one type
This analyzer reports when a file contains multiple non-nested types, unless they only differ by generic arity.
AV1522: Assign each variable in a separate statement
This analyzer reports when multiple properties, fields, parameters or variables are assigned in a single statement, except when using out variables, is-patterns or deconstruction into tuples.
AV1530: Don't change a loop variable inside a for
loop
This analyzer reports when a for
loop variable is written to in the loop body.
AV1532: Avoid nested loops
This analyzer reports when for
, foreach
, while
or do-while
loops are nested.
AV1535: Always add a block after the keywords if
, else
, do
, while
, for
, foreach
and case
This analyzer reports when a case
or default
clause in a switch statement does not have a block. The other keywords can be configured using Resharper.
AV1536: Always add a default
block after the last case
in a switch
statement
This analyzer reports when a non-exhaustive switch
statement on a (nullable) bool
or (nullable) non-flags enum
type does not have a default
clause.
AV1537: Finish every if
-else
-if
statement with an else
clause
This analyzer reports when an if
-else
-if
construct does not end with an unconditional else
clause.
AV1551: Call the more overloaded method from other overloads
This analyzer reports when:
- an overloaded method does not call another overload (unless it is the longest in the group)
- the longest overloaded method (the one with the most parameters) is not virtual
- the order of parameters in an overloaded method does not match with the parameter order of the longest overload.
AV1553: Only use optional parameters to replace overloads
This analyzer reports when an optional parameter of type string, collection or task has default value null
.
AV1554: Do not use optional parameters in interface methods or their concrete implementations
This analyzer reports when an interface method or an abstract/virtual/override method contains an optional parameter.
AV1555: Avoid using named arguments
This analyzer reports when a named argument is used, unless the parameter type is bool
or bool?
.
AV1561: Don't declare signatures with more than 3 parameters
This analyzer reports when a method, constructor, local function, indexer or delegate:
- declares more than three parameters
- declares a tuple parameter
- returns a tuple with more than 2 elements.
Note: This rule can be customized using a configuration file by setting MaxParameterCount and/or MaxConstructorParameterCount to a value in range 0-255. When MaxConstructorParameterCount is omitted, the value from MaxParameterCount (or its default) is used for constructors.
AV1562: Don't use ref or out parameters
This analyzer reports when:
- a parameter is declared as
ref
- a parameter is declared as
out
, unless the containing method name starts with "Try".
AV1564: Avoid signatures that take a bool
parameter
This analyzer reports when a public or internal member declares a parameter of type bool
or bool?
.
AV1568: Don't use parameters as temporary variables
This analyzer reports when a by-value (not ref
, in
or out
) parameter is written to.
AV1580: Write code that is easy to debug
This analyzer reports using nested method calls.
AV1704: Don't include numbers in variables, parameters and type members
This analyzer reports when a digit occurs in the name of a type, member, local function, parameter, tuple element or variable.
AV1706: Don't use abbreviations
This analyzer reports when the name of a type, member, local function, parameter, tuple element or variable consists of a single letter or contains an abbreviation like "Btn", "Ctrl", "Frm", "Chk", "Str" etc.
AV1708: Name types using nouns, noun phrases or adjective phrases
This analyzer reports when a type name contains the term "Utility", "Utilities", "Facility", "Facilities", "Helper", "Helpers", "Common" or "Shared".
AV1710: Don't repeat the name of a class or enumeration in its members
This analyzer reports when a member name contains the name of its containing type.
AV1711: Name members similarly to members of related .NET Framework classes
This analyzer reports when a member is named "AddItem", "Delete" or "NumberOfItems". See also CA1726.
AV1712: Avoid short names or names that can be mistaken for other names
This analyzer reports when a variable or parameter is named "b001", "lo", "I1" or "lOl".
AV1715: Properly name properties
This analyzer reports when a public or internal (nullable) boolean member or parameter name does not start with a word like "is", "has", "can" etc.
AV1738: Prefix an event handler with "On"
This analyzer reports when the name of an event handler method does not match the pattern {TargetName}On{EventName}, for example: OkButtonOnClick.
AV1739: Use an underscore for irrelevant lambda parameters
This analyzer reports when an unused lambda parameter name does not consist solely of underscores.
AV1745: Group extension methods in a class suffixed with Extensions
This analyzer reports when all public and internal methods of a static class are extension methods, but its name does not end with "Extensions".
AV1755: Postfix asynchronous methods with Async
or TaskAsync
This analyzer reports when the name of an async
method does not end with "Async".
AV1840: Await ValueTask
and ValueTask<T>
directly and exactly once
This analyzer reports when an expression of type ValueTask
or ValueTask<T>
is being assigned or used as argument without await
.
AV2202: Prefer language syntax over explicit calls to underlying implementations
This analyzer reports when:
- the
HasValue
property of a nullable value type is used to check fornull
- a comparison with a nullable value type contains a redundant null check.
AV2210: Build with the highest warning level
This analyzer reports when warnings are not treated as errors in the build settings.
Note: this analyzer requires Full Solution Analysis enabled.
AV2220: Avoid LINQ query syntax for simple expressions
This analyzer reports when a query (LINQ expression) can be changed into a single method call.
AV2230: Only use the dynamic
keyword when talking to a dynamic object
This analyzer reports when a statically typed expression is implicitly converted to dynamic
, unless the source type is object
or ObjectHandle
.
AV2235: Favor async
/await
over Task
continuations
This analyzer reports when Task.ContinueWith
is called.
AV2305: Document all public
, protected
and internal
types and members
This analyzer reports (in addition to what the C# compiler reports) when compiling with documentation comments enabled and:
- an internal type has no XML documentation comments
- an internal member has no XML documentation comments
- a public member in an internal type has no XML documentation comments
- a parameter of an internal member has no XML documentation comments.
AV2310: Avoid inline comments
This analyzer reports when a comment is found inside a method body, except when it is a Resharper suppression, language injection or formatter configuration comment.
AV2318: Don't use comments for tracking work to be done later
This analyzer reports when a comment starts with the word "TODO".
AV2407: Do not use #region
This analyzer reports when a #region
directive is found.