Type Name | VALFY02_AttributeAnalyzer |
Diagnostic Id | VALFY02 |
Category | Usage |
Severity | Warning |
Is Enabled By Default | Yes |
The declaration for a class
annotated with the Valuify
attribute is not marked as partial.
A violation of this rule occurs when a class
is not marked with the partial
keyword when the Valuify
attribute is applied. The partial
keyword is needed to facilitate the generation of additional content within the assembly for the type.
For example:
[Valuify]
public class Example
{
public int Value { get; set; }
}
In this example, Example
is excluded from Valuify's consideration as the declaration is not partial
and as a result, no additional content can be generated without resulting in an compilation failure.
Reevaluate the decision to apply the Valuify
attribute. If the intention is correct, add the partial
keyword to the declaration, otherwise remove the Valuify
attribute.
For example:
[Valuify]
public partial class Example
{
public int Value { get; set; }
}
or alternatively:
public class Example
{
public int Value { get; set; }
}
It is not recommended to suppress the rule. Instead, it is suggested that the usage of the Valuify
attribute be reevaluated.
If suppression is desired, one of the following approaches can be used:
#pragma warning disable VALFY02 // Type is not Partial
[Valuify]
public class Example
{
public int Value { get; set; }
}
#pragma warning restore VALFY02 // Type is not Partial
or alternatively:
[Valuify]
[SuppressMessage("Design", "VALFY02:Type is not Partial", Justification = "Explanation for suppression")]
public class Example
{
public int Value { get; set; }
}
It is not recommended to disable the rule, as this may result in some confusion if the expected equality behavior is not observed.
# Disable VALFY02: Descriptor is disregarded from consideration by Valuify
[*.cs]
dotnet_diagnostic.VALFY02.severity = none