Skip to content

Latest commit

 

History

History
54 lines (39 loc) · 1.74 KB

WPF0150.md

File metadata and controls

54 lines (39 loc) · 1.74 KB

WPF0150

Use nameof() instead of literal.

Topic Value
Id WPF0150
Severity Warning
Enabled True
Category WpfAnalyzers.Correctness
Code AttributeAnalyzer
RegistrationAnalyzer
RoutedCommandCreationAnalyzer
RoutedEventBackingFieldOrPropertyAnalyzer

Description

Use nameof() as it is less fragile than string literal.

Motivation

ADD MOTIVATION HERE

How to fix violations

ADD HOW TO FIX VIOLATIONS HERE

Configure severity

Via ruleset file.

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

Via #pragma directive.

#pragma warning disable WPF0150 // Use nameof() instead of literal.
Code violating the rule here
#pragma warning restore WPF0150 // Use nameof() instead of literal.

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

#pragma warning disable WPF0150 // Use nameof() instead of literal.

Via attribute [SuppressMessage].

[System.Diagnostics.CodeAnalysis.SuppressMessage("WpfAnalyzers.Correctness", 
    "WPF0150:Use nameof() instead of literal.", 
    Justification = "Reason...")]