Skip to main content

Analyzers Library

  • 7 minutes to read

The table below lists supported analyzers. Refer to the Static Code Analysis article for information on how to use them.

Code Complexity Analysis

ID Title Description C# VB
CRR0001 Redundant sub-expressions in a binary operation The binary operation for identical sub-expressions may contain a redundant expression. CRR_IconPassed CRR_IconPassed
CRR0004 If conditional (ternary) operator has identical branches Both ternary expression branches are identical. CRR_IconPassed CRR_IconPassed
CRR2007 IIF function has identical resulting arguments IIF arguments are identical. CRR_IconPassed
CRR0009 Subsequent if-statements have identical conditions Subsequent conditional statements with identical conditions can be combined into a single conditional statement. CRR_IconPassed CRR_IconPassed
CRR0012 Logical OR expression has opposite operands The logical OR expression has opposite terms. This expression is redundant and can be omitted. CRR_IconPassed CRR_IconPassed
CRR0015 Logical OR expression redundancy The logical OR operation in the expression may be redundant. CRR_IconPassed CRR_IconPassed
CRR0019 Expression contains redundant subsets The expression contains at least one expression that is a logical subset of another. CRR_IconPassed CRR_IconPassed
CRR0024 Increase precision with a built-in constant or call The number is a low-precision version of a common constant. Consider changing the number to the suggested reference. CRR_IconPassed CRR_IconPassed
CRR0047 The type can be moved to a separate file The type can be moved to a separate file CRR_IconPassed CRR_IconPassed
CRR0049 Environment.NewLine can be used Environment.NewLine can be used. Convert the “\r\n” string value to an Environment.NewLine call. CRR_IconPassed CRR_IconPassed
CRR0050 String.Compare can be used String.Compare can be used. Use the String.Compare() instead of the == operator or “!=” operator. CRR_IconPassed CRR_IconPassed
CRR0051 String.IsNullOrEmpty can be used String.IsNullOrEmpty can be used. Use the string.IsNullOrEmpty method call instead of an expression. CRR_IconPassed CRR_IconPassed
CRR0052 String interpolation can be used String interpolation can be used. Convert an expression into string interpolation. CRR_IconPassed CRR_IconPassed

Mistake Detection

ID Title Description C# VB
CRR0002 Suspect variable reference in a for-loop condition The for-loop’s condition expression may use an incorrect variable. CRR_IconPassed
CRR0003 Suspect variable reference in the for-loop iterator section The for-loop’s iterator section may use an incorrect variable. CRR_IconPassed
CRR0006 Suspect variable reference in null-check following as-cast The null comparison that follows the typecast may reference an incorrect variable. CRR_IconPassed CRR_IconPassed
CRR0007 String format item/argument mismatch The string.Format arguments may not match specified format items. CRR_IconPassed CRR_IconPassed
CRR0013 The member always returns the same value The method’s return statements appear to always return the same constant value. CRR_IconPassed CRR_IconPassed
CRR0017 Null check follows usage The expression contains a variable that is checked for null after it is referenced. CRR_IconPassed CRR_IconPassed
CRR0020 Integral divide operation cast to float The divide-by-integral operation is internally cast to the integral type and rounding a floating point value may produce unexpected results. CRR_IconPassed CRR_IconPassed
CRR0027 Possible System.NullReferenceException The expression is not checked for null and can cause a System.NullReferenceException exception. CRR_IconPassed CRR_IconPassed
CRR0028 Empty event handler This event handler is empty and can be deleted. CRR_IconPassed CRR_IconPassed
CRR0040 A code metric exceeds the specified threshold The code element exceeds the specified metric threshold. CRR_IconPassed CRR_IconPassed
CRR0048 The type name does not correspond to the file name The type name does not correspond to the file name CRR_IconPassed CRR_IconPassed
CRR1000 Name does not correspond to Naming Conventions The name of the declaration contradicts the existing naming conventions. Use a different name or add a new naming rule. CRR_IconPassed CRR_IconPassed

Async/Await

ID Title Description C# VB
CRR0029 The ConfigureAwait(true) is called implicitly You should always call the ConfigureAwait() explicitly because the default behavior may cause a deadlock and should be changed in most cases. CRR_IconPassed CRR_IconPassed
CRR0030 Redundant await You can delete the await keyword. CRR_IconPassed CRR_IconPassed
CRR0031 The returned Task is null The returned Task should never be null, use Task.FromResult() instead. CRR_IconPassed CRR_IconPassed
CRR0033 The void async method should be in a try/catch block The async method which returns nothing should be in a try/catch block. Otherwise, that method’s exceptions may cause a crash. CRR_IconPassed CRR_IconPassed
CRR0034 The asynchronous method should contain the “Async” suffix The asynchronous method should contain the “Async” suffix. CRR_IconPassed CRR_IconPassed
CRR0035 No CancellationToken parameter in the async method The async method has no CancellationToken parameter. CRR_IconPassed CRR_IconPassed
CRR0036 The await Task.FromResult() expression is redundant The await keyword is not required for the Task.FromResult expression. CRR_IconPassed CRR_IconPassed
CRR0037 Task.Wait is used in an async method Use the Task.When instead of Task.Wait method in an async method. CRR_IconPassed CRR_IconPassed
CRR0038 The CancellationToken parameter is never used You should use the CancellationToken in the async method’s body to break the task if cancellation is requested. CRR_IconPassed CRR_IconPassed
CRR0039 The await expression without cancellation token The cancellation token should be passed into the await expression. CRR_IconPassed CRR_IconPassed
CRR0041 Use Task.Run instead of Task.Factory.StartNew You should use the Task.Run method instead. CRR_IconPassed CRR_IconPassed

