6.2.12.2. C#

Checks for C# coding style

Nested Rules

C#-BitfieldHasNoPluralS

An enum used as bitfield requires a plural “s”

C#-BracesForSingleStatementBodies

Bodies of control statements like if, for and while require curly braces

C#-CSharpCommentsConvention

Checks for correctly used comment style in C# files

C#-CSharpNamingConvention

Naming conventions for C#

C#-CSharpNoBackwardGotoJumps

A goto statement should not have a target which is defined before the actual goto statement

C#-CSharpNoCatchAllExceptionsClause

Do not use a single clause for catching all exceptions

C#-CSharpNoRefAndOutParameters

Parameters with modifiers ref and out should not be used

C#-CWE

Checks for CWEs in C#

C#-CheckPInvoke

Check whether names and signatures of P/Invoke declarations match their native counterparts

C#-DoNotMixLogicalOperators

The logical operators && and || should not appear together in a full expression

C#-EntityMarker

Reports a (suppressed) issue per entity of a configurable type

C#-EnumeratorRequiresInitialization

Every enumerator has to be initialized

C#-FieldNotPrivateNorProtected

A field should be either private or protected

C#-FilenameNaming

Use only certain characters for file names

C#-ImportCompilerAndAnalyzerDiagnostics

Imports warnings and errors produced by the C# compiler and analyzers

C#-InvalidDependencyPropertyDeclaration

Follow the guidelines for creating dependency properties

C#-MarkupComments

Scans for comments containing a specified regular expression

C#-MaxComplexity

Functions must not exceed cyclomatic complexity limit

C#-MaxConditions

An expression must not have more than N logical operators

C#-MaxNesting

A function must have a nesting level less than or equal N

C#-MaxOneStmtPerLine

Do not put more than one statement in a line

C#-MaxParams

A function must not have more than N parameters

C#-MaximumLineLength

The length of a line of code must not exceed the character limit

C#-MethodShouldBeDeclaredStatic

Instance methods that do not access instance members or other instance methods should be declared static

C#-NoBlankLinesAtBraces

Avoid blank lines after { and before }

C#-NoHidingOfBaseClassMethods

Do not hide a base method by a method in a derived type

C#-NoMagicNumbers

Do not use magic literals

C#-NoTabs

Do not use tabs

C#-NoTrailingWhitespace

Do not use trailing whitespace

C#-SourceFileNaming

Name a source_file for a type defined in it

C#-VirtualCallInConstructor

No virtual calls in constructors or destructors

Options