Back to Devexpress

Analyzers Library

coderushforroslyn-116021-static-code-analysis-analyzers-library.md

latest25.6 KB
Original Source

Analyzers Library

  • May 21, 2025
  • 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

IDTitleDescriptionC#VB
CRR0001Redundant sub-expressions in a binary operationThe binary operation for identical sub-expressions may contain a redundant expression.
CRR0004If conditional (ternary) operator has identical branchesBoth ternary expression branches are identical.
CRR2007The IIF function has identical resulting argumentsIIF arguments are identical.
CRR0009Subsequent if -statements have identical conditionsSubsequent conditional statements with identical conditions can be combined into a single conditional statement.
CRR0012The logical OR expression has opposite operandsThe logical OR expression has opposite terms. This expression is redundant and can be omitted.
CRR0015Logical OR expression redundancyThe logical OR operation in the expression may be redundant.
CRR0019Expression contains redundant subsetsThe expression contains at least one expression that is a logical subset of another.
CRR0024Increase precision with a built-in constant or callThe number is a low-precision version of a common constant. Consider changing the number to the suggested reference.
CRR0047The type can be moved to a separate fileThe type can be moved to a separate file
CRR0049Environment.NewLine can be usedEnvironment.NewLine can be used. Convert the “\r\n” string value to an Environment.NewLine call.
CRR0050String.Compare can be usedString.Compare can be used. Use the String.Compare() instead of the == operator or “!=” operator.
CRR0051String.IsNullOrEmpty can be usedString.IsNullOrEmpty can be used. Use the string.IsNullOrEmpty method call instead of an expression.
CRR0052String interpolation can be usedString interpolation can be used. Convert an expression into string interpolation.
CRR0053Missing ‘await’Async method should be awaited. Add the await operator to the method call.
CRR0054Async method is called in sync contextThe async method is called from regular synchronous code, and the resulting task is ignored. Add the await operator or assign the task returned from this call to a discard.

Mistake Detection

IDTitleDescriptionC#VB
CRR0002Suspect variable reference in a for -loop conditionThe for -loop’s condition expression may use an incorrect variable.
CRR0003Suspect variable reference in the for -loop iterator sectionThe for -loop’s iterator section may use an incorrect variable.
CRR0006Suspect variable reference in null -check following as-castThe null comparison that follows the typecast may reference an incorrect variable.
CRR0007String format item/argument mismatchThe string.Format arguments may not match specified format items.
CRR0013The member always returns the same valueThe method’s return statements appear to always return the same constant value.
CRR0017Null check follows usageThe expression contains a variable that is checked for null after it is referenced.
CRR0020Integral divide operation cast to floatThe divide-by-integral operation is internally cast to the integral type and rounding a floating point value may produce unexpected results.
CRR0027Possible System.NullReferenceExceptionThe expression is not checked for null and can cause a System.NullReferenceException exception.
CRR0028Empty event handlerThis event handler is empty and can be deleted.
CRR0040The code metric exceeds the specified thresholdThe code element exceeds the specified metric threshold.
CRR0048The type name does not correspond to the file nameThe type name does not correspond to the file name
CRR1000Name does not correspond to Naming ConventionsThe name of the declaration contradicts the existing naming conventions. Use a different name or add a new naming rule.

Async/Await

IDTitleDescriptionC#VB
CRR0029The ConfigureAwait(true) is called implicitlyYou should always call the ConfigureAwait() explicitly because the default behavior may cause a deadlock and should be changed in most cases.
CRR0030Redundant awaitYou can delete the await keyword.
CRR0031The returned Task is nullThe returned Task should never be null , use Task.FromResult() instead.
CRR0033The void async method should be in a try / catch blockThe async method which returns nothing should be in a try / catch block. Otherwise, that method’s exceptions may cause a crash.
CRR0034The asynchronous method should contain the “Async” suffixThe asynchronous method should contain the “Async” suffix.
CRR0035No CancellationToken parameter in the async methodThe async method has no CancellationToken parameter.
CRR0036The await Task.FromResult() expression is redundantThe await keyword is not required for the Task.FromResult expression.
CRR0037Task.Wait is used in an async methodUse the Task.When instead of Task.Wait method in an async method.
CRR0038The CancellationToken parameter is never usedYou should use the CancellationToken in the async method’s body to break the task if cancellation is requested.
CRR0039The await expression without cancellation tokenThe cancellation token should be passed into the await expression.
CRR0041Use Task.Run instead of Task.Factory.StartNewYou should use the Task.Run method instead.

Unused Code Detection

IDTitleDescriptionC#VB
CRR0005The Expression value is always the sameAn expression always resolves to the same value.
CRR0008If -block matches else -blockBoth if statement child blocks appear to be identical.
CRR0010Exception without throwPrecede the instantiation with the throw keyword if you want to throw an exception (so other parts of the program can catch it).
CRR0011Next if-statement has an identical condition that is never reachedThe 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.
CRR0014The variable is assigned twice in successionThe variable receives two assignments in succession. The first assignment may not be needed.
CRR0016Method call’s return value is ignoredThe method call’s return value is not used. This may be unintentional.
CRR0018Suspect assignment reversalThe 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.
CRR0021Subsequent else - if conditions are identicalNested if - else conditions are equivalent. The code in the nested if -block may never be reached.
CRR0022Unreachable 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.
CRR0023Unnecessary conditionalThe conditional expression appears to always evaluate to true. The conditional expressions above are likely to ensure that this conditional never evaluates to false.
CRR0025Unreachable 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).
CRR0026Unused type memberThe member is never used and can be deleted.
CRR0042Unused parameterThis parameter is never used and can be deleted.
CRR0043Unused typeThis type appears to be never used and can be deleted.
CRR0044Unused local variableThe local variable is never used and can be deleted.
CRR0045Local variable can be replaced with discardThe local variable is never used and can be replaced with a discard.
CRR0046Redundant field initializationRemove the redundant initialization to improve code readability.

Spell Check

IDTitleC#VB
CRRSP02[1]A repeated word was found.
CRRSP03[1]A misspelled word was found in the file name.
CRRSP04[1]A misspelled word was found in the XML documentation comment.
CRRSP05[1]A misspelled word was found in the comment.
CRRSP06[1]A misspelled word was found in the string.
CRRSP07[1]A misspelled word was found in the verbatim string.
CRRSP08[1]A misspelled word was found in the public identifier.
CRRSP09[1]A misspelled word was found in the internal identifier.
CRRSP10[1]A misspelled word was found in the protected internal identifier.
CRRSP11[1]A misspelled word was found in the protected identifier.
CRRSP12[1]A misspelled word was found in the private identifier.
CRRSP13[1]A misspelled word was found in the local identifier.

Footnotes

  1. Open the quick actions menu and choose the Spell Checker to see a list of possible corrections.