Unused Code Detection

ID Title Description C# VB
CRR0005 Expression value is always the same An expression always resolves to the same value. CRR_IconPassed CRR_IconPassed
CRR0008 If-block matches else-block Both if statement child blocks appear to be identical. CRR_IconPassed CRR_IconPassed
CRR0010 Exception without throw Precede the instantiation with the throw keyword if you want to throw an exception (so other parts of the program can catch it). CRR_IconPassed CRR_IconPassed
CRR0011 Next if-statement has an identical condition that is never reached The next if-statement has the same condition as the current one. However, this if-statement breaks the program flow and exits the method block. The next if-statement’s body is never reached. CRR_IconPassed CRR_IconPassed
CRR0014 The variable is assigned twice in succession The variable receives two assignments in succession. The first assignment may not be needed. CRR_IconPassed CRR_IconPassed
CRR0016 Method call’s return value is ignored The method call’s return value is not used. This may be unintentional. CRR_IconPassed CRR_IconPassed
CRR0018 Suspect assignment reversal The assignment reversal is unusual and may be an attempt to bypass side-effects occurring between two assignment statements. This may also indicate brittle code, which cannot be easily maintained. CRR_IconPassed CRR_IconPassed
CRR0021 Subsequent else-if conditions are identical Nested if-else conditions are equivalent. The code in the nested if-block may never be reached. CRR_IconPassed CRR_IconPassed
CRR0022 Unreachable conditional code block (a similar condition in the else branch) The conditional expression appears to always evaluate to false. You should check the conditionals above for similar expressions that would prevent the current conditional from being evaluated to true. CRR_IconPassed CRR_IconPassed
CRR0023 Unnecessary conditional The conditional expression appears to always evaluate to true. The conditional expressions above are likely to ensure that this conditional never evaluates to false. CRR_IconPassed CRR_IconPassed
CRR0025 Unreachable conditional code block (the inversed condition is already satisfied) The inverse of the current expression is satisfied in a parent conditional - this expression resolves to false (rendering its code block is never reached). CRR_IconPassed CRR_IconPassed
CRR0026 Unused type member The member is never used and can be deleted. CRR_IconPassed CRR_IconPassed
CRR0042 Unused parameter This parameter is never used and can be deleted. CRR_IconPassed CRR_IconPassed
CRR0043 Unused type This type appears to be never used and can be deleted. CRR_IconPassed CRR_IconPassed
CRR0044 Unused local variable The local variable is never used and can be deleted. CRR_IconPassed CRR_IconPassed
CRR0045 Local variable can be replaced with discard The local variable is never used and can be replaced with a discard. CRR_IconPassed CRR_IconPassed
CRR0046 Redundant field initialization Remove the redundant initialization to improve code readability. CRR_IconPassed CRR_IconPassed

Spell Check

ID Title C# VB
CRRSP02[1] A repeated word was found. CRR_IconPassed CRR_IconPassed
CRRSP03[1] A misspelled word was found in the file name. CRR_IconPassed CRR_IconPassed
CRRSP04[1] A misspelled word was found in the XML documentation comment. CRR_IconPassed CRR_IconPassed
CRRSP05[1] A misspelled word was found in the comment. CRR_IconPassed CRR_IconPassed
CRRSP06[1] A misspelled word was found in the string. CRR_IconPassed CRR_IconPassed
CRRSP07[1] A misspelled word was found in the verbatim string. CRR_IconPassed CRR_IconPassed
CRRSP08[1] A misspelled word was found in the public identifier. CRR_IconPassed CRR_IconPassed
CRRSP09[1] A misspelled word was found in the internal identifier. CRR_IconPassed CRR_IconPassed
CRRSP10[1] A misspelled word was found in the protected internal identifier. CRR_IconPassed CRR_IconPassed
CRRSP11[1] A misspelled word was found in the protected identifier. CRR_IconPassed CRR_IconPassed
CRRSP12[1] A misspelled word was found in the private identifier. CRR_IconPassed CRR_IconPassed
CRRSP13[1] A misspelled word was found in the local identifier. CRR_IconPassed CRR_IconPassed
Footnotes
  1. Open the quick actions menu and choose the Spell Checker to see a list of possible corrections.