次の方法で共有


明示的に指定されたタプル名を使用する (IDE0033)

財産 価値
ルール ID IDE0033
タイトル 明示的に提供されたタプル名を使用する
カテゴリー スタイル
Subcategory 言語規則 (式レベル基本設定)
適用可能な言語 C# と Visual Basic
オプション dotnet_style_explicit_tuple_names

概要

このスタイル ルールは、タプル フィールドにアクセスするときに明示的な タプル 名と暗黙的な 'ItemX' プロパティの使用に関するものです。

オプション

オプションでは、ルールを適用する動作を指定します。 オプションの構成については、「オプション形式 を参照してください。

dotnet_style_explicit_tuple_names

財産 価値 説明
オプション名 dotnet_style_explicit_tuple_names
オプションの値 true タプル名をItemXプロパティより優先する
false タプル名よりも ItemX プロパティを優先する
既定のオプション値 true
// dotnet_style_explicit_tuple_names = true
(string name, int age) customer = GetCustomer();
var name = customer.name;

// dotnet_style_explicit_tuple_names = false
(string, int) customer = GetCustomer();
var name = customer.Item1;
 ' dotnet_style_explicit_tuple_names = true
Dim customer As (name As String, age As Integer) = GetCustomer()
Dim name = customer.name

' dotnet_style_explicit_tuple_names = false
Dim customer As (String, Integer) = GetCustomer()
Dim name = customer.Item1

警告を抑制する

1 つの違反のみを抑制する場合は、ソース ファイルにプリプロセッサ ディレクティブを追加して無効にしてから、ルールを再度有効にします。

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

ファイル、フォルダー、またはプロジェクトのルールを無効にするには、その重大度を 構成ファイルnone に設定します。

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

すべてのコード スタイルルールを無効にするには、カテゴリ Style の重大度を、構成ファイルnone するように設定します。

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

詳細については、「コード分析の警告を抑制する方法」を参照してください。

関連項目