Skip to content

Latest commit

 

History

History
107 lines (83 loc) · 2.51 KB

FLTFY05.md

File metadata and controls

107 lines (83 loc) · 2.51 KB

FLTFY05: Type does not utilize Fluentify

Type Name FLTFY05_IgnoreAttributeAnalyzer
Diagnostic Id FLTFY05
Category Usage
Severity Info
Is Enabled By Default Yes

Cause

The property is not considered by Fluentify because the type has not been annotated with the Fluentify attribute.

Rule Description

A violation of this rule occurs when a property is marked with the Ignore attribute, but the containing type, be it a class or record, is not annotated with the Fluentify attribute. Therefore, no extension methods will be generated, making use of the Ignore attribute redundant.

For example:

public class Example
{
    [Ignore]
    public string Property { get; set; }
}

In this example, the Ignore attribute on Property, and the class itself, will be ignored by Fluentify, suggesting a misunderstanding by the engineer as to its intended usage.

How to Fix Violations

Reevaluate the decision to apply the Ignore attribute. If the Ignore attribute usage is deemed correct, annotate the type with the Fluentify attribute, otherwise remove the Ignore attribute.

For example:

[Fluentify]
public class Example
{
    [Ignore]
    public string Property { get; set; }
}

or alternatively:

public class Example
{
    public string Property { get; set; }
}

When to Suppress Warnings

Warnings from this rule should be suppressed only if there is a strong justification for not using the Fluentify attribute on the containing type when the Ignore attribute is applied.

If suppression is desired, one of the following approaches can be used:

[Fluentify]
public class Example
{
    #pragma warning disable FLTFY05 // Type does not utilize Fluentify
    
    [Ignore]
    public string Property { get; set; }
    
    #pragma warning restore FLTFY05 // Type does not utilize Fluentify
}

or alternatively:

public class Example
{
    [Ignore]
    [SuppressMessage("Usage", "FLTFY05:Type does not utilize Fluentify", Justification = "Explanation for suppression")]
    public string Property { get; set; }
}

How to Disable FLTFY05

It is not recommended to disable the rule, as this may result in some confusion if expected extension methods are not present.

# Disable FLTFY05: Type does not utilize Fluentify
[*.cs]
dotnet_diagnostic.FLTFY05.severity = none