S101 — Types should be named in PascalCase

Language
C#
Type
Code smell
Severity
Minor
Tags
convention

Why is this an issue?

Shared naming conventions allow teams to collaborate efficiently.

This rule raises an issue when a type name is not PascalCased.

For example, the classes


class my_class {...}
class SOMEName42 {...}

should be renamed to


class MyClass {...}
class SomeName42 {...}

Exceptions


class Some_Name___42 {...} // Compliant in tests
class Some_name___42 {...} // Noncompliant
class Some_Name_XC {...} // Noncompliant because of XC, should be Some_Name_Xc

Allowing custom acronyms

You can configure the rule to ignore certain acronyms by adding a Microsoft Code Analysis Dictionary as an AdditionalFiles item in your project:


<Dictionary>
    <Acronyms>
        <CasingExceptions>
            <Acronym>SEO</Acronym>
            <Acronym>IAC</Acronym>
        </CasingExceptions>
    </Acronyms>
</Dictionary>

<ItemGroup>
    <AdditionalFiles Include="CustomDictionary.xml" />
</ItemGroup>

Resources

Documentation

↑ Back to top