単純な 'using' ステートメントを使用する (IDE0063)
プロパティ | 値 |
---|---|
ルール ID | IDE0063 |
Title | 単純な using ステートメントを使用する |
カテゴリ | スタイル |
Subcategory | 言語規則 (コード ブロック基本設定) |
該当言語 | C# 8.0 以降 |
[オプション] | csharp_prefer_simple_using_statement |
概要
このスタイル規則は、中かっこを使わない using
ステートメントの使用に関するもので、using
宣言とも呼ばれます。 この代替構文は、C# 8.0 で導入されました。
オプション
オプションでは、規則を適用する動作を指定します。 オプションの構成の詳細については、「オプションの書式」を参照してください。
csharp_prefer_simple_using_statement
プロパティ | 値 | 説明 |
---|---|---|
オプション名 | csharp_prefer_simple_using_statement | |
オプションの値 | true |
using 宣言を使います |
false |
中かっこがある using ステートメントを使います |
|
既定のオプションの値 | true |
// csharp_prefer_simple_using_statement = true
using var a = b;
// csharp_prefer_simple_using_statement = false
using (var a = b) { }
警告を抑制する
単一の違反だけを抑制する場合は、ソース ファイルにプリプロセッサ ディレクティブを追加して無効にしてから、規則を再度有効にします。
#pragma warning disable IDE0063
// The code that's violating the rule is on this line.
#pragma warning restore IDE0063
ファイル、フォルダー、またはプロジェクトのルールを無効にするには、構成ファイルでその重要度を none
に設定します。
[*.{cs,vb}]
dotnet_diagnostic.IDE0063.severity = none
すべてのコード スタイル規則を無効にするには、構成ファイルでカテゴリ Style
の重要度を none
に設定します。
[*.{cs,vb}]
dotnet_analyzer_diagnostic.category-Style.severity = none
詳細については、「コード分析の警告を抑制する方法」を参照してください。
関連項目
Collaborate with us on GitHub
The source for this content can be found on GitHub, where you can also create and review issues and pull requests. For more information, see our contributor guide.
.NET feedback
The .NET documentation is open source. Provide feedback here.
フィードバック
フィードバックの送信と表示