需要檔案標頭(IDE0073)
財產 | 價值 |
---|---|
規則標識碼 | IDE0073 |
標題 | 需要檔案標題 |
類別 | 風格 |
子類別 | 語言規則(using 指令偏好設定) |
適用的語言 | C# 和 Visual Basic |
選項 | file_header_template |
概述
此樣式規則涉及在原始碼檔案的開始處提供文件標頭。
選項
藉由設定 [file_header_template
] 選項來指定必要的標頭文字。
- 當選項值是非空字串時,需要指定的檔案標頭。
- 當選項值
unset
或空字串時,不需要檔案標頭。
如需設定選項的相關資訊,請參閱 選項格式。
file_header_template
財產 | 價值 | 描述 |
---|---|---|
選項名稱 | 檔案標頭範本 | |
選項值 | 非空白字串,選擇性地包含 {fileName} 佔位元 |
偏好字串做為必要的檔案標頭。 |
unset 或空字串 |
不需要檔案標頭。 | |
預設選項值 | unset |
// file_header_template = Copyright (c) SomeCorp. All rights reserved.\nLicensed under the xyz license.
// Copyright (c) SomeCorp. All rights reserved.
// Licensed under the xyz license.
namespace N1
{
class C1 { }
}
// file_header_template = unset
// OR
// file_header_template =
namespace N2
{
class C2 { }
}
' file_header_template = Copyright (c) SomeCorp. All rights reserved.\nLicensed under the xyz license.
' Copyright (c) SomeCorp. All rights reserved.
' Licensed under the xyz license.
Namespace N1
Class C1
End Class
End Namespace
' file_header_template = unset
' OR
' file_header_template =
Namespace N2
Class C2
End Class
End Namespace
隱藏警告
如果您想要只隱藏單一違規,請將預處理器指示詞新增至原始程式檔以停用,然後重新啟用規則。
#pragma warning disable IDE0073
// The code that's violating the rule is on this line.
#pragma warning restore IDE0073
若要停用檔案、資料夾或項目的規則,請將其嚴重性設定為 組態檔中的 none
。
[*.{cs,vb}]
dotnet_diagnostic.IDE0073.severity = none
若要停用所有程式碼樣式規則,請將類別 Style
的嚴重性設定為 組態檔中的 none
。
[*.{cs,vb}]
dotnet_analyzer_diagnostic.category-Style.severity = none
如需詳細資訊,請參閱 如何在隱藏程式代碼分析警告。