BL0003:具有 CaptureUnmatchedValues 的元件參數有錯誤的型別

規則識別碼 BL0003
類別 使用方式
修正程式是中斷或非中斷 中斷

原因

衍生自使用 CaptureUnmatchedValues= true 註解 ComponentBase 的型別上的參數無法從 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; }
}

隱藏警告的時機

請勿隱藏此規則的警告。