GU0020
November 24, 2021 ยท View on GitHub
Sort properties
| Topic | Value |
|---|---|
| Id | GU0020 |
| Severity | Hidden |
| Enabled | True |
| Category | Gu.Analyzers.Correctness |
| Code | GU0020SortProperties |
Description
Sort properties by StyleCop rules then by mutability.
Order:
- get-only
- Expression body.
- private set;, protected set, internal set, public set.
Motivation
To make it easier to keep an eye on state if any.
How to fix violations
Sort the properties.
Configure severity
Via ruleset file.
Configure the severity per project, for more info see MSDN.
Via #pragma directive.
#pragma warning disable GU0020 // Sort properties
Code violating the rule here
#pragma warning restore GU0020 // Sort properties
Or put this at the top of the file to disable all instances.
#pragma warning disable GU0020 // Sort properties
Via attribute [SuppressMessage].
[System.Diagnostics.CodeAnalysis.SuppressMessage("Gu.Analyzers.Correctness",
"GU0020:Sort properties",
Justification = "Reason...")]