共用方式為


使用 Copilot 來實現 (IDE3000)

房產 價值觀
規則識別碼 IDE3000
職稱 使用 Copilot 實作
類別 CodeQuality
子類別 其他規則
適用語言 C#

概觀

此規則會識別包含 NotImplementedException 的方法,並提供使用 GitHub Copilot 來實作方法的燈泡提示。 當您使用此程式代碼修正時,GitHub Copilot 會根據其簽章、類型內容和其他可用資訊,為方法產生實作。

備註

即使您 在組建上啟用程式代碼樣式規則,也不會啟用此規則。 它只會呈現在 IDE 中。

選項

此規則沒有相關聯的程式代碼樣式選項。

範例

// Code with NotImplementedException
public class Calculator
{
    public int Add(int a, int b)
    {
        // IDE3000: Implement with Copilot.
        throw new NotImplementedException();
    }
}

當您點選燈泡建議時,請選取「使用 Copilot 實作」選項,以提示 GitHub Copilot 生成該方法的實作。

隱藏警告

如果您想要只隱藏單一違規,請將預處理器指示詞新增至原始程式檔以停用,然後重新啟用規則。

#pragma warning disable IDE3000
// The code that's violating the rule is on this line.
#pragma warning restore IDE3000

若要停用檔案、資料夾或項目的規則,請在none中將其嚴重性設為

[*.{cs,vb}]
dotnet_diagnostic.IDE3000.severity = none

若要停用所有程式碼樣式規則,請將類別 Style 的嚴重性設定為 組態檔中的 none

[*.{cs,vb}]
dotnet_analyzer_diagnostic.category-Style.severity = none

如需詳細資訊,請參閱 如何隱藏程式代碼分析警告

另請參閱