Analyzers Library

The table below lists currently supported analyzers. Refer to the Static Code Analysis article to learn how to use them.

ID Title Description
CRR0001 Redundant sub-expressions in a binary operation The binary operation for identical sub-expressions may contain a redundant expression.
CRR0002 Suspect variable reference in a for-loop condition The for-loop's condition expression may use an incorrect variable.
CRR0003 Suspect variable reference in the for-loop iterator section The for-loop's iterator section may use an incorrect variable.
CRR0004 Ternary expression has identical branches Both ternary expression branches appear to be identical.
CRR0005 Expression value is always the same An expression always resolves to the same value.
CRR0006 Suspect variable reference in null-check following as-cast The null comparison that follows the typecast may reference an incorrect variable.
CRR0007 String format item/argument mismatch The string.Format arguments may not match specified format items.
CRR0008 If-block matches else-block Both if statement child blocks appear to be identical.
CRR0009 Subsequent if-statements have identical conditions The conditional expression in the if-statement can be combined with the next one.
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).
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.
CRR0012 Logical OR expression has opposite operands The logical OR expression has opposite terms. Check both operands to make sure they are expressed as intended.
CRR0013 Member always returns the same value The method's return statements appear to always return the same constant value.
CRR0014 Variable is assigned twice in succession The variable receives two assignments in succession. The first assignment may not be needed.
CRR0015 Logical OR expression redundancy The logical OR operation in the expression may be redundant.
CRR0016 Method call's return value is ignored The method call's return value is not used. This may be unintentional.
CRR0017 Null check follows usage The expression contains a variable that is checked for null after it is referenced.
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.
CRR0019 Expression contains redundant subsets The expression contains at least one expression that is a logical subset of another.
CRR0020 Integral divide operation cast to float The divide-by-integral operation internally casts to the integral type and rounding a floating point value may produce unexpected results.
CRR0021 Subsequent else-if conditions are identical Nested if-else conditions are equivalent. The code in the nested if-block may never be reached.
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.
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.
CRR0024 Increase precision with a built-in constant or call The number appears to be a low-precision version of a common constant. Consider changing the number to the suggested reference.
CRR0025 Unreachable conditional code block (the inversed condition is already satisfied) The inverse of the current expression appears to be already satisfied in a parent conditional, so this expression likely always resolves to false (rendering its code block is never reached).
CRR0026 Unused member The member is never used and can be deleted.
CRR0027 Possible System.NullReferenceException The code is may cause System.NullReferenceException.
CRR0028 Empty event handler This event handler is empty and can be deleted.
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.
CRR0030 Redundant await You can delete the await keyword.
CRR0031 The returned Task is null The returned Task should never be null, use Task.FromResult() instead.
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.
CRR0035 No CancellationToken parameter in the async method The async method has no CancellationToken parameter.
CRR0036 The await Task.FromResult() expression is redundant The await keyword is not required for the Task.FromResult expression.
CRR0037 Task.Wait is used in an async method Use the Task.When instead of Task.Wait method in an async method.
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.
CRR0039 The await expression without cancellation token The cancellation token should be passed into the await expression.
CRR0040 A code metric exceeds the specified threshold The code element exceeds a code metric's specified threshold .
CRR0041 The Task.Factory.StartNew method can be unsafe You should use the Task.Run method instead.
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.
CRRSP01 Misspelled word has been found A misspelled word has been found. You can open the quick actions menu to see a list of possible corrections.
CRRSP02 Repeated word has been found A repeated word has been found. You can open the quick actions menu to see a list of possible corrections.