BL0003:CaptureUnmatchedValues 的组件参数类型错误

价值
规则 ID BL0003
类别 Usage
修复是中断修复还是非中断修复 重大

原因

派生自 ComponentBase 且带有 CaptureUnmatchedValues= true 批注的类型的参数不能被 Dictionary<string, object> 分配。

规则说明

CaptureUnmatchedValues = true 批注的参数必须能够接收值 Dictionary<string, object>

@code
{
    [Parameter(CaptureUnmatchedValues = true)] public IDictionary<string, string> Attributes { get; set; }
}

如何修复违规行为

将参数的类型更改为任一 IDictionary<string, object>Dictionary<string, object>

@code
{
    [Parameter(CaptureUnmatchedValues = true)] public IDictionary<string, object> Attributes { get; set; }
}

何时禁止显示警告

不禁止显示此规则发出的警告。