View on GitHub

Arnolyzer

Clean-code Roslyn-based analyzer for C# 6

Arnolyzer on nuget

AA2104 - File Must Only Contain One Type Definition

Report code: AA2104-FileMustOnlyContainOneTypeDefinition

Summary

Status Implemented
Description To comply with the single responsibility principle, a file should only contain one non-private type definition.
Category Single Responsibilty Analyzers
Enabled by default: Yes
Severity: Error

Cause

A file that contains more than one class, enum or interface definition inherently contains more than one responsibility.

In addition, the discoverability of these types is made harder as the pattern of matching type and file names breaks down, as there’s no clear way of naming the file to match the contents.

How to fix violations

There currently aren’t any implemented code-fixes for this rule.

How to suppress violations

This rule cannot be suppressed.