Type Name | FLTFY03_DescriptorAttributeAnalyzer |
Diagnostic Id | FLTFY03 |
Category | Usage |
Severity | Info |
Is Enabled By Default | Yes |
The property and its Descriptor
are not considered by Fluentify because the type has not been annotated with the Fluentify
attribute.
A violation of this rule occurs when a property is marked with the Descriptor
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 Descriptor
attribute redundant.
For example:
public class Example
{
[Descriptor("Assign")]
public string Property { get; set; }
}
In this example, the Descriptor
attribute on Property
, and the class
itself, will be ignored by Fluentify
, suggesting a misunderstanding by the engineer as to its intended usage.
Reevaluate the decision to apply the Discriptor
attribute. If the Discriptor
attribute usage is deemed correct, annotate the type with the Fluentify
attribute, otherwise remove the Descriptor
attribute.
For example:
[Fluentify]
public class Example
{
[Descriptor("Assign")]
public string Property { get; set; }
}
or alternatively:
public class Example
{
public string Property { get; set; }
}
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 Discriptor
attribute is applied.
If suppression is desired, one of the following approaches can be used:
[Fluentify]
public class Example
{
#pragma warning disable FLTFY03 // Type does not utilize Fluentify
[Descriptor("Assign")]
public string Property { get; set; }
#pragma warning restore FLTFY03 // Type does not utilize Fluentify
}
or alternatively:
public class Example
{
[Descriptor("Assign")]
[SuppressMessage("Usage", "FLTFY03:Type does not utilize Fluentify", Justification = "Explanation for suppression")]
public string Property { get; set; }
}
It is not recommended to disable the rule, as this may result in some confusion if expected extension methods are not present.
# Disable FLTFY03: Type does not utilize Fluentify
[*.cs]
dotnet_diagnostic.FLTFY03.severity = none