Skip to content

Latest commit

 

History

History
43 lines (31 loc) · 1.2 KB

SA1402.md

File metadata and controls

43 lines (31 loc) · 1.2 KB

SA1402

TypeName SA1402FileMayOnlyContainASingleType
CheckId SA1402
Category Maintainability Rules

Cause

A C# code file contains more than one unique type.

Rule description

A violation of this rule occurs when a C# file contains more than one type. To increase long-term maintainability of the code-base, each type should be placed in its own file, and file names should reflect the name of the type within the file.

It is possible to configure which kind of types this rule should affect. By default, it allows delegates, enums, structs and interfaces to be placed together with a class.

It is also possible to place multiple parts of the same partial type within the same file.

How to fix violations

To fix an instance of this violation, move each type into its own file.

How to suppress violations

[SuppressMessage("StyleCop.CSharp.MaintainabilityRules", "SA1402:FileMayOnlyContainASingleType", Justification = "Reviewed.")]
#pragma warning disable SA1402 // FileMayOnlyContainASingleType
#pragma warning restore SA1402 // FileMayOnlyContainASingleType