Skip to content

Latest commit

 

History

History
55 lines (40 loc) · 1.26 KB

GU0020.md

File metadata and controls

55 lines (40 loc) · 1.26 KB

GU0020

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:

  1. get-only
  2. Expression body.
  3. 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...")]