diff --git a/src/Analyzers/CSharp/CodeFixes/MakeMemberRequired/CSharpMakeMemberRequiredCodeFixProvider.cs b/src/Analyzers/CSharp/CodeFixes/MakeMemberRequired/CSharpMakeMemberRequiredCodeFixProvider.cs
index 039b5cd452721..8fdf1e135ea86 100644
--- a/src/Analyzers/CSharp/CodeFixes/MakeMemberRequired/CSharpMakeMemberRequiredCodeFixProvider.cs
+++ b/src/Analyzers/CSharp/CodeFixes/MakeMemberRequired/CSharpMakeMemberRequiredCodeFixProvider.cs
@@ -24,7 +24,7 @@ namespace Microsoft.CodeAnalysis.CSharp.CodeFixes.MakeMemberRequired;
[ExtensionOrder(Before = PredefinedCodeFixProviderNames.DeclareAsNullable)]
internal sealed class CSharpMakeMemberRequiredCodeFixProvider : SyntaxEditorBasedCodeFixProvider
{
- private const string CS8618 = nameof(CS8618); // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable.
+ private const string CS8618 = nameof(CS8618); // Non-nullable variable must contain a non-null value when exiting constructor. Consider adding the required modifier or declaring it as nullable.
[ImportingConstructor]
[Obsolete(MefConstruction.ImportingConstructorMessage, error: true)]
diff --git a/src/Compilers/CSharp/Portable/CSharpResources.resx b/src/Compilers/CSharp/Portable/CSharpResources.resx
index 1c597710b3960..80439b9ffcd43 100644
--- a/src/Compilers/CSharp/Portable/CSharpResources.resx
+++ b/src/Compilers/CSharp/Portable/CSharpResources.resx
@@ -5717,10 +5717,10 @@ To remove the warning, you can use /reference instead (set the Embed Interop Typ
Nullability of reference types in type of parameter doesn't match implemented member (possibly because of nullability attributes).
- Non-nullable {0} '{1}' must contain a non-null value when exiting constructor. Consider declaring the {0} as nullable.
+ Non-nullable {0} '{1}' must contain a non-null value when exiting constructor. Consider adding the required modifier or declaring the {0} as nullable.
- Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable.
+ Non-nullable field must contain a non-null value when exiting constructor. Consider adding the required modifier or declaring as nullable.Nullability of reference types in value of type '{0}' doesn't match target type '{1}'.
diff --git a/src/Compilers/CSharp/Portable/xlf/CSharpResources.cs.xlf b/src/Compilers/CSharp/Portable/xlf/CSharpResources.cs.xlf
index 52bc7a06848ef..f71d5aa7b876c 100644
--- a/src/Compilers/CSharp/Portable/xlf/CSharpResources.cs.xlf
+++ b/src/Compilers/CSharp/Portable/xlf/CSharpResources.cs.xlf
@@ -5079,13 +5079,13 @@
- Non-nullable {0} '{1}' must contain a non-null value when exiting constructor. Consider declaring the {0} as nullable.
- Proměnná {0} {1}, která nemůže být null, musí při ukončování konstruktoru obsahovat hodnotu, která není null. Zvažte možnost deklarovat {0} jako proměnnou s možnou hodnotou null.
+ Non-nullable {0} '{1}' must contain a non-null value when exiting constructor. Consider adding the required modifier or declaring the {0} as nullable.
+ Proměnná {0} {1}, která nemůže být null, musí při ukončování konstruktoru obsahovat hodnotu, která není null. Zvažte možnost deklarovat {0} jako proměnnou s možnou hodnotou null.
- Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable.
- Pole, které nemůže být null, musí při ukončování konstruktoru obsahovat hodnotu, která není null. Zvažte možnost deklarovat ho jako pole s možnou hodnotou null.
+ Non-nullable field must contain a non-null value when exiting constructor. Consider adding the required modifier or declaring as nullable.
+ Pole, které nemůže být null, musí při ukončování konstruktoru obsahovat hodnotu, která není null. Zvažte možnost deklarovat ho jako pole s možnou hodnotou null.
diff --git a/src/Compilers/CSharp/Portable/xlf/CSharpResources.de.xlf b/src/Compilers/CSharp/Portable/xlf/CSharpResources.de.xlf
index 31fdb8ad5d94e..7308fc8221c1c 100644
--- a/src/Compilers/CSharp/Portable/xlf/CSharpResources.de.xlf
+++ b/src/Compilers/CSharp/Portable/xlf/CSharpResources.de.xlf
@@ -5079,13 +5079,13 @@
- Non-nullable {0} '{1}' must contain a non-null value when exiting constructor. Consider declaring the {0} as nullable.
- Non-Nullable-{0} "{1}" muss beim Beenden des Konstruktors einen Wert ungleich NULL enthalten. Erwägen Sie eine Deklaration von "{0}" als Nullable.
+ Non-nullable {0} '{1}' must contain a non-null value when exiting constructor. Consider adding the required modifier or declaring the {0} as nullable.
+ Non-Nullable-{0} "{1}" muss beim Beenden des Konstruktors einen Wert ungleich NULL enthalten. Erwägen Sie eine Deklaration von "{0}" als Nullable.
- Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable.
- Ein Non-Nullable-Feld muss beim Beenden des Konstruktors einen Wert ungleich NULL enthalten. Erwägen Sie die Deklaration als Nullable.
+ Non-nullable field must contain a non-null value when exiting constructor. Consider adding the required modifier or declaring as nullable.
+ Ein Non-Nullable-Feld muss beim Beenden des Konstruktors einen Wert ungleich NULL enthalten. Erwägen Sie die Deklaration als Nullable.
diff --git a/src/Compilers/CSharp/Portable/xlf/CSharpResources.es.xlf b/src/Compilers/CSharp/Portable/xlf/CSharpResources.es.xlf
index 46d2302cf07e3..e817772468f9b 100644
--- a/src/Compilers/CSharp/Portable/xlf/CSharpResources.es.xlf
+++ b/src/Compilers/CSharp/Portable/xlf/CSharpResources.es.xlf
@@ -5079,13 +5079,13 @@
- Non-nullable {0} '{1}' must contain a non-null value when exiting constructor. Consider declaring the {0} as nullable.
- El elemento {0} "{1}" que no acepta valores NULL debe contener un valor distinto de NULL al salir del constructor. Considere la posibilidad de declarar el elemento {0} como que admite un valor NULL.
+ Non-nullable {0} '{1}' must contain a non-null value when exiting constructor. Consider adding the required modifier or declaring the {0} as nullable.
+ El elemento {0} "{1}" que no acepta valores NULL debe contener un valor distinto de NULL al salir del constructor. Considere la posibilidad de declarar el elemento {0} como que admite un valor NULL.
- Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable.
- Un campo que no acepta valores NULL debe contener un valor distinto de NULL al salir del constructor. Considere la posibilidad de declararlo como que admite un valor NULL.
+ Non-nullable field must contain a non-null value when exiting constructor. Consider adding the required modifier or declaring as nullable.
+ Un campo que no acepta valores NULL debe contener un valor distinto de NULL al salir del constructor. Considere la posibilidad de declararlo como que admite un valor NULL.
diff --git a/src/Compilers/CSharp/Portable/xlf/CSharpResources.fr.xlf b/src/Compilers/CSharp/Portable/xlf/CSharpResources.fr.xlf
index 21d95c543a69c..0f757f3ff2008 100644
--- a/src/Compilers/CSharp/Portable/xlf/CSharpResources.fr.xlf
+++ b/src/Compilers/CSharp/Portable/xlf/CSharpResources.fr.xlf
@@ -5079,13 +5079,13 @@
- Non-nullable {0} '{1}' must contain a non-null value when exiting constructor. Consider declaring the {0} as nullable.
- Le {0} '{1}' non-nullable doit contenir une valeur non-null lors de la fermeture du constructeur. Envisagez de déclarer le {0} comme nullable.
+ Non-nullable {0} '{1}' must contain a non-null value when exiting constructor. Consider adding the required modifier or declaring the {0} as nullable.
+ Le {0} '{1}' non-nullable doit contenir une valeur non-null lors de la fermeture du constructeur. Envisagez de déclarer le {0} comme nullable.
- Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable.
- Un champ non-nullable doit contenir une valeur non-null lors de la fermeture du constructeur. Envisagez de déclarer le champ comme nullable.
+ Non-nullable field must contain a non-null value when exiting constructor. Consider adding the required modifier or declaring as nullable.
+ Un champ non-nullable doit contenir une valeur non-null lors de la fermeture du constructeur. Envisagez de déclarer le champ comme nullable.
diff --git a/src/Compilers/CSharp/Portable/xlf/CSharpResources.it.xlf b/src/Compilers/CSharp/Portable/xlf/CSharpResources.it.xlf
index 4b6f9d4393503..8b3166ce14fb7 100644
--- a/src/Compilers/CSharp/Portable/xlf/CSharpResources.it.xlf
+++ b/src/Compilers/CSharp/Portable/xlf/CSharpResources.it.xlf
@@ -5079,13 +5079,13 @@ target:module Compila un modulo che può essere aggiunto ad altro
- Non-nullable {0} '{1}' must contain a non-null value when exiting constructor. Consider declaring the {0} as nullable.
- L'elemento {0} '{1}' non nullable deve contenere un valore non Null all'uscita dal costruttore. Provare a dichiarare {0} come nullable.
+ Non-nullable {0} '{1}' must contain a non-null value when exiting constructor. Consider adding the required modifier or declaring the {0} as nullable.
+ L'elemento {0} '{1}' non nullable deve contenere un valore non Null all'uscita dal costruttore. Provare a dichiarare {0} come nullable.
- Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable.
- Il campo non nullable deve contenere un valore non Null all'uscita dal costruttore. Provare a dichiararlo come nullable.
+ Non-nullable field must contain a non-null value when exiting constructor. Consider adding the required modifier or declaring as nullable.
+ Il campo non nullable deve contenere un valore non Null all'uscita dal costruttore. Provare a dichiararlo come nullable.
diff --git a/src/Compilers/CSharp/Portable/xlf/CSharpResources.ja.xlf b/src/Compilers/CSharp/Portable/xlf/CSharpResources.ja.xlf
index d22e46da8f2c8..62bbe4fb0a0e9 100644
--- a/src/Compilers/CSharp/Portable/xlf/CSharpResources.ja.xlf
+++ b/src/Compilers/CSharp/Portable/xlf/CSharpResources.ja.xlf
@@ -5079,13 +5079,13 @@
- Non-nullable {0} '{1}' must contain a non-null value when exiting constructor. Consider declaring the {0} as nullable.
- null 非許容の {0} '{1}' には、コンストラクターの終了時に null 以外の値が入っていなければなりません。{0} を Null 許容として宣言することをご検討ください。
+ Non-nullable {0} '{1}' must contain a non-null value when exiting constructor. Consider adding the required modifier or declaring the {0} as nullable.
+ null 非許容の {0} '{1}' には、コンストラクターの終了時に null 以外の値が入っていなければなりません。{0} を Null 許容として宣言することをご検討ください。
- Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable.
- null 非許容のフィールドには、コンストラクターの終了時に null 以外の値が入っていなければなりません。Null 許容として宣言することをご検討ください。
+ Non-nullable field must contain a non-null value when exiting constructor. Consider adding the required modifier or declaring as nullable.
+ null 非許容のフィールドには、コンストラクターの終了時に null 以外の値が入っていなければなりません。Null 許容として宣言することをご検討ください。
diff --git a/src/Compilers/CSharp/Portable/xlf/CSharpResources.ko.xlf b/src/Compilers/CSharp/Portable/xlf/CSharpResources.ko.xlf
index 3c3e4232b34f0..5dcc4f6d48de8 100644
--- a/src/Compilers/CSharp/Portable/xlf/CSharpResources.ko.xlf
+++ b/src/Compilers/CSharp/Portable/xlf/CSharpResources.ko.xlf
@@ -5079,13 +5079,13 @@
- Non-nullable {0} '{1}' must contain a non-null value when exiting constructor. Consider declaring the {0} as nullable.
- 생성자를 종료할 때 null을 허용하지 않는 {0} '{1}'에 null이 아닌 값을 포함해야 합니다. {0}을(를) null 허용으로 선언해 보세요.
+ Non-nullable {0} '{1}' must contain a non-null value when exiting constructor. Consider adding the required modifier or declaring the {0} as nullable.
+ 생성자를 종료할 때 null을 허용하지 않는 {0} '{1}'에 null이 아닌 값을 포함해야 합니다. {0}을(를) null 허용으로 선언해 보세요.
- Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable.
- 생성자를 종료할 때 null을 허용하지 않는 필드에 null이 아닌 값을 포함해야 합니다. null 허용으로 선언해 보세요.
+ Non-nullable field must contain a non-null value when exiting constructor. Consider adding the required modifier or declaring as nullable.
+ 생성자를 종료할 때 null을 허용하지 않는 필드에 null이 아닌 값을 포함해야 합니다. null 허용으로 선언해 보세요.
diff --git a/src/Compilers/CSharp/Portable/xlf/CSharpResources.pl.xlf b/src/Compilers/CSharp/Portable/xlf/CSharpResources.pl.xlf
index 236da182cee77..bf781f4c46e2e 100644
--- a/src/Compilers/CSharp/Portable/xlf/CSharpResources.pl.xlf
+++ b/src/Compilers/CSharp/Portable/xlf/CSharpResources.pl.xlf
@@ -5079,13 +5079,13 @@
- Non-nullable {0} '{1}' must contain a non-null value when exiting constructor. Consider declaring the {0} as nullable.
- Niedopuszczający wartości null element {0} „{1}” musi zawierać wartość inną niż null podczas kończenia działania konstruktora. Rozważ zadeklarowanie elementu {0} jako dopuszczającego wartość null.
+ Non-nullable {0} '{1}' must contain a non-null value when exiting constructor. Consider adding the required modifier or declaring the {0} as nullable.
+ Niedopuszczający wartości null element {0} „{1}” musi zawierać wartość inną niż null podczas kończenia działania konstruktora. Rozważ zadeklarowanie elementu {0} jako dopuszczającego wartość null.
- Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable.
- Pole niedopuszczające wartości null musi zawierać wartość inną niż null podczas kończenia działania konstruktora. Rozważ zadeklarowanie pola jako dopuszczającego wartość null.
+ Non-nullable field must contain a non-null value when exiting constructor. Consider adding the required modifier or declaring as nullable.
+ Pole niedopuszczające wartości null musi zawierać wartość inną niż null podczas kończenia działania konstruktora. Rozważ zadeklarowanie pola jako dopuszczającego wartość null.
diff --git a/src/Compilers/CSharp/Portable/xlf/CSharpResources.pt-BR.xlf b/src/Compilers/CSharp/Portable/xlf/CSharpResources.pt-BR.xlf
index ed4a82cea33ad..7b5499124fb6d 100644
--- a/src/Compilers/CSharp/Portable/xlf/CSharpResources.pt-BR.xlf
+++ b/src/Compilers/CSharp/Portable/xlf/CSharpResources.pt-BR.xlf
@@ -5079,13 +5079,13 @@
- Non-nullable {0} '{1}' must contain a non-null value when exiting constructor. Consider declaring the {0} as nullable.
- O {0} não anulável '{1}' precisa conter um valor não nulo ao sair do construtor. Considere declarar o {0} como anulável.
+ Non-nullable {0} '{1}' must contain a non-null value when exiting constructor. Consider adding the required modifier or declaring the {0} as nullable.
+ O {0} não anulável '{1}' precisa conter um valor não nulo ao sair do construtor. Considere declarar o {0} como anulável.
- Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable.
- O campo não anulável precisa conter um valor não nulo ao sair do construtor. Considere declará-lo como anulável.
+ Non-nullable field must contain a non-null value when exiting constructor. Consider adding the required modifier or declaring as nullable.
+ O campo não anulável precisa conter um valor não nulo ao sair do construtor. Considere declará-lo como anulável.
diff --git a/src/Compilers/CSharp/Portable/xlf/CSharpResources.ru.xlf b/src/Compilers/CSharp/Portable/xlf/CSharpResources.ru.xlf
index 197239919e8d6..bff744f50ff98 100644
--- a/src/Compilers/CSharp/Portable/xlf/CSharpResources.ru.xlf
+++ b/src/Compilers/CSharp/Portable/xlf/CSharpResources.ru.xlf
@@ -5080,13 +5080,13 @@
- Non-nullable {0} '{1}' must contain a non-null value when exiting constructor. Consider declaring the {0} as nullable.
- {0} "{1}", не допускающий значения NULL, должен содержать значение, отличное от NULL, при выходе из конструктора. Возможно, стоит объявить {0} как допускающий значения NULL.
+ Non-nullable {0} '{1}' must contain a non-null value when exiting constructor. Consider adding the required modifier or declaring the {0} as nullable.
+ {0} "{1}", не допускающий значения NULL, должен содержать значение, отличное от NULL, при выходе из конструктора. Возможно, стоит объявить {0} как допускающий значения NULL.
- Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable.
- Поле, не допускающее значения NULL, должно содержать значение, отличное от NULL, при выходе из конструктора. Возможно, стоит объявить поле как допускающее значения NULL.
+ Non-nullable field must contain a non-null value when exiting constructor. Consider adding the required modifier or declaring as nullable.
+ Поле, не допускающее значения NULL, должно содержать значение, отличное от NULL, при выходе из конструктора. Возможно, стоит объявить поле как допускающее значения NULL.
diff --git a/src/Compilers/CSharp/Portable/xlf/CSharpResources.tr.xlf b/src/Compilers/CSharp/Portable/xlf/CSharpResources.tr.xlf
index 44f14a30f0b80..8a0db42f9f02e 100644
--- a/src/Compilers/CSharp/Portable/xlf/CSharpResources.tr.xlf
+++ b/src/Compilers/CSharp/Portable/xlf/CSharpResources.tr.xlf
@@ -5079,13 +5079,13 @@
- Non-nullable {0} '{1}' must contain a non-null value when exiting constructor. Consider declaring the {0} as nullable.
- Null atanamaz {0} '{1}', oluşturucudan çıkış yaparken null olmayan bir değer içermelidir. {0} alanını null atanabilir olarak bildirmeyi düşünün.
+ Non-nullable {0} '{1}' must contain a non-null value when exiting constructor. Consider adding the required modifier or declaring the {0} as nullable.
+ Null atanamaz {0} '{1}', oluşturucudan çıkış yaparken null olmayan bir değer içermelidir. {0} alanını null atanabilir olarak bildirmeyi düşünün.
- Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable.
- Null atanamaz alan, oluşturucudan çıkış yaparken null olmayan bir değer içermelidir. Alanı null atanabilir olarak bildirmeyi düşünün.
+ Non-nullable field must contain a non-null value when exiting constructor. Consider adding the required modifier or declaring as nullable.
+ Null atanamaz alan, oluşturucudan çıkış yaparken null olmayan bir değer içermelidir. Alanı null atanabilir olarak bildirmeyi düşünün.
diff --git a/src/Compilers/CSharp/Portable/xlf/CSharpResources.zh-Hans.xlf b/src/Compilers/CSharp/Portable/xlf/CSharpResources.zh-Hans.xlf
index 0983b4f8fc93c..536f98ea1a7f2 100644
--- a/src/Compilers/CSharp/Portable/xlf/CSharpResources.zh-Hans.xlf
+++ b/src/Compilers/CSharp/Portable/xlf/CSharpResources.zh-Hans.xlf
@@ -5079,13 +5079,13 @@
- Non-nullable {0} '{1}' must contain a non-null value when exiting constructor. Consider declaring the {0} as nullable.
- 在退出构造函数时,不可为 null 的 {0}“{1}”必须包含非 null 值。请考虑将 {0} 声明为可以为 null。
+ Non-nullable {0} '{1}' must contain a non-null value when exiting constructor. Consider adding the required modifier or declaring the {0} as nullable.
+ 在退出构造函数时,不可为 null 的 {0}“{1}”必须包含非 null 值。请考虑将 {0} 声明为可以为 null。
- Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable.
- 在退出构造函数时,不可为 null 的字段必须包含非 null 值。请考虑声明为可以为 null。
+ Non-nullable field must contain a non-null value when exiting constructor. Consider adding the required modifier or declaring as nullable.
+ 在退出构造函数时,不可为 null 的字段必须包含非 null 值。请考虑声明为可以为 null。
diff --git a/src/Compilers/CSharp/Portable/xlf/CSharpResources.zh-Hant.xlf b/src/Compilers/CSharp/Portable/xlf/CSharpResources.zh-Hant.xlf
index ac7f52744cd5c..5f711a0904f94 100644
--- a/src/Compilers/CSharp/Portable/xlf/CSharpResources.zh-Hant.xlf
+++ b/src/Compilers/CSharp/Portable/xlf/CSharpResources.zh-Hant.xlf
@@ -5079,13 +5079,13 @@ strument:TestCoverage 產生檢測要收集
- Non-nullable {0} '{1}' must contain a non-null value when exiting constructor. Consider declaring the {0} as nullable.
- 退出建構函式時,不可為 Null 的 {0} '{1}' 必須包含非 Null 值。請考慮將 {0} 宣告為可為 Null。
+ Non-nullable {0} '{1}' must contain a non-null value when exiting constructor. Consider adding the required modifier or declaring the {0} as nullable.
+ 退出建構函式時,不可為 Null 的 {0} '{1}' 必須包含非 Null 值。請考慮將 {0} 宣告為可為 Null。
- Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable.
- 退出建構函式時,不可為 Null 的欄位必須包含非 Null 值。請考慮宣告為可為 Null。
+ Non-nullable field must contain a non-null value when exiting constructor. Consider adding the required modifier or declaring as nullable.
+ 退出建構函式時,不可為 Null 的欄位必須包含非 Null 值。請考慮宣告為可為 Null。
diff --git a/src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenAsyncMethodBuilderOverrideTests.cs b/src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenAsyncMethodBuilderOverrideTests.cs
index a49eaad3395f5..ea3346aa3f4c4 100644
--- a/src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenAsyncMethodBuilderOverrideTests.cs
+++ b/src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenAsyncMethodBuilderOverrideTests.cs
@@ -231,7 +231,7 @@ public static async MyTask M()
// (20,16): warning CS8603: Possible null reference return.
// return await G((string?)null); // 2
Diagnostic(ErrorCode.WRN_NullReferenceReturn, "await G((string?)null)").WithLocation(20, 16),
- // (44,16): warning CS8618: Non-nullable field '_result' must contain a non-null value when exiting constructor. Consider declaring the field as nullable.
+ // (44,16): warning CS8618: Non-nullable field '_result' must contain a non-null value when exiting constructor. Consider adding the required modifier or declaring the field as nullable.
// internal T _result;
Diagnostic(ErrorCode.WRN_UninitializedNonNullableField, "_result").WithArguments("field", "_result").WithLocation(44, 16)
);
diff --git a/src/Compilers/CSharp/Test/Emit2/Semantics/PatternMatchingTests3.cs b/src/Compilers/CSharp/Test/Emit2/Semantics/PatternMatchingTests3.cs
index 1be33c211fbeb..918ba7fbc7519 100644
--- a/src/Compilers/CSharp/Test/Emit2/Semantics/PatternMatchingTests3.cs
+++ b/src/Compilers/CSharp/Test/Emit2/Semantics/PatternMatchingTests3.cs
@@ -1393,7 +1393,7 @@ public static class C {
}
}";
var expectedDiagnostics = new DiagnosticDescription[] {
- // (4,19): warning CS8618: Non-nullable field 'o' must contain a non-null value when exiting constructor. Consider declaring the field as nullable.
+ // (4,19): warning CS8618: Non-nullable field 'o' must contain a non-null value when exiting constructor. Consider adding the required modifier or declaring the field as nullable.
// static object o;
Diagnostic(ErrorCode.WRN_UninitializedNonNullableField, "o").WithArguments("field", "o").WithLocation(4, 19),
// (4,19): warning CS0649: Field 'C.o' is never assigned to, and will always have its default value null
diff --git a/src/Compilers/CSharp/Test/Emit2/Semantics/PrimaryConstructorTests.cs b/src/Compilers/CSharp/Test/Emit2/Semantics/PrimaryConstructorTests.cs
index f9f267fa6b620..7197757ed35b9 100644
--- a/src/Compilers/CSharp/Test/Emit2/Semantics/PrimaryConstructorTests.cs
+++ b/src/Compilers/CSharp/Test/Emit2/Semantics/PrimaryConstructorTests.cs
@@ -19671,7 +19671,7 @@ internal class MyOtherClass
// (57,32): warning CS0067: The event 'MyOtherClass.SomethingChanged' is never used
// public event EventHandler? SomethingChanged;
Diagnostic(ErrorCode.WRN_UnreferencedEvent, "SomethingChanged").WithArguments("MyOtherClass.SomethingChanged").WithLocation(57, 32),
- // (58,19): warning CS8618: Non-nullable property 'MyProperty' must contain a non-null value when exiting constructor. Consider declaring the property as nullable.
+ // (58,19): warning CS8618: Non-nullable property 'MyProperty' must contain a non-null value when exiting constructor. Consider adding the required modifier or declaring the property as nullable.
// public string MyProperty { get; set; }
Diagnostic(ErrorCode.WRN_UninitializedNonNullableField, "MyProperty").WithArguments("property", "MyProperty").WithLocation(58, 19)
);
diff --git a/src/Compilers/CSharp/Test/Semantic/Semantics/NullableContextTests.cs b/src/Compilers/CSharp/Test/Semantic/Semantics/NullableContextTests.cs
index 08698e915b7b4..1d3f66d185fb6 100644
--- a/src/Compilers/CSharp/Test/Semantic/Semantics/NullableContextTests.cs
+++ b/src/Compilers/CSharp/Test/Semantic/Semantics/NullableContextTests.cs
@@ -962,7 +962,7 @@ struct S
S(object obj) : this() { }
}";
verify(source, expectedAnalyzedKeys: new[] { ".ctor" },
- // (6,5): warning CS8618: Non-nullable field 'F1' must contain a non-null value when exiting constructor. Consider declaring the field as nullable.
+ // (6,5): warning CS8618: Non-nullable field 'F1' must contain a non-null value when exiting constructor. Consider adding the required modifier or declaring the field as nullable.
// S(object obj) : this() { }
Diagnostic(ErrorCode.WRN_UninitializedNonNullableField, "S").WithArguments("field", "F1").WithLocation(6, 5)
);
@@ -1083,7 +1083,7 @@ public void AnalyzeMethodsInEnabledContextOnly_05()
static object P2 { get; set; }
}";
verify(source, expectedAnalyzedKeys: new[] { ".cctor" },
- // (6,19): warning CS8618: Non-nullable property 'P2' must contain a non-null value when exiting constructor. Consider declaring the property as nullable.
+ // (6,19): warning CS8618: Non-nullable property 'P2' must contain a non-null value when exiting constructor. Consider adding the required modifier or declaring the property as nullable.
// static object P2 { get; set; }
Diagnostic(ErrorCode.WRN_UninitializedNonNullableField, "P2").WithArguments("property", "P2").WithLocation(6, 19));
@@ -1096,7 +1096,7 @@ public void AnalyzeMethodsInEnabledContextOnly_05()
static object P2 { get; set; }
}";
verify(source, expectedAnalyzedKeys: new[] { ".ctor" },
- // (4,12): warning CS8618: Non-nullable property 'P1' must contain a non-null value when exiting constructor. Consider declaring the property as nullable.
+ // (4,12): warning CS8618: Non-nullable property 'P1' must contain a non-null value when exiting constructor. Consider adding the required modifier or declaring the property as nullable.
// object P1 { get; set; }
Diagnostic(ErrorCode.WRN_UninitializedNonNullableField, "P1").WithArguments("property", "P1").WithLocation(4, 12));
@@ -1109,7 +1109,7 @@ public void AnalyzeMethodsInEnabledContextOnly_05()
object P3 => 3;
}";
verify(source, expectedAnalyzedKeys: new[] { ".ctor", "get_P2", "get_P3", "set_P2" },
- // (4,12): warning CS8618: Non-nullable property 'P1' must contain a non-null value when exiting constructor. Consider declaring the property as nullable.
+ // (4,12): warning CS8618: Non-nullable property 'P1' must contain a non-null value when exiting constructor. Consider adding the required modifier or declaring the property as nullable.
// object P1 { get; }
Diagnostic(ErrorCode.WRN_UninitializedNonNullableField, "P1").WithArguments("property", "P1").WithLocation(4, 12));
@@ -1124,7 +1124,7 @@ class Program
static event D E2;
}";
verify(source, expectedAnalyzedKeys: new[] { ".cctor" },
- // (8,20): warning CS8618: Non-nullable event 'E2' must contain a non-null value when exiting constructor. Consider declaring the event as nullable.
+ // (8,20): warning CS8618: Non-nullable event 'E2' must contain a non-null value when exiting constructor. Consider adding the required modifier or declaring the event as nullable.
// static event D E2;
Diagnostic(ErrorCode.WRN_UninitializedNonNullableField, "E2").WithArguments("event", "E2").WithLocation(8, 20));
@@ -1139,7 +1139,7 @@ class Program
static event D E2;
}";
verify(source, expectedAnalyzedKeys: new[] { ".ctor" },
- // (6,13): warning CS8618: Non-nullable event 'E1' must contain a non-null value when exiting constructor. Consider declaring the event as nullable.
+ // (6,13): warning CS8618: Non-nullable event 'E1' must contain a non-null value when exiting constructor. Consider adding the required modifier or declaring the event as nullable.
// event D E1;
Diagnostic(ErrorCode.WRN_UninitializedNonNullableField, "E1").WithArguments("event", "E1").WithLocation(6, 13));
diff --git a/src/Compilers/CSharp/Test/Semantic/Semantics/NullableReferenceTypesTests.cs b/src/Compilers/CSharp/Test/Semantic/Semantics/NullableReferenceTypesTests.cs
index c418ef1be80e0..991658f354cef 100644
--- a/src/Compilers/CSharp/Test/Semantic/Semantics/NullableReferenceTypesTests.cs
+++ b/src/Compilers/CSharp/Test/Semantic/Semantics/NullableReferenceTypesTests.cs
@@ -30965,10 +30965,10 @@ public void Init(T t)
";
var comp = CreateNullableCompilation(new[] { source, NotNullAttributeDefinition, MemberNotNullAttributeDefinition, DisallowNullAttributeDefinition });
comp.VerifyDiagnostics(
- // (9,12): warning CS8618: Non-nullable property 'Prop' must contain a non-null value when exiting constructor. Consider declaring the property as nullable.
+ // (9,12): warning CS8618: Non-nullable property 'Prop' must contain a non-null value when exiting constructor. Consider adding the required modifier or declaring the property as nullable.
// public C() { } // 1
Diagnostic(ErrorCode.WRN_UninitializedNonNullableField, "C").WithArguments("property", "Prop").WithLocation(9, 12),
- // (10,12): warning CS8618: Non-nullable property 'Prop' must contain a non-null value when exiting constructor. Consider declaring the property as nullable.
+ // (10,12): warning CS8618: Non-nullable property 'Prop' must contain a non-null value when exiting constructor. Consider adding the required modifier or declaring the property as nullable.
// public C(T t) { Prop = t; } // 2
Diagnostic(ErrorCode.WRN_UninitializedNonNullableField, "C").WithArguments("property", "Prop").WithLocation(10, 12),
// (11,38): warning CS8602: Dereference of a possibly null reference.
@@ -31006,10 +31006,10 @@ public void Init(T t)
";
var comp = CreateNullableCompilation(new[] { source, NotNullAttributeDefinition, MemberNotNullAttributeDefinition, DisallowNullAttributeDefinition });
comp.VerifyDiagnostics(
- // (9,12): warning CS8618: Non-nullable field 'field' must contain a non-null value when exiting constructor. Consider declaring the field as nullable.
+ // (9,12): warning CS8618: Non-nullable field 'field' must contain a non-null value when exiting constructor. Consider adding the required modifier or declaring the field as nullable.
// public C() { } // 1
Diagnostic(ErrorCode.WRN_UninitializedNonNullableField, "C").WithArguments("field", "field").WithLocation(9, 12),
- // (10,12): warning CS8618: Non-nullable field 'field' must contain a non-null value when exiting constructor. Consider declaring the field as nullable.
+ // (10,12): warning CS8618: Non-nullable field 'field' must contain a non-null value when exiting constructor. Consider adding the required modifier or declaring the field as nullable.
// public C(T t) { field = t; } // 2
Diagnostic(ErrorCode.WRN_UninitializedNonNullableField, "C").WithArguments("field", "field").WithLocation(10, 12),
// (11,39): warning CS8602: Dereference of a possibly null reference.
@@ -31078,10 +31078,10 @@ public C3(int i)
// We expect no warnings on `C2(string?)` because `C2.F`'s getter and setter are not linked.
var comp = CreateNullableCompilation(new[] { source, NotNullAttributeDefinition, DisallowNullAttributeDefinition });
comp.VerifyDiagnostics(
- // (9,12): warning CS8618: Non-nullable property 'F1' must contain a non-null value when exiting constructor. Consider declaring the property as nullable.
+ // (9,12): warning CS8618: Non-nullable property 'F1' must contain a non-null value when exiting constructor. Consider adding the required modifier or declaring the property as nullable.
// public C1() { } // 1
Diagnostic(ErrorCode.WRN_UninitializedNonNullableField, "C1").WithArguments("property", "F1").WithLocation(9, 12),
- // (10,12): warning CS8618: Non-nullable property 'F1' must contain a non-null value when exiting constructor. Consider declaring the property as nullable.
+ // (10,12): warning CS8618: Non-nullable property 'F1' must contain a non-null value when exiting constructor. Consider adding the required modifier or declaring the property as nullable.
// public C1(string? F1) // 2
Diagnostic(ErrorCode.WRN_UninitializedNonNullableField, "C1").WithArguments("property", "F1").WithLocation(10, 12),
// (12,19): warning CS8601: Possible null reference assignment.
@@ -31149,19 +31149,19 @@ public C3(int i)
";
var comp = CreateNullableCompilation(new[] { source, NotNullAttributeDefinition, DisallowNullAttributeDefinition });
comp.VerifyDiagnostics(
- // (9,12): warning CS8618: Non-nullable field 'F' must contain a non-null value when exiting constructor. Consider declaring the field as nullable.
+ // (9,12): warning CS8618: Non-nullable field 'F' must contain a non-null value when exiting constructor. Consider adding the required modifier or declaring the field as nullable.
// public C1() { } // 1
Diagnostic(ErrorCode.WRN_UninitializedNonNullableField, "C1").WithArguments("field", "F").WithLocation(9, 12),
- // (10,12): warning CS8618: Non-nullable field 'F' must contain a non-null value when exiting constructor. Consider declaring the field as nullable.
+ // (10,12): warning CS8618: Non-nullable field 'F' must contain a non-null value when exiting constructor. Consider adding the required modifier or declaring the field as nullable.
// public C1(string? F) // 2
Diagnostic(ErrorCode.WRN_UninitializedNonNullableField, "C1").WithArguments("field", "F").WithLocation(10, 12),
// (12,18): warning CS8601: Possible null reference assignment.
// this.F = F; // 3
Diagnostic(ErrorCode.WRN_NullReferenceAssignment, "F").WithLocation(12, 18),
- // (25,12): warning CS8618: Non-nullable field 'F' must contain a non-null value when exiting constructor. Consider declaring the field as nullable.
+ // (25,12): warning CS8618: Non-nullable field 'F' must contain a non-null value when exiting constructor. Consider adding the required modifier or declaring the field as nullable.
// public C2() { } // 4
Diagnostic(ErrorCode.WRN_UninitializedNonNullableField, "C2").WithArguments("field", "F").WithLocation(25, 12),
- // (26,12): warning CS8618: Non-nullable field 'F' must contain a non-null value when exiting constructor. Consider declaring the field as nullable.
+ // (26,12): warning CS8618: Non-nullable field 'F' must contain a non-null value when exiting constructor. Consider adding the required modifier or declaring the field as nullable.
// public C2(string? F) // 5
Diagnostic(ErrorCode.WRN_UninitializedNonNullableField, "C2").WithArguments("field", "F").WithLocation(26, 12),
// (44,18): warning CS8601: Possible null reference assignment.
@@ -31245,10 +31245,10 @@ public class C {
// it seems like property state should be NotNull after assigning a MaybeNull to the property.
// https://github.com/dotnet/roslyn/issues/49964
comp.VerifyDiagnostics(
- // (8,12): warning CS8618: Non-nullable property 'Prop' must contain a non-null value when exiting constructor. Consider declaring the property as nullable.
+ // (8,12): warning CS8618: Non-nullable property 'Prop' must contain a non-null value when exiting constructor. Consider adding the required modifier or declaring the property as nullable.
// public C() // 1
Diagnostic(ErrorCode.WRN_UninitializedNonNullableField, "C").WithArguments("property", "Prop").WithLocation(8, 12),
- // (12,12): warning CS8618: Non-nullable property 'Prop' must contain a non-null value when exiting constructor. Consider declaring the property as nullable.
+ // (12,12): warning CS8618: Non-nullable property 'Prop' must contain a non-null value when exiting constructor. Consider adding the required modifier or declaring the property as nullable.
// public C(T t) // 2
Diagnostic(ErrorCode.WRN_UninitializedNonNullableField, "C").WithArguments("property", "Prop").WithLocation(12, 12),
// (19,9): warning CS8602: Dereference of a possibly null reference.
@@ -33905,7 +33905,7 @@ class C
";
var comp = CreateCompilation(new[] { source, NotNullIfNotNullAttributeDefinition });
comp.VerifyEmitDiagnostics(
- // (14,5): warning CS8618: Non-nullable field 'f2' must contain a non-null value when exiting constructor. Consider declaring the field as nullable.
+ // (14,5): warning CS8618: Non-nullable field 'f2' must contain a non-null value when exiting constructor. Consider adding the required modifier or declaring the field as nullable.
// C()
Diagnostic(ErrorCode.WRN_UninitializedNonNullableField, "C", isSuppressed: false).WithArguments("field", "f2").WithLocation(14, 5),
// (18,16): warning CS8601: Possible null reference assignment.
@@ -45895,13 +45895,13 @@ public class CStruct where TStruct : struct
}";
var comp = CreateNullableCompilation(new[] { lib_cs, NotNullAttributeDefinition });
comp.VerifyDiagnostics(
- // (5,5): warning CS8618: Non-nullable property 'P1' must contain a non-null value when exiting constructor. Consider declaring the property as nullable.
+ // (5,5): warning CS8618: Non-nullable property 'P1' must contain a non-null value when exiting constructor. Consider adding the required modifier or declaring the property as nullable.
// COpen() // 1
Diagnostic(ErrorCode.WRN_UninitializedNonNullableField, "COpen").WithArguments("property", "P1").WithLocation(5, 5),
// (7,14): warning CS8601: Possible null reference assignment.
// P1 = default; // 2
Diagnostic(ErrorCode.WRN_NullReferenceAssignment, "default").WithLocation(7, 14),
- // (14,5): warning CS8618: Non-nullable property 'P2' must contain a non-null value when exiting constructor. Consider declaring the property as nullable.
+ // (14,5): warning CS8618: Non-nullable property 'P2' must contain a non-null value when exiting constructor. Consider adding the required modifier or declaring the property as nullable.
// CClass() // 3
Diagnostic(ErrorCode.WRN_UninitializedNonNullableField, "CClass").WithArguments("property", "P2").WithLocation(14, 5),
// (16,14): warning CS8625: Cannot convert null literal to non-nullable reference type.
@@ -60808,7 +60808,7 @@ struct S1
// (12,14): warning CS8601: Possible null reference assignment.
// P1 = x1; // 2
Diagnostic(ErrorCode.WRN_NullReferenceAssignment, "x1").WithLocation(12, 14),
- // (10,12): warning CS8618: Non-nullable property 'P1' must contain a non-null value when exiting constructor. Consider declaring the property as nullable.
+ // (10,12): warning CS8618: Non-nullable property 'P1' must contain a non-null value when exiting constructor. Consider adding the required modifier or declaring the property as nullable.
// public C1(C1? x1) // 1
Diagnostic(ErrorCode.WRN_UninitializedNonNullableField, "C1").WithArguments("property", "P1").WithLocation(10, 12),
// (22,14): warning CS8600: Converting null literal or possible null value to non-nullable type.
@@ -60895,7 +60895,7 @@ struct S1
// (12,14): warning CS8601: Possible null reference assignment.
// P1 = x1; // 2
Diagnostic(ErrorCode.WRN_NullReferenceAssignment, "x1").WithLocation(12, 14),
- // (10,12): warning CS8618: Non-nullable property 'P1' must contain a non-null value when exiting constructor. Consider declaring the property as nullable.
+ // (10,12): warning CS8618: Non-nullable property 'P1' must contain a non-null value when exiting constructor. Consider adding the required modifier or declaring the property as nullable.
// public C1(C0? x1) // 1
Diagnostic(ErrorCode.WRN_UninitializedNonNullableField, "C1").WithArguments("property", "P1").WithLocation(10, 12),
// (34,14): warning CS8600: Converting null literal or possible null value to non-nullable type.
@@ -73723,7 +73723,7 @@ static void M3()
var comp = CreateCompilation(new[] { source }, options: WithNullableEnable());
// https://github.com/dotnet/roslyn/issues/31018: Report warnings for // 3 and // 4.
comp.VerifyDiagnostics(
- // (6,30): warning CS8618: Non-nullable event 'E' must contain a non-null value when exiting constructor. Consider declaring the event as nullable.
+ // (6,30): warning CS8618: Non-nullable event 'E' must contain a non-null value when exiting constructor. Consider adding the required modifier or declaring the event as nullable.
// event Action> E;
Diagnostic(ErrorCode.WRN_UninitializedNonNullableField, "E").WithArguments("event", "E").WithLocation(6, 30),
// (10,17): warning CS8622: Nullability of reference types in type of parameter 'a' of 'void B.F1(A