FLTFY06: Property is already disregarded from consideration by Fluentify
November 23, 2024 ยท View on GitHub
| Type Name | FLTFY06_IgnoreAttributeAnalyzer |
| Diagnostic Id | FLTFY06 |
| Category | Usage |
| Severity | Info |
| Is Enabled By Default | Yes |
Cause
This property is not considered by Fluentify, so the usage of the Ignore attribute is redundant.
Rule Description
A violation of this rule occurs when a property that is already disregarded by Fluentify is marked with the Ignore attribute, making the usage of the Ignore attribute redundant.
For example:
[Fluentify]
public class Example
{
[Ignore]
public string Property { get; } = string.Empty;
}
In this example, Property is already disregarded by Fluentify as it is deemed to be immutable, so the usage of the Ignore attribute is redundant.
How to Fix Violations
Remove the redundant Ignore attribute from properties that are already disregarded by Fluentify.
For example:
[Fluentify]
public class Example
{
public string Property { get; } = string.Empty;
}
When to Suppress Warnings
Warnings from this rule should be suppressed only if there is a strong justification for the redundant use of the Ignore attribute.
If suppression is desired, one of the following approaches can be used:
[Fluentify]
public class Example
{
#pragma warning disable FLTFY06 // Property is already disregarded from consideration by Fluentify
[Ignore]
public string Property { get; } = string.Empty;
#pragma warning restore FLTFY06 // Property is already disregarded from consideration by Fluentify
}
or alternatively:
[Fluentify]
public class Example
{
[Ignore]
[SuppressMessage("Usage", "FLTFY06:Property is already disregarded from consideration by Fluentify", Justification = "Explanation for suppression")]
public string Property { get; } = string.Empty;
}
How to Disable FLTFY06
It is not recommended to disable the rule, as its presence suggests a misunderstanding by the engineer as to its intended usage.
# Disable FLTFY06: Property is already disregarded from consideration by Fluentify
[*.cs]
dotnet_diagnostic.FLTFY06.severity = none