MFTV0008: Tag the return value with the tag of the returned values

edit

Cause

Every value returned by a method, a local function, or a property getter has the same tag, but the return value is not tagged. The callers lose the tag, so the analyzer cannot check what they do with the result. Its severity is Info:

public sealed class OrderLookup
{
    public Guid GetFirstOrderId(List<Order> orders) => orders[0].Id; // MFTV0008
}
Every value returned by method 'OrderLookup.GetFirstOrderId' is [ValueTag("OrderId")]; add [return: ValueTag("OrderId")] so the tag flows to the callers

The rule is only reported for tags written by the user, not for tags inferred from a naming convention. It is not reported for overrides and implementations, such as ToString, which get their tags from the base member.

How to fix

Tag the return value, or the property. The code fix adds the attribute:

public sealed class OrderLookup
{
    [return: ValueTag("OrderId")]
    public Guid GetFirstOrderId(List<Order> orders) => orders[0].Id;
}