GU0022

November 24, 2021 ยท View on GitHub

Use get-only

TopicValue
IdGU0022
SeverityHidden
EnabledTrue
CategoryGu.Analyzers.Correctness
CodeGU0022UseGetOnly

Description

Use get-only.

Motivation

The property is only assigned in constructor or in property initializer and can be made get-only.

How to fix violations

Use the code fix.

Configure severity

Via ruleset file.

Configure the severity per project, for more info see MSDN.

Via #pragma directive.

#pragma warning disable GU0022 // Use get-only
Code violating the rule here
#pragma warning restore GU0022 // Use get-only

Or put this at the top of the file to disable all instances.

#pragma warning disable GU0022 // Use get-only

Via attribute [SuppressMessage].

[System.Diagnostics.CodeAnalysis.SuppressMessage("Gu.Analyzers.Correctness", 
    "GU0022:Use get-only", 
    Justification = "Reason...")]