ReSharper 2026.1 Help

コードインスペクション: null 非許容または必須のメンバーがコンストラクターの終了時に初期化されていない

このコードインスペクションは、 [NotNullAttribute] が付与されたフィールドまたはプロパティの契約が機能しない可能性があることを警告します。オブジェクト生成時にこのメンバーが null のままの場合があります。

以下の例では、ReSharper が PlaceOfBirth が初期化されていないことを警告します:

class Person { [NotNull] public string Name { get; set; } [NotNull] public string PlaceOfBirth { get; set; } // Warning: Member with '[NotNull]' attribute is not initialized public Person([NotNull] string name, string placeOfBirth) { Name = name; Console.WriteLine(@"Name: {0}, Place of birth: {1}", name, placeOfBirth); } }

このインスペクションは、メンバーの使用箇所をコンストラクター内のコードだけチェックします。 そのため、コンストラクター内で呼び出す他のメソッドでメンバーを初期化しても、ReSharper は初期化されていないメンバーとして警告します。 この場合は、次のコメントでこのインスペクションを抑制してください: // ReSharper disable once NotNullMemberIsNotInitialized

2026 年 6 月 12 日