MFTV0005: Fix or remove the invalid value tag annotation
editCause
A [ValueTag] attribute or a ValueTag comment cannot be applied, so it tags nothing:
public sealed class Shipment
{
[ValueTag("")] public Guid Id { get; set; } // MFTV0005, the tag is empty
[ValueTag(Key = "OrderId")] public Guid OrderId { get; set; } // MFTV0005, Key only applies to dictionaries
[field: ValueTag("CarrierId")] public Guid CarrierId { get; set; } // MFTV0005, the backing field is not analyzed
/* ValueTag=ProjectId */ public Guid ProjectId { get; set; } // MFTV0005, comments only tag local variables
public void M()
{
Guid /* ValueTag= */ id = Guid.NewGuid(); // MFTV0005, the comment cannot be parsed
}
}The message explains what is wrong. The rule reports:
- an empty tag, or an attribute that declares no tag,
KeyandValueon something other than a dictionary,[ValueTag("Tag")]on a dictionary, and an attribute that combines tags withKeyandValue,[field: ValueTag]on a property, whose backing field is not analyzed,- an
[assembly: ValueTag]attribute that does not name a member, that names a missing member, or that usesKeyandValue, and theValueTag(typeof(...), "Member", ...)form on something other than the assembly, - a comment that cannot be parsed, or that does not tag a local variable: a comment on a field, inside an initializer, at the end of a line, or before a statement that declares no variable,
- a comment in the type arguments of a field, a parameter, a generic method, or a type that is neither a collection, a dictionary, nor a wrapper, and
/* ValueTag Key=... */in a type argument, - a comment that another comment overrides for every variable it could tag, with other tags.
How to fix
Fix the annotation as the message explains:
public sealed class Shipment
{
[ValueTag("ShipmentId")] public Guid Id { get; set; }
[ValueTag("OrderId")] public Guid OrderId { get; set; }
[ValueTag("CarrierId")] public Guid CarrierId { get; set; }
[ValueTag("ProjectId")] public Guid ProjectId { get; set; }
public void M()
{
Guid /* ValueTag=ShipmentId */ id = Guid.NewGuid();
}
}The code fix removes the annotation when removing it is safe. See Tagging values and Tagging local variables for the valid forms.