找出重复特性里的 bug

来自 特性
C# 14 / .NET 10 进阶 4分钟 找出 1处问题

找出这个特性契约与消费者之间的不一致。

csharp
using System;
using System.Reflection;

var tag = typeof(BillingService).GetCustomAttribute<TagAttribute>();
Console.WriteLine(tag!.Name);

[Tag("billing"), Tag("critical")]
public sealed class BillingService;

[AttributeUsage(AttributeTargets.Class, AllowMultiple = true)]
public sealed class TagAttribute(string name) : Attribute
{
    public string Name { get; } = name;
}
在试验场中打开
报告错误