From c42c063687e2fdde93ce2542ce7da9bd507b93a1 Mon Sep 17 00:00:00 2001 From: Charles Stoner <10732005+cston@users.noreply.github.com> Date: Thu, 13 Jun 2024 15:11:38 -0700 Subject: [PATCH] Report info diagnostic for `field` and `value` in property accessors regardless of language version (#73952) --- .../Portable/Binder/Binder_Expressions.cs | 5 +- .../CSharp/Portable/CSharpResources.resx | 2 +- .../Portable/xlf/CSharpResources.cs.xlf | 4 +- .../Portable/xlf/CSharpResources.de.xlf | 4 +- .../Portable/xlf/CSharpResources.es.xlf | 4 +- .../Portable/xlf/CSharpResources.fr.xlf | 4 +- .../Portable/xlf/CSharpResources.it.xlf | 4 +- .../Portable/xlf/CSharpResources.ja.xlf | 4 +- .../Portable/xlf/CSharpResources.ko.xlf | 4 +- .../Portable/xlf/CSharpResources.pl.xlf | 4 +- .../Portable/xlf/CSharpResources.pt-BR.xlf | 4 +- .../Portable/xlf/CSharpResources.ru.xlf | 4 +- .../Portable/xlf/CSharpResources.tr.xlf | 4 +- .../Portable/xlf/CSharpResources.zh-Hans.xlf | 4 +- .../Portable/xlf/CSharpResources.zh-Hant.xlf | 4 +- .../Emit/CodeGen/CodeGenDeconstructTests.cs | 4 +- .../Test/Emit2/Semantics/RecordTests.cs | 2 +- .../Semantic/Semantics/BindingAsyncTests.cs | 4 +- .../Semantics/InheritanceBindingTests.cs | 8 +- .../Test/Semantic/Semantics/LambdaTests.cs | 12 +- .../Semantics/NullableReferenceTypesTests.cs | 8 +- .../Test/Semantic/Semantics/RefFieldTests.cs | 16 +- .../Semantics/RefLocalsAndReturnsTests.cs | 2 +- .../Semantic/Semantics/SemanticErrorTests.cs | 12 +- ...InterfaceOverriddenOrHiddenMembersTests.cs | 2 +- .../Symbols/OverriddenOrHiddenMembersTests.cs | 6 +- .../Source/ExpressionBodiedPropertyTests.cs | 4 +- .../Symbol/Symbols/Source/PropertyTests.cs | 8 +- .../Test/Symbol/Symbols/SymbolErrorTests.cs | 24 +- .../Syntax/FieldAndValueKeywordTests.cs | 841 +++++++----------- 30 files changed, 424 insertions(+), 588 deletions(-) diff --git a/src/Compilers/CSharp/Portable/Binder/Binder_Expressions.cs b/src/Compilers/CSharp/Portable/Binder/Binder_Expressions.cs index 19e3505db39fe..ad570b1be3c47 100644 --- a/src/Compilers/CSharp/Portable/Binder/Binder_Expressions.cs +++ b/src/Compilers/CSharp/Portable/Binder/Binder_Expressions.cs @@ -1750,10 +1750,7 @@ internal void ReportFieldOrValueContextualKeywordConflictIfAny(SyntaxNode syntax case "value" when ContainingMember() is MethodSymbol { MethodKind: MethodKind.PropertySet or MethodKind.EventAdd or MethodKind.EventRemove }: { var requiredVersion = MessageID.IDS_FeatureFieldAndValueKeywords.RequiredVersion(); - if (Compilation.LanguageVersion < requiredVersion) - { - diagnostics.Add(ErrorCode.INF_IdentifierConflictWithContextualKeyword, syntax, name, requiredVersion.ToDisplayString()); - } + diagnostics.Add(ErrorCode.INF_IdentifierConflictWithContextualKeyword, syntax, name, requiredVersion.ToDisplayString()); } break; } diff --git a/src/Compilers/CSharp/Portable/CSharpResources.resx b/src/Compilers/CSharp/Portable/CSharpResources.resx index a80bb7e8a1161..e38f8308170e8 100644 --- a/src/Compilers/CSharp/Portable/CSharpResources.resx +++ b/src/Compilers/CSharp/Portable/CSharpResources.resx @@ -6866,7 +6866,7 @@ To remove the warning, you can use /reference instead (set the Embed Interop Typ Compiling requires binding the lambda expression many times. Consider declaring the lambda expression with explicit parameter types, or if the containing method call is generic, consider using explicit type arguments. - '{0}' is a contextual keyword, with a specific meaning, starting in language version {1}. Use '@{0}' to avoid a breaking change when compiling with language version {1} or later. + '{0}' is a contextual keyword in property accessors starting in language version {1}. Use '@{0}' instead. Identifier is a contextual keyword, with a specific meaning, in a later language version. diff --git a/src/Compilers/CSharp/Portable/xlf/CSharpResources.cs.xlf b/src/Compilers/CSharp/Portable/xlf/CSharpResources.cs.xlf index 61a1a5f35d074..858863c5bb979 100644 --- a/src/Compilers/CSharp/Portable/xlf/CSharpResources.cs.xlf +++ b/src/Compilers/CSharp/Portable/xlf/CSharpResources.cs.xlf @@ -2608,8 +2608,8 @@ - '{0}' is a contextual keyword, with a specific meaning, starting in language version {1}. Use '@{0}' to avoid a breaking change when compiling with language version {1} or later. - '{0}' is a contextual keyword, with a specific meaning, starting in language version {1}. Use '@{0}' to avoid a breaking change when compiling with language version {1} or later. + '{0}' is a contextual keyword in property accessors starting in language version {1}. Use '@{0}' instead. + '{0}' is a contextual keyword in property accessors starting in language version {1}. Use '@{0}' instead. diff --git a/src/Compilers/CSharp/Portable/xlf/CSharpResources.de.xlf b/src/Compilers/CSharp/Portable/xlf/CSharpResources.de.xlf index 22d3090b57e4b..3081f74cee2da 100644 --- a/src/Compilers/CSharp/Portable/xlf/CSharpResources.de.xlf +++ b/src/Compilers/CSharp/Portable/xlf/CSharpResources.de.xlf @@ -2608,8 +2608,8 @@ - '{0}' is a contextual keyword, with a specific meaning, starting in language version {1}. Use '@{0}' to avoid a breaking change when compiling with language version {1} or later. - '{0}' is a contextual keyword, with a specific meaning, starting in language version {1}. Use '@{0}' to avoid a breaking change when compiling with language version {1} or later. + '{0}' is a contextual keyword in property accessors starting in language version {1}. Use '@{0}' instead. + '{0}' is a contextual keyword in property accessors starting in language version {1}. Use '@{0}' instead. diff --git a/src/Compilers/CSharp/Portable/xlf/CSharpResources.es.xlf b/src/Compilers/CSharp/Portable/xlf/CSharpResources.es.xlf index 1a5bd7a3bdc57..52ff38d31a108 100644 --- a/src/Compilers/CSharp/Portable/xlf/CSharpResources.es.xlf +++ b/src/Compilers/CSharp/Portable/xlf/CSharpResources.es.xlf @@ -2608,8 +2608,8 @@ - '{0}' is a contextual keyword, with a specific meaning, starting in language version {1}. Use '@{0}' to avoid a breaking change when compiling with language version {1} or later. - '{0}' is a contextual keyword, with a specific meaning, starting in language version {1}. Use '@{0}' to avoid a breaking change when compiling with language version {1} or later. + '{0}' is a contextual keyword in property accessors starting in language version {1}. Use '@{0}' instead. + '{0}' is a contextual keyword in property accessors starting in language version {1}. Use '@{0}' instead. diff --git a/src/Compilers/CSharp/Portable/xlf/CSharpResources.fr.xlf b/src/Compilers/CSharp/Portable/xlf/CSharpResources.fr.xlf index f51de573ca84e..58c4bb0bc700a 100644 --- a/src/Compilers/CSharp/Portable/xlf/CSharpResources.fr.xlf +++ b/src/Compilers/CSharp/Portable/xlf/CSharpResources.fr.xlf @@ -2608,8 +2608,8 @@ - '{0}' is a contextual keyword, with a specific meaning, starting in language version {1}. Use '@{0}' to avoid a breaking change when compiling with language version {1} or later. - '{0}' is a contextual keyword, with a specific meaning, starting in language version {1}. Use '@{0}' to avoid a breaking change when compiling with language version {1} or later. + '{0}' is a contextual keyword in property accessors starting in language version {1}. Use '@{0}' instead. + '{0}' is a contextual keyword in property accessors starting in language version {1}. Use '@{0}' instead. diff --git a/src/Compilers/CSharp/Portable/xlf/CSharpResources.it.xlf b/src/Compilers/CSharp/Portable/xlf/CSharpResources.it.xlf index 65613b4fbd281..c6d538e42c0f9 100644 --- a/src/Compilers/CSharp/Portable/xlf/CSharpResources.it.xlf +++ b/src/Compilers/CSharp/Portable/xlf/CSharpResources.it.xlf @@ -2608,8 +2608,8 @@ - '{0}' is a contextual keyword, with a specific meaning, starting in language version {1}. Use '@{0}' to avoid a breaking change when compiling with language version {1} or later. - '{0}' is a contextual keyword, with a specific meaning, starting in language version {1}. Use '@{0}' to avoid a breaking change when compiling with language version {1} or later. + '{0}' is a contextual keyword in property accessors starting in language version {1}. Use '@{0}' instead. + '{0}' is a contextual keyword in property accessors starting in language version {1}. Use '@{0}' instead. diff --git a/src/Compilers/CSharp/Portable/xlf/CSharpResources.ja.xlf b/src/Compilers/CSharp/Portable/xlf/CSharpResources.ja.xlf index 1fe44a2bc159f..6e0f70dbe292f 100644 --- a/src/Compilers/CSharp/Portable/xlf/CSharpResources.ja.xlf +++ b/src/Compilers/CSharp/Portable/xlf/CSharpResources.ja.xlf @@ -2608,8 +2608,8 @@ - '{0}' is a contextual keyword, with a specific meaning, starting in language version {1}. Use '@{0}' to avoid a breaking change when compiling with language version {1} or later. - '{0}' is a contextual keyword, with a specific meaning, starting in language version {1}. Use '@{0}' to avoid a breaking change when compiling with language version {1} or later. + '{0}' is a contextual keyword in property accessors starting in language version {1}. Use '@{0}' instead. + '{0}' is a contextual keyword in property accessors starting in language version {1}. Use '@{0}' instead. diff --git a/src/Compilers/CSharp/Portable/xlf/CSharpResources.ko.xlf b/src/Compilers/CSharp/Portable/xlf/CSharpResources.ko.xlf index e6a84fba71344..4428122d05997 100644 --- a/src/Compilers/CSharp/Portable/xlf/CSharpResources.ko.xlf +++ b/src/Compilers/CSharp/Portable/xlf/CSharpResources.ko.xlf @@ -2608,8 +2608,8 @@ - '{0}' is a contextual keyword, with a specific meaning, starting in language version {1}. Use '@{0}' to avoid a breaking change when compiling with language version {1} or later. - '{0}' is a contextual keyword, with a specific meaning, starting in language version {1}. Use '@{0}' to avoid a breaking change when compiling with language version {1} or later. + '{0}' is a contextual keyword in property accessors starting in language version {1}. Use '@{0}' instead. + '{0}' is a contextual keyword in property accessors starting in language version {1}. Use '@{0}' instead. diff --git a/src/Compilers/CSharp/Portable/xlf/CSharpResources.pl.xlf b/src/Compilers/CSharp/Portable/xlf/CSharpResources.pl.xlf index 2c222144ccdea..f15e05c0cbea6 100644 --- a/src/Compilers/CSharp/Portable/xlf/CSharpResources.pl.xlf +++ b/src/Compilers/CSharp/Portable/xlf/CSharpResources.pl.xlf @@ -2608,8 +2608,8 @@ - '{0}' is a contextual keyword, with a specific meaning, starting in language version {1}. Use '@{0}' to avoid a breaking change when compiling with language version {1} or later. - '{0}' is a contextual keyword, with a specific meaning, starting in language version {1}. Use '@{0}' to avoid a breaking change when compiling with language version {1} or later. + '{0}' is a contextual keyword in property accessors starting in language version {1}. Use '@{0}' instead. + '{0}' is a contextual keyword in property accessors starting in language version {1}. Use '@{0}' instead. diff --git a/src/Compilers/CSharp/Portable/xlf/CSharpResources.pt-BR.xlf b/src/Compilers/CSharp/Portable/xlf/CSharpResources.pt-BR.xlf index 2dfcafb5266f7..dac8436c4383f 100644 --- a/src/Compilers/CSharp/Portable/xlf/CSharpResources.pt-BR.xlf +++ b/src/Compilers/CSharp/Portable/xlf/CSharpResources.pt-BR.xlf @@ -2608,8 +2608,8 @@ - '{0}' is a contextual keyword, with a specific meaning, starting in language version {1}. Use '@{0}' to avoid a breaking change when compiling with language version {1} or later. - '{0}' is a contextual keyword, with a specific meaning, starting in language version {1}. Use '@{0}' to avoid a breaking change when compiling with language version {1} or later. + '{0}' is a contextual keyword in property accessors starting in language version {1}. Use '@{0}' instead. + '{0}' is a contextual keyword in property accessors starting in language version {1}. Use '@{0}' instead. diff --git a/src/Compilers/CSharp/Portable/xlf/CSharpResources.ru.xlf b/src/Compilers/CSharp/Portable/xlf/CSharpResources.ru.xlf index 3930417dae824..b984771860100 100644 --- a/src/Compilers/CSharp/Portable/xlf/CSharpResources.ru.xlf +++ b/src/Compilers/CSharp/Portable/xlf/CSharpResources.ru.xlf @@ -2608,8 +2608,8 @@ - '{0}' is a contextual keyword, with a specific meaning, starting in language version {1}. Use '@{0}' to avoid a breaking change when compiling with language version {1} or later. - '{0}' is a contextual keyword, with a specific meaning, starting in language version {1}. Use '@{0}' to avoid a breaking change when compiling with language version {1} or later. + '{0}' is a contextual keyword in property accessors starting in language version {1}. Use '@{0}' instead. + '{0}' is a contextual keyword in property accessors starting in language version {1}. Use '@{0}' instead. diff --git a/src/Compilers/CSharp/Portable/xlf/CSharpResources.tr.xlf b/src/Compilers/CSharp/Portable/xlf/CSharpResources.tr.xlf index ad744f2e1a9e8..811de3b857c1a 100644 --- a/src/Compilers/CSharp/Portable/xlf/CSharpResources.tr.xlf +++ b/src/Compilers/CSharp/Portable/xlf/CSharpResources.tr.xlf @@ -2608,8 +2608,8 @@ - '{0}' is a contextual keyword, with a specific meaning, starting in language version {1}. Use '@{0}' to avoid a breaking change when compiling with language version {1} or later. - '{0}' is a contextual keyword, with a specific meaning, starting in language version {1}. Use '@{0}' to avoid a breaking change when compiling with language version {1} or later. + '{0}' is a contextual keyword in property accessors starting in language version {1}. Use '@{0}' instead. + '{0}' is a contextual keyword in property accessors starting in language version {1}. Use '@{0}' instead. diff --git a/src/Compilers/CSharp/Portable/xlf/CSharpResources.zh-Hans.xlf b/src/Compilers/CSharp/Portable/xlf/CSharpResources.zh-Hans.xlf index 2d9f977417bf7..293573c1e4ef4 100644 --- a/src/Compilers/CSharp/Portable/xlf/CSharpResources.zh-Hans.xlf +++ b/src/Compilers/CSharp/Portable/xlf/CSharpResources.zh-Hans.xlf @@ -2608,8 +2608,8 @@ - '{0}' is a contextual keyword, with a specific meaning, starting in language version {1}. Use '@{0}' to avoid a breaking change when compiling with language version {1} or later. - '{0}' is a contextual keyword, with a specific meaning, starting in language version {1}. Use '@{0}' to avoid a breaking change when compiling with language version {1} or later. + '{0}' is a contextual keyword in property accessors starting in language version {1}. Use '@{0}' instead. + '{0}' is a contextual keyword in property accessors starting in language version {1}. Use '@{0}' instead. diff --git a/src/Compilers/CSharp/Portable/xlf/CSharpResources.zh-Hant.xlf b/src/Compilers/CSharp/Portable/xlf/CSharpResources.zh-Hant.xlf index bcbc5420069e3..a88fb77e8fa15 100644 --- a/src/Compilers/CSharp/Portable/xlf/CSharpResources.zh-Hant.xlf +++ b/src/Compilers/CSharp/Portable/xlf/CSharpResources.zh-Hant.xlf @@ -2608,8 +2608,8 @@ - '{0}' is a contextual keyword, with a specific meaning, starting in language version {1}. Use '@{0}' to avoid a breaking change when compiling with language version {1} or later. - '{0}' is a contextual keyword, with a specific meaning, starting in language version {1}. Use '@{0}' to avoid a breaking change when compiling with language version {1} or later. + '{0}' is a contextual keyword in property accessors starting in language version {1}. Use '@{0}' instead. + '{0}' is a contextual keyword in property accessors starting in language version {1}. Use '@{0}' instead. diff --git a/src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenDeconstructTests.cs b/src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenDeconstructTests.cs index 5887c8eb41966..32bd50f9a7b3e 100644 --- a/src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenDeconstructTests.cs +++ b/src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenDeconstructTests.cs @@ -1906,7 +1906,7 @@ class C static int field; static long x { set { System.Console.WriteLine($""setX {value}""); } } static string y { get; set; } - static ref int z { get { return ref field; } } + static ref int z { get { return ref @field; } } static void Main() { @@ -1941,7 +1941,7 @@ class C static int field; static long x { set { System.Console.WriteLine($""setX {value}""); } } static string y { get; set; } - static ref int z { get { return ref field; } } + static ref int z { get { return ref @field; } } static void Main() { diff --git a/src/Compilers/CSharp/Test/Emit2/Semantics/RecordTests.cs b/src/Compilers/CSharp/Test/Emit2/Semantics/RecordTests.cs index fc5a188c754b5..d2d97b296fbfd 100644 --- a/src/Compilers/CSharp/Test/Emit2/Semantics/RecordTests.cs +++ b/src/Compilers/CSharp/Test/Emit2/Semantics/RecordTests.cs @@ -5282,7 +5282,7 @@ record C1(int I1) public int this[int i] => 0; public int PropertyWithoutGetter { set { } } public int P2 { get => 43; } - public ref int P3 { get => ref field; } + public ref int P3 { get => ref @field; } public event System.Action a; private int field1 = 100; diff --git a/src/Compilers/CSharp/Test/Semantic/Semantics/BindingAsyncTests.cs b/src/Compilers/CSharp/Test/Semantic/Semantics/BindingAsyncTests.cs index 8e550a2a565e8..c67dbbdde2610 100644 --- a/src/Compilers/CSharp/Test/Semantic/Semantics/BindingAsyncTests.cs +++ b/src/Compilers/CSharp/Test/Semantic/Semantics/BindingAsyncTests.cs @@ -2313,13 +2313,13 @@ public Task Prop get { Meth(1); - return field; + return @field; } set { Bar(); Meth(""""); - field = value; + @field = value; } } diff --git a/src/Compilers/CSharp/Test/Semantic/Semantics/InheritanceBindingTests.cs b/src/Compilers/CSharp/Test/Semantic/Semantics/InheritanceBindingTests.cs index bcd93d2fedcf3..f00e3f59dddbe 100644 --- a/src/Compilers/CSharp/Test/Semantic/Semantics/InheritanceBindingTests.cs +++ b/src/Compilers/CSharp/Test/Semantic/Semantics/InheritanceBindingTests.cs @@ -1907,17 +1907,17 @@ class Base int field = 0; public virtual int Proprty1 { get { return 0; } } - public virtual ref int Property2 { get { return ref field; } } - public virtual ref int Property3 { get { return ref field; } } + public virtual ref int Property2 { get { return ref @field; } } + public virtual ref int Property3 { get { return ref @field; } } } class Derived : Base { int field = 0; - public override ref int Proprty1 { get { return ref field; } } + public override ref int Proprty1 { get { return ref @field; } } public override int Property2 { get { return 0; } } - public override ref int Property3 { get { return ref field; } } + public override ref int Property3 { get { return ref @field; } } } "; CreateCompilationWithMscorlib45(text).VerifyDiagnostics( diff --git a/src/Compilers/CSharp/Test/Semantic/Semantics/LambdaTests.cs b/src/Compilers/CSharp/Test/Semantic/Semantics/LambdaTests.cs index 645bfc7417e12..c4603025d3465 100644 --- a/src/Compilers/CSharp/Test/Semantic/Semantics/LambdaTests.cs +++ b/src/Compilers/CSharp/Test/Semantic/Semantics/LambdaTests.cs @@ -4742,7 +4742,7 @@ public void NullableTypeArraySwitchPattern() class C { object? field; - string Prop => field switch + string Prop => @field switch { string?[] a => ""a"" }; @@ -4752,9 +4752,9 @@ class C // (4,13): warning CS0649: Field 'C.field' is never assigned to, and will always have its default value null // object? field; Diagnostic(ErrorCode.WRN_UnassignedInternalField, "field").WithArguments("C.field", "null").WithLocation(4, 13), - // (5,26): warning CS8509: The switch expression does not handle all possible values of its input type (it is not exhaustive). For example, the pattern '_' is not covered. - // string Prop => field switch - Diagnostic(ErrorCode.WRN_SwitchExpressionNotExhaustive, "switch").WithArguments("_").WithLocation(5, 26)); + // (5,27): warning CS8509: The switch expression does not handle all possible values of its input type (it is not exhaustive). For example, the pattern '_' is not covered. + // string Prop => @field switch + Diagnostic(ErrorCode.WRN_SwitchExpressionNotExhaustive, "switch").WithArguments("_").WithLocation(5, 27)); } [Fact, WorkItem(52827, "https://github.com/dotnet/roslyn/issues/52827")] @@ -7344,7 +7344,7 @@ public void LambdaWithNonConstantDefault() class C { object field; - public object Field => field; + public object Field => @field; public C(object f) { field = f; } @@ -7373,7 +7373,7 @@ public void AnonymousMethodWithNonConstantDefault() class C { object field; - public object Field => field; + public object Field => @field; public C(object f) { field = f; } diff --git a/src/Compilers/CSharp/Test/Semantic/Semantics/NullableReferenceTypesTests.cs b/src/Compilers/CSharp/Test/Semantic/Semantics/NullableReferenceTypesTests.cs index acc45c67ba330..4d3054f38cf56 100644 --- a/src/Compilers/CSharp/Test/Semantic/Semantics/NullableReferenceTypesTests.cs +++ b/src/Compilers/CSharp/Test/Semantic/Semantics/NullableReferenceTypesTests.cs @@ -22615,7 +22615,7 @@ public void MemberNotNull_NotFound_PrivateInBase() public class Base { private string? field; - public string? P { get { return field; } set { field = value; } } + public string? P { get { return @field; } set { @field = value; } } } public class C : Base { @@ -156308,7 +156308,7 @@ class C public string? field = null; [MemberNotNullWhen(true, ""field"")] - public System.Nullable Init => field != null; + public System.Nullable Init => @field != null; public void M() { @@ -156349,7 +156349,7 @@ class C public string? field = null; [MemberNotNullWhen(true, ""field"")] - public bool Init => field != null; + public bool Init => @field != null; public void M() { @@ -156387,7 +156387,7 @@ class C public string? field = null; [MemberNotNullWhen(true, ""field"")] - public System.Nullable Init => field != null; + public System.Nullable Init => @field != null; public void M() { diff --git a/src/Compilers/CSharp/Test/Semantic/Semantics/RefFieldTests.cs b/src/Compilers/CSharp/Test/Semantic/Semantics/RefFieldTests.cs index f037d2a226ec2..fa8b87aff98a1 100644 --- a/src/Compilers/CSharp/Test/Semantic/Semantics/RefFieldTests.cs +++ b/src/Compilers/CSharp/Test/Semantic/Semantics/RefFieldTests.cs @@ -19777,17 +19777,17 @@ ref struct S { public int field; public ref int refField; - ref int Prop1 => ref field; // 1 + ref int Prop1 => ref @field; // 1 [UnscopedRef] - ref int Prop2 => ref field; // okay + ref int Prop2 => ref @field; // okay S2 Prop3 => new S2 { S = this }; // Okay - S Prop4 => new S { refField = ref this.field }; // 2 + S Prop4 => new S { refField = ref this.@field }; // 2 [UnscopedRef] - S Prop5 => new S { refField = ref this.field }; // okay + S Prop5 => new S { refField = ref this.@field }; // okay S M1() => new S { refField = ref this.field }; // 3 @@ -19803,11 +19803,11 @@ ref struct S { var comp = CreateCompilation(source, targetFramework: TargetFramework.Net70); comp.VerifyDiagnostics( // (11,26): error CS8170: Struct members cannot return 'this' or other instance members by reference - // ref int Prop1 => ref field; // 1 - Diagnostic(ErrorCode.ERR_RefReturnStructThis, "field").WithLocation(11, 26), + // ref int Prop1 => ref @field; // 1 + Diagnostic(ErrorCode.ERR_RefReturnStructThis, "@field").WithLocation(11, 26), // (18,24): error CS8170: Struct members cannot return 'this' or other instance members by reference - // S Prop4 => new S { refField = ref this.field }; // 2 - Diagnostic(ErrorCode.ERR_RefReturnStructThis, "refField = ref this.field").WithLocation(18, 24), + // S Prop4 => new S { refField = ref this.@field }; // 2 + Diagnostic(ErrorCode.ERR_RefReturnStructThis, "refField = ref this.@field").WithLocation(18, 24), // (23,23): error CS8170: Struct members cannot return 'this' or other instance members by reference // S M1() => new S { refField = ref this.field }; // 3 Diagnostic(ErrorCode.ERR_RefReturnStructThis, "refField = ref this.field").WithLocation(23, 23), diff --git a/src/Compilers/CSharp/Test/Semantic/Semantics/RefLocalsAndReturnsTests.cs b/src/Compilers/CSharp/Test/Semantic/Semantics/RefLocalsAndReturnsTests.cs index 7299939536559..8dc2ac17f2146 100644 --- a/src/Compilers/CSharp/Test/Semantic/Semantics/RefLocalsAndReturnsTests.cs +++ b/src/Compilers/CSharp/Test/Semantic/Semantics/RefLocalsAndReturnsTests.cs @@ -4341,7 +4341,7 @@ class C { int field = 0; - ref int P { get { return ref field; } } + ref int P { get { return ref @field; } } ref int this[int i] { get { return ref field; } } ref int M() { return ref field; } diff --git a/src/Compilers/CSharp/Test/Semantic/Semantics/SemanticErrorTests.cs b/src/Compilers/CSharp/Test/Semantic/Semantics/SemanticErrorTests.cs index 780a3ed6dcbb2..6b9d8dbbb42ec 100644 --- a/src/Compilers/CSharp/Test/Semantic/Semantics/SemanticErrorTests.cs +++ b/src/Compilers/CSharp/Test/Semantic/Semantics/SemanticErrorTests.cs @@ -4010,10 +4010,10 @@ static void N(int q) // (24,17): error CS0136: A local or parameter named 'value' cannot be declared in this scope because that name is used in an enclosing local scope to define a local or parameter // int value = 0; // CS0136 Diagnostic(ErrorCode.ERR_LocalIllegallyOverrides, "value").WithArguments("value").WithLocation(24, 17), - // (24,17): info CS9258: 'value' is a contextual keyword, with a specific meaning, starting in language version preview. Use '@value' to avoid a breaking change when compiling with language version preview or later. + // (24,17): info CS9258: 'value' is a contextual keyword in property accessors starting in language version preview. Use '@value' instead. // int value = 0; // CS0136 Diagnostic(ErrorCode.INF_IdentifierConflictWithContextualKeyword, "value = 0").WithArguments("value", "preview").WithLocation(24, 17), - // (25,15): info CS9258: 'value' is a contextual keyword, with a specific meaning, starting in language version preview. Use '@value' to avoid a breaking change when compiling with language version preview or later. + // (25,15): info CS9258: 'value' is a contextual keyword in property accessors starting in language version preview. Use '@value' instead. // M(value); Diagnostic(ErrorCode.INF_IdentifierConflictWithContextualKeyword, "value").WithArguments("value", "preview").WithLocation(25, 15), // (30,35): error CS0136: A local or parameter named 'q' cannot be declared in this scope because that name is used in an enclosing local scope to define a local or parameter @@ -4028,9 +4028,15 @@ static void N(int q) // (9,17): error CS0136: A local or parameter named 'y' cannot be declared in this scope because that name is used in an enclosing local scope to define a local or parameter // int y = 0; // CS0136 Diagnostic(ErrorCode.ERR_LocalIllegallyOverrides, "y").WithArguments("y").WithLocation(9, 17), + // (24,17): info CS9258: 'value' is a contextual keyword in property accessors starting in language version preview. Use '@value' instead. + // int value = 0; // CS0136 + Diagnostic(ErrorCode.INF_IdentifierConflictWithContextualKeyword, "value = 0").WithArguments("value", "preview").WithLocation(24, 17), // (24,17): error CS0136: A local or parameter named 'value' cannot be declared in this scope because that name is used in an enclosing local scope to define a local or parameter // int value = 0; // CS0136 - Diagnostic(ErrorCode.ERR_LocalIllegallyOverrides, "value").WithArguments("value").WithLocation(24, 17)); + Diagnostic(ErrorCode.ERR_LocalIllegallyOverrides, "value").WithArguments("value").WithLocation(24, 17), + // (25,15): info CS9258: 'value' is a contextual keyword in property accessors starting in language version preview. Use '@value' instead. + // M(value); + Diagnostic(ErrorCode.INF_IdentifierConflictWithContextualKeyword, "value").WithArguments("value", "preview").WithLocation(25, 15)); } [Fact] diff --git a/src/Compilers/CSharp/Test/Symbol/Symbols/InterfaceOverriddenOrHiddenMembersTests.cs b/src/Compilers/CSharp/Test/Symbol/Symbols/InterfaceOverriddenOrHiddenMembersTests.cs index 69c6ba4f789db..fdcc6b20cc275 100644 --- a/src/Compilers/CSharp/Test/Symbol/Symbols/InterfaceOverriddenOrHiddenMembersTests.cs +++ b/src/Compilers/CSharp/Test/Symbol/Symbols/InterfaceOverriddenOrHiddenMembersTests.cs @@ -1194,7 +1194,7 @@ class DerivedClass : BaseInterface { protected int field; public ref readonly int Method1(in int a) { return ref field; } - public ref readonly int Property1 { get { return ref field; } } + public ref readonly int Property1 { get { return ref @field; } } public ref readonly int this[int a] { get { return ref field; } } }"; diff --git a/src/Compilers/CSharp/Test/Symbol/Symbols/OverriddenOrHiddenMembersTests.cs b/src/Compilers/CSharp/Test/Symbol/Symbols/OverriddenOrHiddenMembersTests.cs index 8e5409c016121..43d9407d60ae9 100644 --- a/src/Compilers/CSharp/Test/Symbol/Symbols/OverriddenOrHiddenMembersTests.cs +++ b/src/Compilers/CSharp/Test/Symbol/Symbols/OverriddenOrHiddenMembersTests.cs @@ -802,7 +802,7 @@ class Base2 : Base { A field = default(A); public override A Property { set { } } - public override ref A RefProperty { get { return ref field; } } + public override ref A RefProperty { get { return ref @field; } } } abstract class Base3 : Base2 @@ -4362,14 +4362,14 @@ class BaseClass { protected int field; public virtual ref readonly int Method1(in BaseClass a) { return ref field; } - public virtual ref readonly int Property1 { get { return ref field; } } + public virtual ref readonly int Property1 { get { return ref @field; } } public virtual ref readonly int this[int a] { get { return ref field; } } } class DerivedClass : BaseClass { public override ref readonly int Method1(in BaseClass a) { return ref field; } - public override ref readonly int Property1 { get { return ref field; } } + public override ref readonly int Property1 { get { return ref @field; } } public override ref readonly int this[int a] { get { return ref field; } } }"; diff --git a/src/Compilers/CSharp/Test/Symbol/Symbols/Source/ExpressionBodiedPropertyTests.cs b/src/Compilers/CSharp/Test/Symbol/Symbols/Source/ExpressionBodiedPropertyTests.cs index ad857ae71ef04..c026c48a2251b 100644 --- a/src/Compilers/CSharp/Test/Symbol/Symbols/Source/ExpressionBodiedPropertyTests.cs +++ b/src/Compilers/CSharp/Test/Symbol/Symbols/Source/ExpressionBodiedPropertyTests.cs @@ -496,7 +496,7 @@ public void RefReturningExpressionBodiedProperty() class C { int field = 0; - public ref int P => ref field; + public ref int P => ref @field; }"); comp.VerifyDiagnostics(); @@ -519,7 +519,7 @@ public void RefReadonlyReturningExpressionBodiedProperty() class C { int field = 0; - public ref readonly int P => ref field; + public ref readonly int P => ref @field; }"); comp.VerifyDiagnostics(); diff --git a/src/Compilers/CSharp/Test/Symbol/Symbols/Source/PropertyTests.cs b/src/Compilers/CSharp/Test/Symbol/Symbols/Source/PropertyTests.cs index 87b1257877968..9cb17023809c6 100644 --- a/src/Compilers/CSharp/Test/Symbol/Symbols/Source/PropertyTests.cs +++ b/src/Compilers/CSharp/Test/Symbol/Symbols/Source/PropertyTests.cs @@ -2922,14 +2922,14 @@ public void RefPropertyWithGetterAndSetter() class C { int field = 0; - ref int P { get { return ref field; } set { } } + ref int P { get { return ref @field; } set { } } } "; CreateCompilationWithMscorlib45(source).VerifyDiagnostics( - // (5,47): error CS8081: Properties with by-reference returns cannot have set accessors. - // ref int P { get { return ref field; } set { } } - Diagnostic(ErrorCode.ERR_RefPropertyCannotHaveSetAccessor, "set").WithLocation(5, 47)); + // (5,48): error CS8147: Properties which return by reference cannot have set accessors + // ref int P { get { return ref @field; } set { } } + Diagnostic(ErrorCode.ERR_RefPropertyCannotHaveSetAccessor, "set").WithLocation(5, 48)); } [Fact, WorkItem(4696, "https://github.com/dotnet/roslyn/issues/4696")] diff --git a/src/Compilers/CSharp/Test/Symbol/Symbols/SymbolErrorTests.cs b/src/Compilers/CSharp/Test/Symbol/Symbols/SymbolErrorTests.cs index 97aca352abf83..0eae9509c6c3e 100644 --- a/src/Compilers/CSharp/Test/Symbol/Symbols/SymbolErrorTests.cs +++ b/src/Compilers/CSharp/Test/Symbol/Symbols/SymbolErrorTests.cs @@ -2486,12 +2486,24 @@ public byte MyProp "; CreateCompilation(text). VerifyDiagnostics( - Diagnostic(ErrorCode.ERR_LocalIllegallyOverrides, "a").WithArguments("a"), - Diagnostic(ErrorCode.WRN_UnreferencedVar, "a").WithArguments("a"), - Diagnostic(ErrorCode.ERR_LocalIllegallyOverrides, "x").WithArguments("x"), - Diagnostic(ErrorCode.ERR_LocalIllegallyOverrides, "value").WithArguments("value"), - Diagnostic(ErrorCode.WRN_UnreferencedVar, "value").WithArguments("value") - ); + // (7,14): error CS0136: A local or parameter named 'a' cannot be declared in this scope because that name is used in an enclosing local scope to define a local or parameter + // long a; // 0136 + Diagnostic(ErrorCode.ERR_LocalIllegallyOverrides, "a").WithArguments("a").WithLocation(7, 14), + // (7,14): warning CS0168: The variable 'a' is declared but never used + // long a; // 0136 + Diagnostic(ErrorCode.WRN_UnreferencedVar, "a").WithArguments("a").WithLocation(7, 14), + // (12,14): error CS0136: A local or parameter named 'x' cannot be declared in this scope because that name is used in an enclosing local scope to define a local or parameter + // long x = 1; // 0136 + Diagnostic(ErrorCode.ERR_LocalIllegallyOverrides, "x").WithArguments("x").WithLocation(12, 14), + // (20,17): info CS9258: 'value' is a contextual keyword in property accessors starting in language version preview. Use '@value' instead. + // int value; // 0136 + Diagnostic(ErrorCode.INF_IdentifierConflictWithContextualKeyword, "value").WithArguments("value", "preview").WithLocation(20, 17), + // (20,17): error CS0136: A local or parameter named 'value' cannot be declared in this scope because that name is used in an enclosing local scope to define a local or parameter + // int value; // 0136 + Diagnostic(ErrorCode.ERR_LocalIllegallyOverrides, "value").WithArguments("value").WithLocation(20, 17), + // (20,17): warning CS0168: The variable 'value' is declared but never used + // int value; // 0136 + Diagnostic(ErrorCode.WRN_UnreferencedVar, "value").WithArguments("value").WithLocation(20, 17)); } [Fact] diff --git a/src/Compilers/CSharp/Test/Syntax/Syntax/FieldAndValueKeywordTests.cs b/src/Compilers/CSharp/Test/Syntax/Syntax/FieldAndValueKeywordTests.cs index 5532bd92677d2..d480140254fdf 100644 --- a/src/Compilers/CSharp/Test/Syntax/Syntax/FieldAndValueKeywordTests.cs +++ b/src/Compilers/CSharp/Test/Syntax/Syntax/FieldAndValueKeywordTests.cs @@ -5,7 +5,6 @@ #nullable disable using Microsoft.CodeAnalysis.CSharp.Test.Utilities; -using Roslyn.Test.Utilities; using Xunit; namespace Microsoft.CodeAnalysis.CSharp.UnitTests @@ -34,23 +33,23 @@ class D2 : A { object this[int i] { get => {{identifier}}; } } class D4 : A { object this[int i] { set { {{identifier}} = 0; } } } """; var comp = CreateCompilation(source, parseOptions: TestOptions.Regular.WithLanguageVersion(languageVersion)); - if (escapeIdentifier || languageVersion > LanguageVersion.CSharp12) + if (escapeIdentifier) { comp.VerifyEmitDiagnostics(); } else { comp.VerifyEmitDiagnostics( - // (4,28): info CS9258: 'field' is a contextual keyword, with a specific meaning, starting in language version preview. Use '@field' to avoid a breaking change when compiling with language version preview or later. + // (4,28): info CS9258: 'field' is a contextual keyword in property accessors starting in language version preview. Use '@field' instead. // class C1 : A { object P => field; } Diagnostic(ErrorCode.INF_IdentifierConflictWithContextualKeyword, "field").WithArguments("field", "preview").WithLocation(4, 28), - // (5,34): info CS9258: 'field' is a contextual keyword, with a specific meaning, starting in language version preview. Use '@field' to avoid a breaking change when compiling with language version preview or later. + // (5,34): info CS9258: 'field' is a contextual keyword in property accessors starting in language version preview. Use '@field' instead. // class C2 : A { object P { get => field; } } Diagnostic(ErrorCode.INF_IdentifierConflictWithContextualKeyword, "field").WithArguments("field", "preview").WithLocation(5, 34), - // (6,40): info CS9258: 'field' is a contextual keyword, with a specific meaning, starting in language version preview. Use '@field' to avoid a breaking change when compiling with language version preview or later. + // (6,40): info CS9258: 'field' is a contextual keyword in property accessors starting in language version preview. Use '@field' instead. // class C3 : A { object P { get { return field; } } } Diagnostic(ErrorCode.INF_IdentifierConflictWithContextualKeyword, "field").WithArguments("field", "preview").WithLocation(6, 40), - // (7,33): info CS9258: 'field' is a contextual keyword, with a specific meaning, starting in language version preview. Use '@field' to avoid a breaking change when compiling with language version preview or later. + // (7,33): info CS9258: 'field' is a contextual keyword in property accessors starting in language version preview. Use '@field' instead. // class C4 : A { object P { set { field = 0; } } } Diagnostic(ErrorCode.INF_IdentifierConflictWithContextualKeyword, "field").WithArguments("field", "preview").WithLocation(7, 33)); } @@ -102,17 +101,17 @@ class D2 : A { object this[int i] { get => this.{{identifier}}; } } class D4 : A { object this[int i] { set { this.{{identifier}} = 0; } } } """; var comp = CreateCompilation(source, parseOptions: TestOptions.Regular.WithLanguageVersion(languageVersion)); - if (escapeIdentifier || languageVersion > LanguageVersion.CSharp12) + if (escapeIdentifier) { comp.VerifyEmitDiagnostics(); } else { comp.VerifyEmitDiagnostics( - // (6,38): info CS9258: 'value' is a contextual keyword, with a specific meaning, starting in language version preview. Use '@value' to avoid a breaking change when compiling with language version preview or later. + // (6,38): info CS9258: 'value' is a contextual keyword in property accessors starting in language version preview. Use '@value' instead. // class C4 : A { object P { set { this.value = 0; } } } Diagnostic(ErrorCode.INF_IdentifierConflictWithContextualKeyword, "value").WithArguments("value", "preview").WithLocation(6, 38), - // (10,48): info CS9258: 'value' is a contextual keyword, with a specific meaning, starting in language version preview. Use '@value' to avoid a breaking change when compiling with language version preview or later. + // (10,48): info CS9258: 'value' is a contextual keyword in property accessors starting in language version preview. Use '@value' instead. // class D4 : A { object this[int i] { set { this.value = 0; } } } Diagnostic(ErrorCode.INF_IdentifierConflictWithContextualKeyword, "value").WithArguments("value", "preview").WithLocation(10, 48)); } @@ -191,7 +190,7 @@ object this[int @value] // (6,19): error CS0229: Ambiguity between 'int value' and 'object value' // set { _ = value; } Diagnostic(ErrorCode.ERR_AmbigMember, "value").WithArguments("int value", "object value").WithLocation(6, 19), - // (6,19): info CS9258: 'value' is a contextual keyword, with a specific meaning, starting in language version preview. Use '@value' to avoid a breaking change when compiling with language version preview or later. + // (6,19): info CS9258: 'value' is a contextual keyword in property accessors starting in language version preview. Use '@value' instead. // set { _ = value; } Diagnostic(ErrorCode.INF_IdentifierConflictWithContextualKeyword, "value").WithArguments("value", "preview").WithLocation(6, 19), // (11,21): error CS0316: The parameter name 'value' conflicts with an automatically-generated parameter name @@ -232,20 +231,13 @@ event EventHandler E3 } """; var comp = CreateCompilation(source, parseOptions: TestOptions.Regular.WithLanguageVersion(languageVersion)); - if (languageVersion > LanguageVersion.CSharp12) - { - comp.VerifyEmitDiagnostics(); - } - else - { - comp.VerifyEmitDiagnostics( - // (14,21): info CS9258: 'value' is a contextual keyword, with a specific meaning, starting in language version preview. Use '@value' to avoid a breaking change when compiling with language version preview or later. - // add { _ = C.value ?? C.@value; } - Diagnostic(ErrorCode.INF_IdentifierConflictWithContextualKeyword, "value").WithArguments("value", "preview").WithLocation(14, 21), - // (15,36): info CS9258: 'value' is a contextual keyword, with a specific meaning, starting in language version preview. Use '@value' to avoid a breaking change when compiling with language version preview or later. - // remove { _ = C.@value ?? C.value; } - Diagnostic(ErrorCode.INF_IdentifierConflictWithContextualKeyword, "value").WithArguments("value", "preview").WithLocation(15, 36)); - } + comp.VerifyEmitDiagnostics( + // (14,21): info CS9258: 'value' is a contextual keyword in property accessors starting in language version preview. Use '@value' instead. + // add { _ = C.value ?? C.@value; } + Diagnostic(ErrorCode.INF_IdentifierConflictWithContextualKeyword, "value").WithArguments("value", "preview").WithLocation(14, 21), + // (15,36): info CS9258: 'value' is a contextual keyword in property accessors starting in language version preview. Use '@value' instead. + // remove { _ = C.@value ?? C.value; } + Diagnostic(ErrorCode.INF_IdentifierConflictWithContextualKeyword, "value").WithArguments("value", "preview").WithLocation(15, 36)); } [Theory] @@ -270,17 +262,17 @@ class C : I } """; var comp = CreateCompilation(source, parseOptions: TestOptions.Regular.WithLanguageVersion(languageVersion)); - if (escapeIdentifier || languageVersion > LanguageVersion.CSharp12) + if (escapeIdentifier) { comp.VerifyEmitDiagnostics(); } else { comp.VerifyEmitDiagnostics( - // (10,25): info CS9258: 'field' is a contextual keyword, with a specific meaning, starting in language version preview. Use '@field' to avoid a breaking change when compiling with language version preview or later. + // (10,25): info CS9258: 'field' is a contextual keyword in property accessors starting in language version preview. Use '@field' instead. // object I.P { get => field; set { _ = field; } } Diagnostic(ErrorCode.INF_IdentifierConflictWithContextualKeyword, "field").WithArguments("field", "preview").WithLocation(10, 25), - // (10,42): info CS9258: 'field' is a contextual keyword, with a specific meaning, starting in language version preview. Use '@field' to avoid a breaking change when compiling with language version preview or later. + // (10,42): info CS9258: 'field' is a contextual keyword in property accessors starting in language version preview. Use '@field' instead. // object I.P { get => field; set { _ = field; } } Diagnostic(ErrorCode.INF_IdentifierConflictWithContextualKeyword, "field").WithArguments("field", "preview").WithLocation(10, 42)); } @@ -308,17 +300,17 @@ class C : I } """; var comp = CreateCompilation(source, parseOptions: TestOptions.Regular.WithLanguageVersion(languageVersion)); - if (escapeIdentifier || languageVersion > LanguageVersion.CSharp12) + if (escapeIdentifier) { comp.VerifyEmitDiagnostics(); } else { comp.VerifyEmitDiagnostics( - // (10,52): info CS9258: 'value' is a contextual keyword, with a specific meaning, starting in language version preview. Use '@value' to avoid a breaking change when compiling with language version preview or later. + // (10,52): info CS9258: 'value' is a contextual keyword in property accessors starting in language version preview. Use '@value' instead. // object I.P { get => this.value; set { _ = this.value; } } Diagnostic(ErrorCode.INF_IdentifierConflictWithContextualKeyword, "value").WithArguments("value", "preview").WithLocation(10, 52), - // (11,62): info CS9258: 'value' is a contextual keyword, with a specific meaning, starting in language version preview. Use '@value' to avoid a breaking change when compiling with language version preview or later. + // (11,62): info CS9258: 'value' is a contextual keyword in property accessors starting in language version preview. Use '@value' instead. // object I.this[int i] { get => this.value; set { _ = this.value; } } Diagnostic(ErrorCode.INF_IdentifierConflictWithContextualKeyword, "value").WithArguments("value", "preview").WithLocation(11, 62)); } @@ -327,6 +319,44 @@ class C : I [Theory] [CombinatorialData] public void ExplicitImplementation_03( + [CombinatorialValues(LanguageVersion.CSharp12, LanguageVersion.Preview)] LanguageVersion languageVersion, + bool escapeIdentifier) + { + string identifier = escapeIdentifier ? "@field" : "field"; + string source = $$""" + #pragma warning disable 649 + interface I + { + object P { get; set; } + object this[int i] { get; set; } + } + class C : I + { + int field; + object I.P { get => this.{{identifier}}; set { _ = this.{{identifier}}; } } + object I.this[int i] { get => this.{{identifier}}; set { _ = this.{{identifier}}; } } + } + """; + var comp = CreateCompilation(source, parseOptions: TestOptions.Regular.WithLanguageVersion(languageVersion)); + if (escapeIdentifier) + { + comp.VerifyEmitDiagnostics(); + } + else + { + comp.VerifyEmitDiagnostics( + // (10,30): info CS9258: 'field' is a contextual keyword, with a specific meaning, starting in language version preview. Use '@field' to avoid a breaking change when compiling with language version preview or later. + // object I.P { get => this.field; set { _ = this.field; } } + Diagnostic(ErrorCode.INF_IdentifierConflictWithContextualKeyword, "field").WithArguments("field", "preview").WithLocation(10, 30), + // (10,52): info CS9258: 'field' is a contextual keyword, with a specific meaning, starting in language version preview. Use '@field' to avoid a breaking change when compiling with language version preview or later. + // object I.P { get => this.field; set { _ = this.field; } } + Diagnostic(ErrorCode.INF_IdentifierConflictWithContextualKeyword, "field").WithArguments("field", "preview").WithLocation(10, 52)); + } + } + + [Theory] + [CombinatorialData] + public void ExplicitImplementation_04( [CombinatorialValues(LanguageVersion.CSharp12, LanguageVersion.Preview)] LanguageVersion languageVersion, [CombinatorialValues("field", "value")] string identifier, bool escapeIdentifier) @@ -350,17 +380,17 @@ event EventHandler I.E } """; var comp = CreateCompilation(source, parseOptions: TestOptions.Regular.WithLanguageVersion(languageVersion)); - if (escapeIdentifier || identifier == "field" || languageVersion > LanguageVersion.CSharp12) + if (escapeIdentifier || identifier == "field") { comp.VerifyEmitDiagnostics(); } else { comp.VerifyEmitDiagnostics( - // (12,24): info CS9258: 'value' is a contextual keyword, with a specific meaning, starting in language version preview. Use '@value' to avoid a breaking change when compiling with language version preview or later. + // (12,24): info CS9258: 'value' is a contextual keyword in property accessors starting in language version preview. Use '@value' instead. // add { _ = this.value; } Diagnostic(ErrorCode.INF_IdentifierConflictWithContextualKeyword, "value").WithArguments("value", "preview").WithLocation(12, 24), - // (13,27): info CS9258: 'value' is a contextual keyword, with a specific meaning, starting in language version preview. Use '@value' to avoid a breaking change when compiling with language version preview or later. + // (13,27): info CS9258: 'value' is a contextual keyword in property accessors starting in language version preview. Use '@value' instead. // remove { _ = this.value; } Diagnostic(ErrorCode.INF_IdentifierConflictWithContextualKeyword, "value").WithArguments("value", "preview").WithLocation(13, 27)); } @@ -384,20 +414,13 @@ class C } """; var comp = CreateCompilation(source, parseOptions: TestOptions.Regular.WithLanguageVersion(languageVersion)); - if (languageVersion > LanguageVersion.CSharp12) - { - comp.VerifyEmitDiagnostics(); - } - else - { - comp.VerifyEmitDiagnostics( - // (6,34): info CS9258: 'field' is a contextual keyword, with a specific meaning, starting in language version preview. Use '@field' to avoid a breaking change when compiling with language version preview or later. - // object P1 { get { return new field(); } } - Diagnostic(ErrorCode.INF_IdentifierConflictWithContextualKeyword, "field").WithArguments("field", "preview").WithLocation(6, 34), - // (8,31): info CS9258: 'value' is a contextual keyword, with a specific meaning, starting in language version preview. Use '@value' to avoid a breaking change when compiling with language version preview or later. - // object P3 { set { _ = new value(); } } - Diagnostic(ErrorCode.INF_IdentifierConflictWithContextualKeyword, "value").WithArguments("value", "preview").WithLocation(8, 31)); - } + comp.VerifyEmitDiagnostics( + // (6,34): info CS9258: 'field' is a contextual keyword in property accessors starting in language version preview. Use '@field' instead. + // object P1 { get { return new field(); } } + Diagnostic(ErrorCode.INF_IdentifierConflictWithContextualKeyword, "field").WithArguments("field", "preview").WithLocation(6, 34), + // (8,31): info CS9258: 'value' is a contextual keyword in property accessors starting in language version preview. Use '@value' instead. + // object P3 { set { _ = new value(); } } + Diagnostic(ErrorCode.INF_IdentifierConflictWithContextualKeyword, "value").WithArguments("value", "preview").WithLocation(8, 31)); } [Theory] @@ -418,20 +441,13 @@ class C } """; var comp = CreateCompilation(source, parseOptions: TestOptions.Regular.WithLanguageVersion(languageVersion)); - if (languageVersion > LanguageVersion.CSharp12) - { - comp.VerifyEmitDiagnostics(); - } - else - { - comp.VerifyEmitDiagnostics( - // (6,34): info CS9258: 'field' is a contextual keyword, with a specific meaning, starting in language version preview. Use '@field' to avoid a breaking change when compiling with language version preview or later. - // object P1 { get { return new field(); } } - Diagnostic(ErrorCode.INF_IdentifierConflictWithContextualKeyword, "field").WithArguments("field", "preview").WithLocation(6, 34), - // (8,31): info CS9258: 'value' is a contextual keyword, with a specific meaning, starting in language version preview. Use '@value' to avoid a breaking change when compiling with language version preview or later. - // object P3 { set { _ = new value(); } } - Diagnostic(ErrorCode.INF_IdentifierConflictWithContextualKeyword, "value").WithArguments("value", "preview").WithLocation(8, 31)); - } + comp.VerifyEmitDiagnostics( + // (6,34): info CS9258: 'field' is a contextual keyword in property accessors starting in language version preview. Use '@field' instead. + // object P1 { get { return new field(); } } + Diagnostic(ErrorCode.INF_IdentifierConflictWithContextualKeyword, "field").WithArguments("field", "preview").WithLocation(6, 34), + // (8,31): info CS9258: 'value' is a contextual keyword in property accessors starting in language version preview. Use '@value' instead. + // object P3 { set { _ = new value(); } } + Diagnostic(ErrorCode.INF_IdentifierConflictWithContextualKeyword, "value").WithArguments("value", "preview").WithLocation(8, 31)); } [Theory] @@ -448,20 +464,13 @@ class C } """; var comp = CreateCompilation(source, parseOptions: TestOptions.Regular.WithLanguageVersion(languageVersion)); - if (languageVersion > LanguageVersion.CSharp12) - { - comp.VerifyEmitDiagnostics(); - } - else - { - comp.VerifyEmitDiagnostics( - // (4,24): info CS9258: 'field' is a contextual keyword, with a specific meaning, starting in language version preview. Use '@field' to avoid a breaking change when compiling with language version preview or later. - // object P3 { set { (int field, int value) t = default; } } - Diagnostic(ErrorCode.INF_IdentifierConflictWithContextualKeyword, "int field").WithArguments("field", "preview").WithLocation(4, 24), - // (4,35): info CS9258: 'value' is a contextual keyword, with a specific meaning, starting in language version preview. Use '@value' to avoid a breaking change when compiling with language version preview or later. - // object P3 { set { (int field, int value) t = default; } } - Diagnostic(ErrorCode.INF_IdentifierConflictWithContextualKeyword, "int value").WithArguments("value", "preview").WithLocation(4, 35)); - } + comp.VerifyEmitDiagnostics( + // (4,24): info CS9258: 'field' is a contextual keyword in property accessors starting in language version preview. Use '@field' instead. + // object P3 { set { (int field, int value) t = default; } } + Diagnostic(ErrorCode.INF_IdentifierConflictWithContextualKeyword, "int field").WithArguments("field", "preview").WithLocation(4, 24), + // (4,35): info CS9258: 'value' is a contextual keyword in property accessors starting in language version preview. Use '@value' instead. + // object P3 { set { (int field, int value) t = default; } } + Diagnostic(ErrorCode.INF_IdentifierConflictWithContextualKeyword, "int value").WithArguments("value", "preview").WithLocation(4, 35)); } [Theory] @@ -480,38 +489,25 @@ class C } """; var comp = CreateCompilation(source, parseOptions: TestOptions.Regular.WithLanguageVersion(languageVersion)); - if (languageVersion > LanguageVersion.CSharp12) - { - comp.VerifyEmitDiagnostics( - // (6,32): error CS1931: The range variable 'value' conflicts with a previous declaration of 'value' - // object P3 { set { _ = from value in new int[0] select value; } } - Diagnostic(ErrorCode.ERR_QueryRangeVariableOverrides, "value").WithArguments("value").WithLocation(6, 32), - // (7,32): error CS1931: The range variable 'value' conflicts with a previous declaration of 'value' - // object P4 { set { _ = from @value in new int[0] select @value; } } - Diagnostic(ErrorCode.ERR_QueryRangeVariableOverrides, "@value").WithArguments("value").WithLocation(7, 32)); - } - else - { - comp.VerifyEmitDiagnostics( - // (4,27): info CS9258: 'field' is a contextual keyword, with a specific meaning, starting in language version preview. Use '@field' to avoid a breaking change when compiling with language version preview or later. - // object P1 { get { _ = from field in new int[0] select field; return null; } } - Diagnostic(ErrorCode.INF_IdentifierConflictWithContextualKeyword, "from field in new int[0]").WithArguments("field", "preview").WithLocation(4, 27), - // (4,59): info CS9258: 'field' is a contextual keyword, with a specific meaning, starting in language version preview. Use '@field' to avoid a breaking change when compiling with language version preview or later. - // object P1 { get { _ = from field in new int[0] select field; return null; } } - Diagnostic(ErrorCode.INF_IdentifierConflictWithContextualKeyword, "field").WithArguments("field", "preview").WithLocation(4, 59), - // (6,27): info CS9258: 'value' is a contextual keyword, with a specific meaning, starting in language version preview. Use '@value' to avoid a breaking change when compiling with language version preview or later. - // object P3 { set { _ = from value in new int[0] select value; } } - Diagnostic(ErrorCode.INF_IdentifierConflictWithContextualKeyword, "from value in new int[0]").WithArguments("value", "preview").WithLocation(6, 27), - // (6,32): error CS1931: The range variable 'value' conflicts with a previous declaration of 'value' - // object P3 { set { _ = from value in new int[0] select value; } } - Diagnostic(ErrorCode.ERR_QueryRangeVariableOverrides, "value").WithArguments("value").WithLocation(6, 32), - // (6,59): info CS9258: 'value' is a contextual keyword, with a specific meaning, starting in language version preview. Use '@value' to avoid a breaking change when compiling with language version preview or later. - // object P3 { set { _ = from value in new int[0] select value; } } - Diagnostic(ErrorCode.INF_IdentifierConflictWithContextualKeyword, "value").WithArguments("value", "preview").WithLocation(6, 59), - // (7,32): error CS1931: The range variable 'value' conflicts with a previous declaration of 'value' - // object P4 { set { _ = from @value in new int[0] select @value; } } - Diagnostic(ErrorCode.ERR_QueryRangeVariableOverrides, "@value").WithArguments("value").WithLocation(7, 32)); - } + comp.VerifyEmitDiagnostics( + // (4,27): info CS9258: 'field' is a contextual keyword in property accessors starting in language version preview. Use '@field' instead. + // object P1 { get { _ = from field in new int[0] select field; return null; } } + Diagnostic(ErrorCode.INF_IdentifierConflictWithContextualKeyword, "from field in new int[0]").WithArguments("field", "preview").WithLocation(4, 27), + // (4,59): info CS9258: 'field' is a contextual keyword in property accessors starting in language version preview. Use '@field' instead. + // object P1 { get { _ = from field in new int[0] select field; return null; } } + Diagnostic(ErrorCode.INF_IdentifierConflictWithContextualKeyword, "field").WithArguments("field", "preview").WithLocation(4, 59), + // (6,27): info CS9258: 'value' is a contextual keyword in property accessors starting in language version preview. Use '@value' instead. + // object P3 { set { _ = from value in new int[0] select value; } } + Diagnostic(ErrorCode.INF_IdentifierConflictWithContextualKeyword, "from value in new int[0]").WithArguments("value", "preview").WithLocation(6, 27), + // (6,32): error CS1931: The range variable 'value' conflicts with a previous declaration of 'value' + // object P3 { set { _ = from value in new int[0] select value; } } + Diagnostic(ErrorCode.ERR_QueryRangeVariableOverrides, "value").WithArguments("value").WithLocation(6, 32), + // (6,59): info CS9258: 'value' is a contextual keyword in property accessors starting in language version preview. Use '@value' instead. + // object P3 { set { _ = from value in new int[0] select value; } } + Diagnostic(ErrorCode.INF_IdentifierConflictWithContextualKeyword, "value").WithArguments("value", "preview").WithLocation(6, 59), + // (7,32): error CS1931: The range variable 'value' conflicts with a previous declaration of 'value' + // object P4 { set { _ = from @value in new int[0] select @value; } } + Diagnostic(ErrorCode.ERR_QueryRangeVariableOverrides, "@value").WithArguments("value").WithLocation(7, 32)); } [Theory] @@ -530,38 +526,25 @@ class C } """; var comp = CreateCompilation(source, parseOptions: TestOptions.Regular.WithLanguageVersion(languageVersion)); - if (languageVersion > LanguageVersion.CSharp12) - { - comp.VerifyEmitDiagnostics( - // (6,52): error CS1931: The range variable 'value' conflicts with a previous declaration of 'value' - // object P3 { set { _ = from i in new int[0] let value = i select value; } } - Diagnostic(ErrorCode.ERR_QueryRangeVariableOverrides, "value").WithArguments("value").WithLocation(6, 52), - // (7,52): error CS1931: The range variable 'value' conflicts with a previous declaration of 'value' - // object P4 { set { _ = from i in new int[0] let @value = i select @value; } } - Diagnostic(ErrorCode.ERR_QueryRangeVariableOverrides, "@value").WithArguments("value").WithLocation(7, 52)); - } - else - { - comp.VerifyEmitDiagnostics( - // (4,48): info CS9258: 'field' is a contextual keyword, with a specific meaning, starting in language version preview. Use '@field' to avoid a breaking change when compiling with language version preview or later. - // object P1 { get { _ = from i in new int[0] let field = i select field; return null; } } - Diagnostic(ErrorCode.INF_IdentifierConflictWithContextualKeyword, "let field = i").WithArguments("field", "preview").WithLocation(4, 48), - // (4,69): info CS9258: 'field' is a contextual keyword, with a specific meaning, starting in language version preview. Use '@field' to avoid a breaking change when compiling with language version preview or later. - // object P1 { get { _ = from i in new int[0] let field = i select field; return null; } } - Diagnostic(ErrorCode.INF_IdentifierConflictWithContextualKeyword, "field").WithArguments("field", "preview").WithLocation(4, 69), - // (6,48): info CS9258: 'value' is a contextual keyword, with a specific meaning, starting in language version preview. Use '@value' to avoid a breaking change when compiling with language version preview or later. - // object P3 { set { _ = from i in new int[0] let value = i select value; } } - Diagnostic(ErrorCode.INF_IdentifierConflictWithContextualKeyword, "let value = i").WithArguments("value", "preview").WithLocation(6, 48), - // (6,52): error CS1931: The range variable 'value' conflicts with a previous declaration of 'value' - // object P3 { set { _ = from i in new int[0] let value = i select value; } } - Diagnostic(ErrorCode.ERR_QueryRangeVariableOverrides, "value").WithArguments("value").WithLocation(6, 52), - // (6,69): info CS9258: 'value' is a contextual keyword, with a specific meaning, starting in language version preview. Use '@value' to avoid a breaking change when compiling with language version preview or later. - // object P3 { set { _ = from i in new int[0] let value = i select value; } } - Diagnostic(ErrorCode.INF_IdentifierConflictWithContextualKeyword, "value").WithArguments("value", "preview").WithLocation(6, 69), - // (7,52): error CS1931: The range variable 'value' conflicts with a previous declaration of 'value' - // object P4 { set { _ = from i in new int[0] let @value = i select @value; } } - Diagnostic(ErrorCode.ERR_QueryRangeVariableOverrides, "@value").WithArguments("value").WithLocation(7, 52)); - } + comp.VerifyEmitDiagnostics( + // (4,48): info CS9258: 'field' is a contextual keyword in property accessors starting in language version preview. Use '@field' instead. + // object P1 { get { _ = from i in new int[0] let field = i select field; return null; } } + Diagnostic(ErrorCode.INF_IdentifierConflictWithContextualKeyword, "let field = i").WithArguments("field", "preview").WithLocation(4, 48), + // (4,69): info CS9258: 'field' is a contextual keyword in property accessors starting in language version preview. Use '@field' instead. + // object P1 { get { _ = from i in new int[0] let field = i select field; return null; } } + Diagnostic(ErrorCode.INF_IdentifierConflictWithContextualKeyword, "field").WithArguments("field", "preview").WithLocation(4, 69), + // (6,48): info CS9258: 'value' is a contextual keyword in property accessors starting in language version preview. Use '@value' instead. + // object P3 { set { _ = from i in new int[0] let value = i select value; } } + Diagnostic(ErrorCode.INF_IdentifierConflictWithContextualKeyword, "let value = i").WithArguments("value", "preview").WithLocation(6, 48), + // (6,52): error CS1931: The range variable 'value' conflicts with a previous declaration of 'value' + // object P3 { set { _ = from i in new int[0] let value = i select value; } } + Diagnostic(ErrorCode.ERR_QueryRangeVariableOverrides, "value").WithArguments("value").WithLocation(6, 52), + // (6,69): info CS9258: 'value' is a contextual keyword in property accessors starting in language version preview. Use '@value' instead. + // object P3 { set { _ = from i in new int[0] let value = i select value; } } + Diagnostic(ErrorCode.INF_IdentifierConflictWithContextualKeyword, "value").WithArguments("value", "preview").WithLocation(6, 69), + // (7,52): error CS1931: The range variable 'value' conflicts with a previous declaration of 'value' + // object P4 { set { _ = from i in new int[0] let @value = i select @value; } } + Diagnostic(ErrorCode.ERR_QueryRangeVariableOverrides, "@value").WithArguments("value").WithLocation(7, 52)); } [Theory] @@ -580,38 +563,25 @@ class C } """; var comp = CreateCompilation(source, parseOptions: TestOptions.Regular.WithLanguageVersion(languageVersion)); - if (languageVersion > LanguageVersion.CSharp12) - { - comp.VerifyEmitDiagnostics( - // (6,53): error CS1931: The range variable 'value' conflicts with a previous declaration of 'value' - // object P3 { set { _ = from x in new int[0] join value in new int[0] on x equals value select x; } } - Diagnostic(ErrorCode.ERR_QueryRangeVariableOverrides, "value").WithArguments("value").WithLocation(6, 53), - // (7,53): error CS1931: The range variable 'value' conflicts with a previous declaration of 'value' - // object P4 { set { _ = from x in new int[0] join @value in new int[0] on x equals @value select x; } } - Diagnostic(ErrorCode.ERR_QueryRangeVariableOverrides, "@value").WithArguments("value").WithLocation(7, 53)); - } - else - { - comp.VerifyEmitDiagnostics( - // (4,48): info CS9258: 'field' is a contextual keyword, with a specific meaning, starting in language version preview. Use '@field' to avoid a breaking change when compiling with language version preview or later. - // object P1 { get { _ = from x in new int[0] join field in new int[0] on x equals field select x; return null; } } - Diagnostic(ErrorCode.INF_IdentifierConflictWithContextualKeyword, "join field in new int[0] on x equals field").WithArguments("field", "preview").WithLocation(4, 48), - // (4,85): info CS9258: 'field' is a contextual keyword, with a specific meaning, starting in language version preview. Use '@field' to avoid a breaking change when compiling with language version preview or later. - // object P1 { get { _ = from x in new int[0] join field in new int[0] on x equals field select x; return null; } } - Diagnostic(ErrorCode.INF_IdentifierConflictWithContextualKeyword, "field").WithArguments("field", "preview").WithLocation(4, 85), - // (6,48): info CS9258: 'value' is a contextual keyword, with a specific meaning, starting in language version preview. Use '@value' to avoid a breaking change when compiling with language version preview or later. - // object P3 { set { _ = from x in new int[0] join value in new int[0] on x equals value select x; } } - Diagnostic(ErrorCode.INF_IdentifierConflictWithContextualKeyword, "join value in new int[0] on x equals value").WithArguments("value", "preview").WithLocation(6, 48), - // (6,53): error CS1931: The range variable 'value' conflicts with a previous declaration of 'value' - // object P3 { set { _ = from x in new int[0] join value in new int[0] on x equals value select x; } } - Diagnostic(ErrorCode.ERR_QueryRangeVariableOverrides, "value").WithArguments("value").WithLocation(6, 53), - // (6,85): info CS9258: 'value' is a contextual keyword, with a specific meaning, starting in language version preview. Use '@value' to avoid a breaking change when compiling with language version preview or later. - // object P3 { set { _ = from x in new int[0] join value in new int[0] on x equals value select x; } } - Diagnostic(ErrorCode.INF_IdentifierConflictWithContextualKeyword, "value").WithArguments("value", "preview").WithLocation(6, 85), - // (7,53): error CS1931: The range variable 'value' conflicts with a previous declaration of 'value' - // object P4 { set { _ = from x in new int[0] join @value in new int[0] on x equals @value select x; } } - Diagnostic(ErrorCode.ERR_QueryRangeVariableOverrides, "@value").WithArguments("value").WithLocation(7, 53)); - } + comp.VerifyEmitDiagnostics( + // (4,48): info CS9258: 'field' is a contextual keyword in property accessors starting in language version preview. Use '@field' instead. + // object P1 { get { _ = from x in new int[0] join field in new int[0] on x equals field select x; return null; } } + Diagnostic(ErrorCode.INF_IdentifierConflictWithContextualKeyword, "join field in new int[0] on x equals field").WithArguments("field", "preview").WithLocation(4, 48), + // (4,85): info CS9258: 'field' is a contextual keyword in property accessors starting in language version preview. Use '@field' instead. + // object P1 { get { _ = from x in new int[0] join field in new int[0] on x equals field select x; return null; } } + Diagnostic(ErrorCode.INF_IdentifierConflictWithContextualKeyword, "field").WithArguments("field", "preview").WithLocation(4, 85), + // (6,48): info CS9258: 'value' is a contextual keyword in property accessors starting in language version preview. Use '@value' instead. + // object P3 { set { _ = from x in new int[0] join value in new int[0] on x equals value select x; } } + Diagnostic(ErrorCode.INF_IdentifierConflictWithContextualKeyword, "join value in new int[0] on x equals value").WithArguments("value", "preview").WithLocation(6, 48), + // (6,53): error CS1931: The range variable 'value' conflicts with a previous declaration of 'value' + // object P3 { set { _ = from x in new int[0] join value in new int[0] on x equals value select x; } } + Diagnostic(ErrorCode.ERR_QueryRangeVariableOverrides, "value").WithArguments("value").WithLocation(6, 53), + // (6,85): info CS9258: 'value' is a contextual keyword in property accessors starting in language version preview. Use '@value' instead. + // object P3 { set { _ = from x in new int[0] join value in new int[0] on x equals value select x; } } + Diagnostic(ErrorCode.INF_IdentifierConflictWithContextualKeyword, "value").WithArguments("value", "preview").WithLocation(6, 85), + // (7,53): error CS1931: The range variable 'value' conflicts with a previous declaration of 'value' + // object P4 { set { _ = from x in new int[0] join @value in new int[0] on x equals @value select x; } } + Diagnostic(ErrorCode.ERR_QueryRangeVariableOverrides, "@value").WithArguments("value").WithLocation(7, 53)); } [Theory] @@ -630,38 +600,25 @@ class C } """; var comp = CreateCompilation(source, parseOptions: TestOptions.Regular.WithLanguageVersion(languageVersion)); - if (languageVersion > LanguageVersion.CSharp12) - { - comp.VerifyEmitDiagnostics( - // (6,88): error CS1931: The range variable 'value' conflicts with a previous declaration of 'value' - // object P3 { set { _ = from x in new int[0] join y in new int[0] on x equals y into value select value; } } - Diagnostic(ErrorCode.ERR_QueryRangeVariableOverrides, "value").WithArguments("value").WithLocation(6, 88), - // (7,88): error CS1931: The range variable 'value' conflicts with a previous declaration of 'value' - // object P4 { set { _ = from x in new int[0] join y in new int[0] on x equals y into @value select @value; } } - Diagnostic(ErrorCode.ERR_QueryRangeVariableOverrides, "@value").WithArguments("value").WithLocation(7, 88)); - } - else - { - comp.VerifyEmitDiagnostics( - // (4,83): info CS9258: 'field' is a contextual keyword, with a specific meaning, starting in language version preview. Use '@field' to avoid a breaking change when compiling with language version preview or later. - // object P1 { get { _ = from x in new int[0] join y in new int[0] on x equals y into field select field; return null; } } - Diagnostic(ErrorCode.INF_IdentifierConflictWithContextualKeyword, "into field").WithArguments("field", "preview").WithLocation(4, 83), - // (4,101): info CS9258: 'field' is a contextual keyword, with a specific meaning, starting in language version preview. Use '@field' to avoid a breaking change when compiling with language version preview or later. - // object P1 { get { _ = from x in new int[0] join y in new int[0] on x equals y into field select field; return null; } } - Diagnostic(ErrorCode.INF_IdentifierConflictWithContextualKeyword, "field").WithArguments("field", "preview").WithLocation(4, 101), - // (6,83): info CS9258: 'value' is a contextual keyword, with a specific meaning, starting in language version preview. Use '@value' to avoid a breaking change when compiling with language version preview or later. - // object P3 { set { _ = from x in new int[0] join y in new int[0] on x equals y into value select value; } } - Diagnostic(ErrorCode.INF_IdentifierConflictWithContextualKeyword, "into value").WithArguments("value", "preview").WithLocation(6, 83), - // (6,88): error CS1931: The range variable 'value' conflicts with a previous declaration of 'value' - // object P3 { set { _ = from x in new int[0] join y in new int[0] on x equals y into value select value; } } - Diagnostic(ErrorCode.ERR_QueryRangeVariableOverrides, "value").WithArguments("value").WithLocation(6, 88), - // (6,101): info CS9258: 'value' is a contextual keyword, with a specific meaning, starting in language version preview. Use '@value' to avoid a breaking change when compiling with language version preview or later. - // object P3 { set { _ = from x in new int[0] join y in new int[0] on x equals y into value select value; } } - Diagnostic(ErrorCode.INF_IdentifierConflictWithContextualKeyword, "value").WithArguments("value", "preview").WithLocation(6, 101), - // (7,88): error CS1931: The range variable 'value' conflicts with a previous declaration of 'value' - // object P4 { set { _ = from x in new int[0] join y in new int[0] on x equals y into @value select @value; } } - Diagnostic(ErrorCode.ERR_QueryRangeVariableOverrides, "@value").WithArguments("value").WithLocation(7, 88)); - } + comp.VerifyEmitDiagnostics( + // (4,83): info CS9258: 'field' is a contextual keyword in property accessors starting in language version preview. Use '@field' instead. + // object P1 { get { _ = from x in new int[0] join y in new int[0] on x equals y into field select field; return null; } } + Diagnostic(ErrorCode.INF_IdentifierConflictWithContextualKeyword, "into field").WithArguments("field", "preview").WithLocation(4, 83), + // (4,101): info CS9258: 'field' is a contextual keyword in property accessors starting in language version preview. Use '@field' instead. + // object P1 { get { _ = from x in new int[0] join y in new int[0] on x equals y into field select field; return null; } } + Diagnostic(ErrorCode.INF_IdentifierConflictWithContextualKeyword, "field").WithArguments("field", "preview").WithLocation(4, 101), + // (6,83): info CS9258: 'value' is a contextual keyword in property accessors starting in language version preview. Use '@value' instead. + // object P3 { set { _ = from x in new int[0] join y in new int[0] on x equals y into value select value; } } + Diagnostic(ErrorCode.INF_IdentifierConflictWithContextualKeyword, "into value").WithArguments("value", "preview").WithLocation(6, 83), + // (6,88): error CS1931: The range variable 'value' conflicts with a previous declaration of 'value' + // object P3 { set { _ = from x in new int[0] join y in new int[0] on x equals y into value select value; } } + Diagnostic(ErrorCode.ERR_QueryRangeVariableOverrides, "value").WithArguments("value").WithLocation(6, 88), + // (6,101): info CS9258: 'value' is a contextual keyword in property accessors starting in language version preview. Use '@value' instead. + // object P3 { set { _ = from x in new int[0] join y in new int[0] on x equals y into value select value; } } + Diagnostic(ErrorCode.INF_IdentifierConflictWithContextualKeyword, "value").WithArguments("value", "preview").WithLocation(6, 101), + // (7,88): error CS1931: The range variable 'value' conflicts with a previous declaration of 'value' + // object P4 { set { _ = from x in new int[0] join y in new int[0] on x equals y into @value select @value; } } + Diagnostic(ErrorCode.ERR_QueryRangeVariableOverrides, "@value").WithArguments("value").WithLocation(7, 88)); } [Theory] @@ -680,38 +637,25 @@ class C } """; var comp = CreateCompilation(source, parseOptions: TestOptions.Regular.WithLanguageVersion(languageVersion)); - if (languageVersion > LanguageVersion.CSharp12) - { - comp.VerifyEmitDiagnostics( - // (6,62): error CS1931: The range variable 'value' conflicts with a previous declaration of 'value' - // object P3 { set { _ = from x in new int[0] select x into value select value; } } - Diagnostic(ErrorCode.ERR_QueryRangeVariableOverrides, "value").WithArguments("value").WithLocation(6, 62), - // (7,62): error CS1931: The range variable 'value' conflicts with a previous declaration of 'value' - // object P4 { set { _ = from x in new int[0] select x into @value select @value; } } - Diagnostic(ErrorCode.ERR_QueryRangeVariableOverrides, "@value").WithArguments("value").WithLocation(7, 62)); - } - else - { - comp.VerifyEmitDiagnostics( - // (4,57): info CS9258: 'field' is a contextual keyword, with a specific meaning, starting in language version preview. Use '@field' to avoid a breaking change when compiling with language version preview or later. - // object P1 { get { _ = from x in new int[0] select x into field select field; return null; } } - Diagnostic(ErrorCode.INF_IdentifierConflictWithContextualKeyword, "into field select field").WithArguments("field", "preview").WithLocation(4, 57), - // (4,75): info CS9258: 'field' is a contextual keyword, with a specific meaning, starting in language version preview. Use '@field' to avoid a breaking change when compiling with language version preview or later. - // object P1 { get { _ = from x in new int[0] select x into field select field; return null; } } - Diagnostic(ErrorCode.INF_IdentifierConflictWithContextualKeyword, "field").WithArguments("field", "preview").WithLocation(4, 75), - // (6,57): info CS9258: 'value' is a contextual keyword, with a specific meaning, starting in language version preview. Use '@value' to avoid a breaking change when compiling with language version preview or later. - // object P3 { set { _ = from x in new int[0] select x into value select value; } } - Diagnostic(ErrorCode.INF_IdentifierConflictWithContextualKeyword, "into value select value").WithArguments("value", "preview").WithLocation(6, 57), - // (6,62): error CS1931: The range variable 'value' conflicts with a previous declaration of 'value' - // object P3 { set { _ = from x in new int[0] select x into value select value; } } - Diagnostic(ErrorCode.ERR_QueryRangeVariableOverrides, "value").WithArguments("value").WithLocation(6, 62), - // (6,75): info CS9258: 'value' is a contextual keyword, with a specific meaning, starting in language version preview. Use '@value' to avoid a breaking change when compiling with language version preview or later. - // object P3 { set { _ = from x in new int[0] select x into value select value; } } - Diagnostic(ErrorCode.INF_IdentifierConflictWithContextualKeyword, "value").WithArguments("value", "preview").WithLocation(6, 75), - // (7,62): error CS1931: The range variable 'value' conflicts with a previous declaration of 'value' - // object P4 { set { _ = from x in new int[0] select x into @value select @value; } } - Diagnostic(ErrorCode.ERR_QueryRangeVariableOverrides, "@value").WithArguments("value").WithLocation(7, 62)); - } + comp.VerifyEmitDiagnostics( + // (4,57): info CS9258: 'field' is a contextual keyword in property accessors starting in language version preview. Use '@field' instead. + // object P1 { get { _ = from x in new int[0] select x into field select field; return null; } } + Diagnostic(ErrorCode.INF_IdentifierConflictWithContextualKeyword, "into field select field").WithArguments("field", "preview").WithLocation(4, 57), + // (4,75): info CS9258: 'field' is a contextual keyword in property accessors starting in language version preview. Use '@field' instead. + // object P1 { get { _ = from x in new int[0] select x into field select field; return null; } } + Diagnostic(ErrorCode.INF_IdentifierConflictWithContextualKeyword, "field").WithArguments("field", "preview").WithLocation(4, 75), + // (6,57): info CS9258: 'value' is a contextual keyword in property accessors starting in language version preview. Use '@value' instead. + // object P3 { set { _ = from x in new int[0] select x into value select value; } } + Diagnostic(ErrorCode.INF_IdentifierConflictWithContextualKeyword, "into value select value").WithArguments("value", "preview").WithLocation(6, 57), + // (6,62): error CS1931: The range variable 'value' conflicts with a previous declaration of 'value' + // object P3 { set { _ = from x in new int[0] select x into value select value; } } + Diagnostic(ErrorCode.ERR_QueryRangeVariableOverrides, "value").WithArguments("value").WithLocation(6, 62), + // (6,75): info CS9258: 'value' is a contextual keyword in property accessors starting in language version preview. Use '@value' instead. + // object P3 { set { _ = from x in new int[0] select x into value select value; } } + Diagnostic(ErrorCode.INF_IdentifierConflictWithContextualKeyword, "value").WithArguments("value", "preview").WithLocation(6, 75), + // (7,62): error CS1931: The range variable 'value' conflicts with a previous declaration of 'value' + // object P4 { set { _ = from x in new int[0] select x into @value select @value; } } + Diagnostic(ErrorCode.ERR_QueryRangeVariableOverrides, "@value").WithArguments("value").WithLocation(7, 62)); } [Theory] @@ -730,32 +674,19 @@ class C } """; var comp = CreateCompilation(source, parseOptions: TestOptions.Regular.WithLanguageVersion(languageVersion)); - if (languageVersion > LanguageVersion.CSharp12) - { - comp.VerifyEmitDiagnostics( - // (6,28): error CS0136: A local or parameter named 'value' cannot be declared in this scope because that name is used in an enclosing local scope to define a local or parameter - // object P3 { set { void value() { } } } - Diagnostic(ErrorCode.ERR_LocalIllegallyOverrides, "value").WithArguments("value").WithLocation(6, 28), - // (7,28): error CS0136: A local or parameter named 'value' cannot be declared in this scope because that name is used in an enclosing local scope to define a local or parameter - // object P4 { set { void @value() { } } } - Diagnostic(ErrorCode.ERR_LocalIllegallyOverrides, "@value").WithArguments("value").WithLocation(7, 28)); - } - else - { - comp.VerifyEmitDiagnostics( - // (4,23): info CS9258: 'field' is a contextual keyword, with a specific meaning, starting in language version preview. Use '@field' to avoid a breaking change when compiling with language version preview or later. - // object P1 { get { object field() => null; return null; } } - Diagnostic(ErrorCode.INF_IdentifierConflictWithContextualKeyword, "object field() => null;").WithArguments("field", "preview").WithLocation(4, 23), - // (6,23): info CS9258: 'value' is a contextual keyword, with a specific meaning, starting in language version preview. Use '@value' to avoid a breaking change when compiling with language version preview or later. - // object P3 { set { void value() { } } } - Diagnostic(ErrorCode.INF_IdentifierConflictWithContextualKeyword, "void value() { }").WithArguments("value", "preview").WithLocation(6, 23), - // (6,28): error CS0136: A local or parameter named 'value' cannot be declared in this scope because that name is used in an enclosing local scope to define a local or parameter - // object P3 { set { void value() { } } } - Diagnostic(ErrorCode.ERR_LocalIllegallyOverrides, "value").WithArguments("value").WithLocation(6, 28), - // (7,28): error CS0136: A local or parameter named 'value' cannot be declared in this scope because that name is used in an enclosing local scope to define a local or parameter - // object P4 { set { void @value() { } } } - Diagnostic(ErrorCode.ERR_LocalIllegallyOverrides, "@value").WithArguments("value").WithLocation(7, 28)); - } + comp.VerifyEmitDiagnostics( + // (4,23): info CS9258: 'field' is a contextual keyword in property accessors starting in language version preview. Use '@field' instead. + // object P1 { get { object field() => null; return null; } } + Diagnostic(ErrorCode.INF_IdentifierConflictWithContextualKeyword, "object field() => null;").WithArguments("field", "preview").WithLocation(4, 23), + // (6,23): info CS9258: 'value' is a contextual keyword in property accessors starting in language version preview. Use '@value' instead. + // object P3 { set { void value() { } } } + Diagnostic(ErrorCode.INF_IdentifierConflictWithContextualKeyword, "void value() { }").WithArguments("value", "preview").WithLocation(6, 23), + // (6,28): error CS0136: A local or parameter named 'value' cannot be declared in this scope because that name is used in an enclosing local scope to define a local or parameter + // object P3 { set { void value() { } } } + Diagnostic(ErrorCode.ERR_LocalIllegallyOverrides, "value").WithArguments("value").WithLocation(6, 28), + // (7,28): error CS0136: A local or parameter named 'value' cannot be declared in this scope because that name is used in an enclosing local scope to define a local or parameter + // object P4 { set { void @value() { } } } + Diagnostic(ErrorCode.ERR_LocalIllegallyOverrides, "@value").WithArguments("value").WithLocation(7, 28)); } [Theory] @@ -774,32 +705,19 @@ class C } """; var comp = CreateCompilation(source, parseOptions: TestOptions.Regular.WithLanguageVersion(languageVersion)); - if (languageVersion > LanguageVersion.CSharp12) - { - comp.VerifyEmitDiagnostics( - // (6,27): error CS0136: A local or parameter named 'value' cannot be declared in this scope because that name is used in an enclosing local scope to define a local or parameter - // object P3 { set { int value = 0; } } - Diagnostic(ErrorCode.ERR_LocalIllegallyOverrides, "value").WithArguments("value").WithLocation(6, 27), - // (7,27): error CS0136: A local or parameter named 'value' cannot be declared in this scope because that name is used in an enclosing local scope to define a local or parameter - // object P4 { set { int @value = 0; } } - Diagnostic(ErrorCode.ERR_LocalIllegallyOverrides, "@value").WithArguments("value").WithLocation(7, 27)); - } - else - { - comp.VerifyEmitDiagnostics( - // (4,27): info CS9258: 'field' is a contextual keyword, with a specific meaning, starting in language version preview. Use '@field' to avoid a breaking change when compiling with language version preview or later. - // object P1 { get { int field = 0; return null; } } - Diagnostic(ErrorCode.INF_IdentifierConflictWithContextualKeyword, "field = 0").WithArguments("field", "preview").WithLocation(4, 27), - // (6,27): error CS0136: A local or parameter named 'value' cannot be declared in this scope because that name is used in an enclosing local scope to define a local or parameter - // object P3 { set { int value = 0; } } - Diagnostic(ErrorCode.ERR_LocalIllegallyOverrides, "value").WithArguments("value").WithLocation(6, 27), - // (6,27): info CS9258: 'value' is a contextual keyword, with a specific meaning, starting in language version preview. Use '@value' to avoid a breaking change when compiling with language version preview or later. - // object P3 { set { int value = 0; } } - Diagnostic(ErrorCode.INF_IdentifierConflictWithContextualKeyword, "value = 0").WithArguments("value", "preview").WithLocation(6, 27), - // (7,27): error CS0136: A local or parameter named 'value' cannot be declared in this scope because that name is used in an enclosing local scope to define a local or parameter - // object P4 { set { int @value = 0; } } - Diagnostic(ErrorCode.ERR_LocalIllegallyOverrides, "@value").WithArguments("value").WithLocation(7, 27)); - } + comp.VerifyEmitDiagnostics( + // (4,27): info CS9258: 'field' is a contextual keyword in property accessors starting in language version preview. Use '@field' instead. + // object P1 { get { int field = 0; return null; } } + Diagnostic(ErrorCode.INF_IdentifierConflictWithContextualKeyword, "field = 0").WithArguments("field", "preview").WithLocation(4, 27), + // (6,27): error CS0136: A local or parameter named 'value' cannot be declared in this scope because that name is used in an enclosing local scope to define a local or parameter + // object P3 { set { int value = 0; } } + Diagnostic(ErrorCode.ERR_LocalIllegallyOverrides, "value").WithArguments("value").WithLocation(6, 27), + // (6,27): info CS9258: 'value' is a contextual keyword in property accessors starting in language version preview. Use '@value' instead. + // object P3 { set { int value = 0; } } + Diagnostic(ErrorCode.INF_IdentifierConflictWithContextualKeyword, "value = 0").WithArguments("value", "preview").WithLocation(6, 27), + // (7,27): error CS0136: A local or parameter named 'value' cannot be declared in this scope because that name is used in an enclosing local scope to define a local or parameter + // object P4 { set { int @value = 0; } } + Diagnostic(ErrorCode.ERR_LocalIllegallyOverrides, "@value").WithArguments("value").WithLocation(7, 27)); } [Theory] @@ -820,32 +738,19 @@ class C } """; var comp = CreateCompilation(source, parseOptions: TestOptions.Regular.WithLanguageVersion(languageVersion)); - if (languageVersion > LanguageVersion.CSharp12) - { - comp.VerifyEmitDiagnostics( - // (6,33): error CS0136: A local or parameter named 'value' cannot be declared in this scope because that name is used in an enclosing local scope to define a local or parameter - // object P3 { set { F(out var value); } } - Diagnostic(ErrorCode.ERR_LocalIllegallyOverrides, "value").WithArguments("value").WithLocation(6, 33), - // (7,33): error CS0136: A local or parameter named 'value' cannot be declared in this scope because that name is used in an enclosing local scope to define a local or parameter - // object P4 { set { F(out var @value); } } - Diagnostic(ErrorCode.ERR_LocalIllegallyOverrides, "@value").WithArguments("value").WithLocation(7, 33)); - } - else - { - comp.VerifyEmitDiagnostics( - // (4,33): info CS9258: 'field' is a contextual keyword, with a specific meaning, starting in language version preview. Use '@field' to avoid a breaking change when compiling with language version preview or later. - // object P1 { get { F(out var field); return null; } } - Diagnostic(ErrorCode.INF_IdentifierConflictWithContextualKeyword, "field").WithArguments("field", "preview").WithLocation(4, 33), - // (6,33): error CS0136: A local or parameter named 'value' cannot be declared in this scope because that name is used in an enclosing local scope to define a local or parameter - // object P3 { set { F(out var value); } } - Diagnostic(ErrorCode.ERR_LocalIllegallyOverrides, "value").WithArguments("value").WithLocation(6, 33), - // (6,33): info CS9258: 'value' is a contextual keyword, with a specific meaning, starting in language version preview. Use '@value' to avoid a breaking change when compiling with language version preview or later. - // object P3 { set { F(out var value); } } - Diagnostic(ErrorCode.INF_IdentifierConflictWithContextualKeyword, "value").WithArguments("value", "preview").WithLocation(6, 33), - // (7,33): error CS0136: A local or parameter named 'value' cannot be declared in this scope because that name is used in an enclosing local scope to define a local or parameter - // object P4 { set { F(out var @value); } } - Diagnostic(ErrorCode.ERR_LocalIllegallyOverrides, "@value").WithArguments("value").WithLocation(7, 33)); - } + comp.VerifyEmitDiagnostics( + // (4,33): info CS9258: 'field' is a contextual keyword in property accessors starting in language version preview. Use '@field' instead. + // object P1 { get { F(out var field); return null; } } + Diagnostic(ErrorCode.INF_IdentifierConflictWithContextualKeyword, "field").WithArguments("field", "preview").WithLocation(4, 33), + // (6,33): error CS0136: A local or parameter named 'value' cannot be declared in this scope because that name is used in an enclosing local scope to define a local or parameter + // object P3 { set { F(out var value); } } + Diagnostic(ErrorCode.ERR_LocalIllegallyOverrides, "value").WithArguments("value").WithLocation(6, 33), + // (6,33): info CS9258: 'value' is a contextual keyword in property accessors starting in language version preview. Use '@value' instead. + // object P3 { set { F(out var value); } } + Diagnostic(ErrorCode.INF_IdentifierConflictWithContextualKeyword, "value").WithArguments("value", "preview").WithLocation(6, 33), + // (7,33): error CS0136: A local or parameter named 'value' cannot be declared in this scope because that name is used in an enclosing local scope to define a local or parameter + // object P4 { set { F(out var @value); } } + Diagnostic(ErrorCode.ERR_LocalIllegallyOverrides, "@value").WithArguments("value").WithLocation(7, 33)); } [Theory] @@ -864,20 +769,13 @@ class C } """; var comp = CreateCompilation(source, parseOptions: TestOptions.Regular.WithLanguageVersion(languageVersion)); - if (languageVersion > LanguageVersion.CSharp12) - { - comp.VerifyEmitDiagnostics(); - } - else - { - comp.VerifyEmitDiagnostics( - // (4,23): info CS9258: 'field' is a contextual keyword, with a specific meaning, starting in language version preview. Use '@field' to avoid a breaking change when compiling with language version preview or later. - // object P1 { get { field: return null; } } - Diagnostic(ErrorCode.INF_IdentifierConflictWithContextualKeyword, "field: return null;").WithArguments("field", "preview").WithLocation(4, 23), - // (6,23): info CS9258: 'value' is a contextual keyword, with a specific meaning, starting in language version preview. Use '@value' to avoid a breaking change when compiling with language version preview or later. - // object P3 { set { value: return; } } - Diagnostic(ErrorCode.INF_IdentifierConflictWithContextualKeyword, "value: return;").WithArguments("value", "preview").WithLocation(6, 23)); - } + comp.VerifyEmitDiagnostics( + // (4,23): info CS9258: 'field' is a contextual keyword in property accessors starting in language version preview. Use '@field' instead. + // object P1 { get { field: return null; } } + Diagnostic(ErrorCode.INF_IdentifierConflictWithContextualKeyword, "field: return null;").WithArguments("field", "preview").WithLocation(4, 23), + // (6,23): info CS9258: 'value' is a contextual keyword in property accessors starting in language version preview. Use '@value' instead. + // object P3 { set { value: return; } } + Diagnostic(ErrorCode.INF_IdentifierConflictWithContextualKeyword, "value: return;").WithArguments("value", "preview").WithLocation(6, 23)); } [Theory] @@ -895,32 +793,19 @@ class C } """; var comp = CreateCompilation(source, parseOptions: TestOptions.Regular.WithLanguageVersion(languageVersion)); - if (languageVersion > LanguageVersion.CSharp12) - { - comp.VerifyEmitDiagnostics( - // (5,36): error CS0136: A local or parameter named 'value' cannot be declared in this scope because that name is used in an enclosing local scope to define a local or parameter - // object P3 { set { foreach (var value in new int[0]) { } } } - Diagnostic(ErrorCode.ERR_LocalIllegallyOverrides, "value").WithArguments("value").WithLocation(5, 36), - // (6,36): error CS0136: A local or parameter named 'value' cannot be declared in this scope because that name is used in an enclosing local scope to define a local or parameter - // object P4 { set { foreach (var @value in new int[0]) { } } } - Diagnostic(ErrorCode.ERR_LocalIllegallyOverrides, "@value").WithArguments("value").WithLocation(6, 36)); - } - else - { - comp.VerifyEmitDiagnostics( - // (3,23): info CS9258: 'field' is a contextual keyword, with a specific meaning, starting in language version preview. Use '@field' to avoid a breaking change when compiling with language version preview or later. - // object P1 { get { foreach (var field in new int[0]) { } return null; } } - Diagnostic(ErrorCode.INF_IdentifierConflictWithContextualKeyword, "foreach (var field in new int[0]) { }").WithArguments("field", "preview").WithLocation(3, 23), - // (5,23): info CS9258: 'value' is a contextual keyword, with a specific meaning, starting in language version preview. Use '@value' to avoid a breaking change when compiling with language version preview or later. - // object P3 { set { foreach (var value in new int[0]) { } } } - Diagnostic(ErrorCode.INF_IdentifierConflictWithContextualKeyword, "foreach (var value in new int[0]) { }").WithArguments("value", "preview").WithLocation(5, 23), - // (5,36): error CS0136: A local or parameter named 'value' cannot be declared in this scope because that name is used in an enclosing local scope to define a local or parameter - // object P3 { set { foreach (var value in new int[0]) { } } } - Diagnostic(ErrorCode.ERR_LocalIllegallyOverrides, "value").WithArguments("value").WithLocation(5, 36), - // (6,36): error CS0136: A local or parameter named 'value' cannot be declared in this scope because that name is used in an enclosing local scope to define a local or parameter - // object P4 { set { foreach (var @value in new int[0]) { } } } - Diagnostic(ErrorCode.ERR_LocalIllegallyOverrides, "@value").WithArguments("value").WithLocation(6, 36)); - } + comp.VerifyEmitDiagnostics( + // (3,23): info CS9258: 'field' is a contextual keyword in property accessors starting in language version preview. Use '@field' instead. + // object P1 { get { foreach (var field in new int[0]) { } return null; } } + Diagnostic(ErrorCode.INF_IdentifierConflictWithContextualKeyword, "foreach (var field in new int[0]) { }").WithArguments("field", "preview").WithLocation(3, 23), + // (5,23): info CS9258: 'value' is a contextual keyword in property accessors starting in language version preview. Use '@value' instead. + // object P3 { set { foreach (var value in new int[0]) { } } } + Diagnostic(ErrorCode.INF_IdentifierConflictWithContextualKeyword, "foreach (var value in new int[0]) { }").WithArguments("value", "preview").WithLocation(5, 23), + // (5,36): error CS0136: A local or parameter named 'value' cannot be declared in this scope because that name is used in an enclosing local scope to define a local or parameter + // object P3 { set { foreach (var value in new int[0]) { } } } + Diagnostic(ErrorCode.ERR_LocalIllegallyOverrides, "value").WithArguments("value").WithLocation(5, 36), + // (6,36): error CS0136: A local or parameter named 'value' cannot be declared in this scope because that name is used in an enclosing local scope to define a local or parameter + // object P4 { set { foreach (var @value in new int[0]) { } } } + Diagnostic(ErrorCode.ERR_LocalIllegallyOverrides, "@value").WithArguments("value").WithLocation(6, 36)); } [Theory] @@ -936,32 +821,19 @@ class C } """; var comp = CreateCompilation(source, parseOptions: TestOptions.Regular.WithLanguageVersion(languageVersion)); - if (languageVersion > LanguageVersion.CSharp12) - { - comp.VerifyEmitDiagnostics( - // (3,44): error CS0136: A local or parameter named 'value' cannot be declared in this scope because that name is used in an enclosing local scope to define a local or parameter - // object P1 { set { foreach (var (field, @value) in new (int, int)[0]) { } } } - Diagnostic(ErrorCode.ERR_LocalIllegallyOverrides, "@value").WithArguments("value").WithLocation(3, 44), - // (4,45): error CS0136: A local or parameter named 'value' cannot be declared in this scope because that name is used in an enclosing local scope to define a local or parameter - // object P2 { set { foreach (var (@field, value) in new (int, int)[0]) { } } } - Diagnostic(ErrorCode.ERR_LocalIllegallyOverrides, "value").WithArguments("value").WithLocation(4, 45)); - } - else - { - comp.VerifyEmitDiagnostics( - // (3,37): info CS9258: 'field' is a contextual keyword, with a specific meaning, starting in language version preview. Use '@field' to avoid a breaking change when compiling with language version preview or later. - // object P1 { set { foreach (var (field, @value) in new (int, int)[0]) { } } } - Diagnostic(ErrorCode.INF_IdentifierConflictWithContextualKeyword, "field").WithArguments("field", "preview").WithLocation(3, 37), - // (3,44): error CS0136: A local or parameter named 'value' cannot be declared in this scope because that name is used in an enclosing local scope to define a local or parameter - // object P1 { set { foreach (var (field, @value) in new (int, int)[0]) { } } } - Diagnostic(ErrorCode.ERR_LocalIllegallyOverrides, "@value").WithArguments("value").WithLocation(3, 44), - // (4,45): error CS0136: A local or parameter named 'value' cannot be declared in this scope because that name is used in an enclosing local scope to define a local or parameter - // object P2 { set { foreach (var (@field, value) in new (int, int)[0]) { } } } - Diagnostic(ErrorCode.ERR_LocalIllegallyOverrides, "value").WithArguments("value").WithLocation(4, 45), - // (4,45): info CS9258: 'value' is a contextual keyword, with a specific meaning, starting in language version preview. Use '@value' to avoid a breaking change when compiling with language version preview or later. - // object P2 { set { foreach (var (@field, value) in new (int, int)[0]) { } } } - Diagnostic(ErrorCode.INF_IdentifierConflictWithContextualKeyword, "value").WithArguments("value", "preview").WithLocation(4, 45)); - } + comp.VerifyEmitDiagnostics( + // (3,37): info CS9258: 'field' is a contextual keyword in property accessors starting in language version preview. Use '@field' instead. + // object P1 { set { foreach (var (field, @value) in new (int, int)[0]) { } } } + Diagnostic(ErrorCode.INF_IdentifierConflictWithContextualKeyword, "field").WithArguments("field", "preview").WithLocation(3, 37), + // (3,44): error CS0136: A local or parameter named 'value' cannot be declared in this scope because that name is used in an enclosing local scope to define a local or parameter + // object P1 { set { foreach (var (field, @value) in new (int, int)[0]) { } } } + Diagnostic(ErrorCode.ERR_LocalIllegallyOverrides, "@value").WithArguments("value").WithLocation(3, 44), + // (4,45): error CS0136: A local or parameter named 'value' cannot be declared in this scope because that name is used in an enclosing local scope to define a local or parameter + // object P2 { set { foreach (var (@field, value) in new (int, int)[0]) { } } } + Diagnostic(ErrorCode.ERR_LocalIllegallyOverrides, "value").WithArguments("value").WithLocation(4, 45), + // (4,45): info CS9258: 'value' is a contextual keyword in property accessors starting in language version preview. Use '@value' instead. + // object P2 { set { foreach (var (@field, value) in new (int, int)[0]) { } } } + Diagnostic(ErrorCode.INF_IdentifierConflictWithContextualKeyword, "value").WithArguments("value", "preview").WithLocation(4, 45)); } [Theory] @@ -981,32 +853,19 @@ class C } """; var comp = CreateCompilation(source, parseOptions: TestOptions.Regular.WithLanguageVersion(languageVersion)); - if (languageVersion > LanguageVersion.CSharp12) - { - comp.VerifyEmitDiagnostics( - // (7,48): error CS0136: A local or parameter named 'value' cannot be declared in this scope because that name is used in an enclosing local scope to define a local or parameter - // object P3 { set { try { } catch (Exception value) { } } } - Diagnostic(ErrorCode.ERR_LocalIllegallyOverrides, "value").WithArguments("value").WithLocation(7, 48), - // (8,48): error CS0136: A local or parameter named 'value' cannot be declared in this scope because that name is used in an enclosing local scope to define a local or parameter - // object P4 { set { try { } catch (Exception @value) { } } } - Diagnostic(ErrorCode.ERR_LocalIllegallyOverrides, "@value").WithArguments("value").WithLocation(8, 48)); - } - else - { - comp.VerifyEmitDiagnostics( - // (5,37): info CS9258: 'field' is a contextual keyword, with a specific meaning, starting in language version preview. Use '@field' to avoid a breaking change when compiling with language version preview or later. - // object P1 { get { try { } catch (Exception field) { } return null; } } - Diagnostic(ErrorCode.INF_IdentifierConflictWithContextualKeyword, "(Exception field)").WithArguments("field", "preview").WithLocation(5, 37), - // (7,37): info CS9258: 'value' is a contextual keyword, with a specific meaning, starting in language version preview. Use '@value' to avoid a breaking change when compiling with language version preview or later. - // object P3 { set { try { } catch (Exception value) { } } } - Diagnostic(ErrorCode.INF_IdentifierConflictWithContextualKeyword, "(Exception value)").WithArguments("value", "preview").WithLocation(7, 37), - // (7,48): error CS0136: A local or parameter named 'value' cannot be declared in this scope because that name is used in an enclosing local scope to define a local or parameter - // object P3 { set { try { } catch (Exception value) { } } } - Diagnostic(ErrorCode.ERR_LocalIllegallyOverrides, "value").WithArguments("value").WithLocation(7, 48), - // (8,48): error CS0136: A local or parameter named 'value' cannot be declared in this scope because that name is used in an enclosing local scope to define a local or parameter - // object P4 { set { try { } catch (Exception @value) { } } } - Diagnostic(ErrorCode.ERR_LocalIllegallyOverrides, "@value").WithArguments("value").WithLocation(8, 48)); - } + comp.VerifyEmitDiagnostics( + // (5,37): info CS9258: 'field' is a contextual keyword in property accessors starting in language version preview. Use '@field' instead. + // object P1 { get { try { } catch (Exception field) { } return null; } } + Diagnostic(ErrorCode.INF_IdentifierConflictWithContextualKeyword, "(Exception field)").WithArguments("field", "preview").WithLocation(5, 37), + // (7,37): info CS9258: 'value' is a contextual keyword in property accessors starting in language version preview. Use '@value' instead. + // object P3 { set { try { } catch (Exception value) { } } } + Diagnostic(ErrorCode.INF_IdentifierConflictWithContextualKeyword, "(Exception value)").WithArguments("value", "preview").WithLocation(7, 37), + // (7,48): error CS0136: A local or parameter named 'value' cannot be declared in this scope because that name is used in an enclosing local scope to define a local or parameter + // object P3 { set { try { } catch (Exception value) { } } } + Diagnostic(ErrorCode.ERR_LocalIllegallyOverrides, "value").WithArguments("value").WithLocation(7, 48), + // (8,48): error CS0136: A local or parameter named 'value' cannot be declared in this scope because that name is used in an enclosing local scope to define a local or parameter + // object P4 { set { try { } catch (Exception @value) { } } } + Diagnostic(ErrorCode.ERR_LocalIllegallyOverrides, "@value").WithArguments("value").WithLocation(8, 48)); } [Theory] @@ -1025,20 +884,13 @@ class C } """; var comp = CreateCompilation(source, parseOptions: TestOptions.Regular.WithLanguageVersion(languageVersion)); - if (languageVersion > LanguageVersion.CSharp12) - { - comp.VerifyEmitDiagnostics(); - } - else - { - comp.VerifyEmitDiagnostics( - // (4,31): info CS9258: 'field' is a contextual keyword, with a specific meaning, starting in language version preview. Use '@field' to avoid a breaking change when compiling with language version preview or later. - // object P1 { get { void F1() { } return null; } } - Diagnostic(ErrorCode.INF_IdentifierConflictWithContextualKeyword, "field").WithArguments("field", "preview").WithLocation(4, 31), - // (6,31): info CS9258: 'value' is a contextual keyword, with a specific meaning, starting in language version preview. Use '@value' to avoid a breaking change when compiling with language version preview or later. - // object P3 { set { void F3() { } } } - Diagnostic(ErrorCode.INF_IdentifierConflictWithContextualKeyword, "value").WithArguments("value", "preview").WithLocation(6, 31)); - } + comp.VerifyEmitDiagnostics( + // (4,31): info CS9258: 'field' is a contextual keyword in property accessors starting in language version preview. Use '@field' instead. + // object P1 { get { void F1() { } return null; } } + Diagnostic(ErrorCode.INF_IdentifierConflictWithContextualKeyword, "field").WithArguments("field", "preview").WithLocation(4, 31), + // (6,31): info CS9258: 'value' is a contextual keyword in property accessors starting in language version preview. Use '@value' instead. + // object P3 { set { void F3() { } } } + Diagnostic(ErrorCode.INF_IdentifierConflictWithContextualKeyword, "value").WithArguments("value", "preview").WithLocation(6, 31)); } [Theory] @@ -1057,26 +909,19 @@ class C } """; var comp = CreateCompilation(source, parseOptions: TestOptions.Regular.WithLanguageVersion(languageVersion)); - if (languageVersion > LanguageVersion.CSharp12) - { - comp.VerifyEmitDiagnostics(); - } - else - { - comp.VerifyEmitDiagnostics( - // (4,33): info CS9258: 'field' is a contextual keyword, with a specific meaning, starting in language version preview. Use '@field' to avoid a breaking change when compiling with language version preview or later. - // object P1 { get { object F1(object field) => field; return null; } } - Diagnostic(ErrorCode.INF_IdentifierConflictWithContextualKeyword, "object field").WithArguments("field", "preview").WithLocation(4, 33), - // (4,50): info CS9258: 'field' is a contextual keyword, with a specific meaning, starting in language version preview. Use '@field' to avoid a breaking change when compiling with language version preview or later. - // object P1 { get { object F1(object field) => field; return null; } } - Diagnostic(ErrorCode.INF_IdentifierConflictWithContextualKeyword, "field").WithArguments("field", "preview").WithLocation(4, 50), - // (6,33): info CS9258: 'value' is a contextual keyword, with a specific meaning, starting in language version preview. Use '@value' to avoid a breaking change when compiling with language version preview or later. - // object P3 { set { object F3(object value) { return value; } } } - Diagnostic(ErrorCode.INF_IdentifierConflictWithContextualKeyword, "object value").WithArguments("value", "preview").WithLocation(6, 33), - // (6,56): info CS9258: 'value' is a contextual keyword, with a specific meaning, starting in language version preview. Use '@value' to avoid a breaking change when compiling with language version preview or later. - // object P3 { set { object F3(object value) { return value; } } } - Diagnostic(ErrorCode.INF_IdentifierConflictWithContextualKeyword, "value").WithArguments("value", "preview").WithLocation(6, 56)); - } + comp.VerifyEmitDiagnostics( + // (4,33): info CS9258: 'field' is a contextual keyword in property accessors starting in language version preview. Use '@field' instead. + // object P1 { get { object F1(object field) => field; return null; } } + Diagnostic(ErrorCode.INF_IdentifierConflictWithContextualKeyword, "object field").WithArguments("field", "preview").WithLocation(4, 33), + // (4,50): info CS9258: 'field' is a contextual keyword in property accessors starting in language version preview. Use '@field' instead. + // object P1 { get { object F1(object field) => field; return null; } } + Diagnostic(ErrorCode.INF_IdentifierConflictWithContextualKeyword, "field").WithArguments("field", "preview").WithLocation(4, 50), + // (6,33): info CS9258: 'value' is a contextual keyword in property accessors starting in language version preview. Use '@value' instead. + // object P3 { set { object F3(object value) { return value; } } } + Diagnostic(ErrorCode.INF_IdentifierConflictWithContextualKeyword, "object value").WithArguments("value", "preview").WithLocation(6, 33), + // (6,56): info CS9258: 'value' is a contextual keyword in property accessors starting in language version preview. Use '@value' instead. + // object P3 { set { object F3(object value) { return value; } } } + Diagnostic(ErrorCode.INF_IdentifierConflictWithContextualKeyword, "value").WithArguments("value", "preview").WithLocation(6, 56)); } [Theory] @@ -1133,26 +978,16 @@ static object P2 } """; var comp = CreateCompilation(source, parseOptions: TestOptions.Regular.WithLanguageVersion(languageVersion)); - if (languageVersion > LanguageVersion.CSharp12) - { - comp.VerifyEmitDiagnostics( - // (9,20): error CS0136: A local or parameter named 'value' cannot be declared in this scope because that name is used in an enclosing local scope to define a local or parameter - // object @value; - Diagnostic(ErrorCode.ERR_LocalIllegallyOverrides, "@value").WithArguments("value").WithLocation(9, 20)); - } - else - { - comp.VerifyEmitDiagnostics( - // (9,20): error CS0136: A local or parameter named 'value' cannot be declared in this scope because that name is used in an enclosing local scope to define a local or parameter - // object @value; - Diagnostic(ErrorCode.ERR_LocalIllegallyOverrides, "@value").WithArguments("value").WithLocation(9, 20), - // (10,14): info CS9258: 'field' is a contextual keyword, with a specific meaning, starting in language version preview. Use '@field' to avoid a breaking change when compiling with language version preview or later. - // (field, @value) = new C(); - Diagnostic(ErrorCode.INF_IdentifierConflictWithContextualKeyword, "field").WithArguments("field", "preview").WithLocation(10, 14), - // (11,22): info CS9258: 'value' is a contextual keyword, with a specific meaning, starting in language version preview. Use '@value' to avoid a breaking change when compiling with language version preview or later. - // (@field, value) = new C(); - Diagnostic(ErrorCode.INF_IdentifierConflictWithContextualKeyword, "value").WithArguments("value", "preview").WithLocation(11, 22)); - } + comp.VerifyEmitDiagnostics( + // (9,20): error CS0136: A local or parameter named 'value' cannot be declared in this scope because that name is used in an enclosing local scope to define a local or parameter + // object @value; + Diagnostic(ErrorCode.ERR_LocalIllegallyOverrides, "@value").WithArguments("value").WithLocation(9, 20), + // (10,14): info CS9258: 'field' is a contextual keyword in property accessors starting in language version preview. Use '@field' instead. + // (field, @value) = new C(); + Diagnostic(ErrorCode.INF_IdentifierConflictWithContextualKeyword, "field").WithArguments("field", "preview").WithLocation(10, 14), + // (11,22): info CS9258: 'value' is a contextual keyword in property accessors starting in language version preview. Use '@value' instead. + // (@field, value) = new C(); + Diagnostic(ErrorCode.INF_IdentifierConflictWithContextualKeyword, "value").WithArguments("value", "preview").WithLocation(11, 22)); } [Theory] @@ -1185,23 +1020,16 @@ object P } """; var comp = CreateCompilation(source, parseOptions: TestOptions.Regular.WithLanguageVersion(languageVersion)); - if (languageVersion > LanguageVersion.CSharp12) - { - comp.VerifyEmitDiagnostics(); - } - else - { - comp.VerifyEmitDiagnostics( - // (12,23): info CS9258: 'field' is a contextual keyword, with a specific meaning, starting in language version preview. Use '@field' to avoid a breaking change when compiling with language version preview or later. - // f = () => field; - Diagnostic(ErrorCode.INF_IdentifierConflictWithContextualKeyword, "field").WithArguments("field", "preview").WithLocation(12, 23), - // (14,25): info CS9258: 'field' is a contextual keyword, with a specific meaning, starting in language version preview. Use '@field' to avoid a breaking change when compiling with language version preview or later. - // f = () => C.field; - Diagnostic(ErrorCode.INF_IdentifierConflictWithContextualKeyword, "field").WithArguments("field", "preview").WithLocation(14, 25), - // (17,25): info CS9258: 'value' is a contextual keyword, with a specific meaning, starting in language version preview. Use '@value' to avoid a breaking change when compiling with language version preview or later. - // f = () => C.value; - Diagnostic(ErrorCode.INF_IdentifierConflictWithContextualKeyword, "value").WithArguments("value", "preview").WithLocation(17, 25)); - } + comp.VerifyEmitDiagnostics( + // (12,23): info CS9258: 'field' is a contextual keyword in property accessors starting in language version preview. Use '@field' instead. + // f = () => field; + Diagnostic(ErrorCode.INF_IdentifierConflictWithContextualKeyword, "field").WithArguments("field", "preview").WithLocation(12, 23), + // (14,25): info CS9258: 'field' is a contextual keyword in property accessors starting in language version preview. Use '@field' instead. + // f = () => C.field; + Diagnostic(ErrorCode.INF_IdentifierConflictWithContextualKeyword, "field").WithArguments("field", "preview").WithLocation(14, 25), + // (17,25): info CS9258: 'value' is a contextual keyword in property accessors starting in language version preview. Use '@value' instead. + // f = () => C.value; + Diagnostic(ErrorCode.INF_IdentifierConflictWithContextualKeyword, "value").WithArguments("value", "preview").WithLocation(17, 25)); } [Theory] @@ -1232,23 +1060,16 @@ object P } """; var comp = CreateCompilation(source, parseOptions: TestOptions.Regular.WithLanguageVersion(languageVersion)); - if (languageVersion > LanguageVersion.CSharp12) - { - comp.VerifyEmitDiagnostics(); - } - else - { - comp.VerifyEmitDiagnostics( - // (10,28): info CS9258: 'field' is a contextual keyword, with a specific meaning, starting in language version preview. Use '@field' to avoid a breaking change when compiling with language version preview or later. - // object F1() => field; - Diagnostic(ErrorCode.INF_IdentifierConflictWithContextualKeyword, "field").WithArguments("field", "preview").WithLocation(10, 28), - // (12,30): info CS9258: 'field' is a contextual keyword, with a specific meaning, starting in language version preview. Use '@field' to avoid a breaking change when compiling with language version preview or later. - // object F3() => C.field; - Diagnostic(ErrorCode.INF_IdentifierConflictWithContextualKeyword, "field").WithArguments("field", "preview").WithLocation(12, 30), - // (15,36): info CS9258: 'value' is a contextual keyword, with a specific meaning, starting in language version preview. Use '@value' to avoid a breaking change when compiling with language version preview or later. - // object G2() { return C.value; } - Diagnostic(ErrorCode.INF_IdentifierConflictWithContextualKeyword, "value").WithArguments("value", "preview").WithLocation(15, 36)); - } + comp.VerifyEmitDiagnostics( + // (10,28): info CS9258: 'field' is a contextual keyword in property accessors starting in language version preview. Use '@field' instead. + // object F1() => field; + Diagnostic(ErrorCode.INF_IdentifierConflictWithContextualKeyword, "field").WithArguments("field", "preview").WithLocation(10, 28), + // (12,30): info CS9258: 'field' is a contextual keyword in property accessors starting in language version preview. Use '@field' instead. + // object F3() => C.field; + Diagnostic(ErrorCode.INF_IdentifierConflictWithContextualKeyword, "field").WithArguments("field", "preview").WithLocation(12, 30), + // (15,36): info CS9258: 'value' is a contextual keyword in property accessors starting in language version preview. Use '@value' instead. + // object G2() { return C.value; } + Diagnostic(ErrorCode.INF_IdentifierConflictWithContextualKeyword, "value").WithArguments("value", "preview").WithLocation(15, 36)); } [Fact] @@ -1279,10 +1100,10 @@ object P """; var comp = CreateCompilation(source, parseOptions: TestOptions.Regular12); comp.VerifyEmitDiagnostics( - // (10,32): info CS9258: 'field' is a contextual keyword, with a specific meaning, starting in language version preview. Use '@field' to avoid a breaking change when compiling with language version preview or later. + // (10,32): info CS9258: 'field' is a contextual keyword in property accessors starting in language version preview. Use '@field' instead. // f = () => { object field = 1; return null; }; Diagnostic(ErrorCode.INF_IdentifierConflictWithContextualKeyword, "field = 1").WithArguments("field", "preview").WithLocation(10, 32), - // (17,32): info CS9258: 'value' is a contextual keyword, with a specific meaning, starting in language version preview. Use '@value' to avoid a breaking change when compiling with language version preview or later. + // (17,32): info CS9258: 'value' is a contextual keyword in property accessors starting in language version preview. Use '@value' instead. // a = () => { object value = 1; }; Diagnostic(ErrorCode.INF_IdentifierConflictWithContextualKeyword, "value = 1").WithArguments("value", "preview").WithLocation(17, 32)); } @@ -1315,10 +1136,10 @@ object P """; var comp = CreateCompilation(source, parseOptions: TestOptions.Regular12); comp.VerifyEmitDiagnostics( - // (10,17): info CS9258: 'field' is a contextual keyword, with a specific meaning, starting in language version preview. Use '@field' to avoid a breaking change when compiling with language version preview or later. + // (10,17): info CS9258: 'field' is a contextual keyword in property accessors starting in language version preview. Use '@field' instead. // f = field => null; Diagnostic(ErrorCode.INF_IdentifierConflictWithContextualKeyword, "field").WithArguments("field", "preview").WithLocation(10, 17), - // (17,17): info CS9258: 'value' is a contextual keyword, with a specific meaning, starting in language version preview. Use '@value' to avoid a breaking change when compiling with language version preview or later. + // (17,17): info CS9258: 'value' is a contextual keyword in property accessors starting in language version preview. Use '@value' instead. // a = value => { }; Diagnostic(ErrorCode.INF_IdentifierConflictWithContextualKeyword, "value").WithArguments("value", "preview").WithLocation(17, 17)); } @@ -1344,10 +1165,10 @@ object P """; var comp = CreateCompilation(source, parseOptions: TestOptions.Regular12); comp.VerifyEmitDiagnostics( - // (10,18): info CS9258: 'field' is a contextual keyword, with a specific meaning, starting in language version preview. Use '@field' to avoid a breaking change when compiling with language version preview or later. + // (10,18): info CS9258: 'field' is a contextual keyword in property accessors starting in language version preview. Use '@field' instead. // a = (field, @value) => { }; Diagnostic(ErrorCode.INF_IdentifierConflictWithContextualKeyword, "field").WithArguments("field", "preview").WithLocation(10, 18), - // (11,26): info CS9258: 'value' is a contextual keyword, with a specific meaning, starting in language version preview. Use '@value' to avoid a breaking change when compiling with language version preview or later. + // (11,26): info CS9258: 'value' is a contextual keyword in property accessors starting in language version preview. Use '@value' instead. // a = (@field, value) => { }; Diagnostic(ErrorCode.INF_IdentifierConflictWithContextualKeyword, "value").WithArguments("value", "preview").WithLocation(11, 26)); } @@ -1373,10 +1194,10 @@ object P """; var comp = CreateCompilation(source, parseOptions: TestOptions.Regular12); comp.VerifyEmitDiagnostics( - // (10,27): info CS9258: 'field' is a contextual keyword, with a specific meaning, starting in language version preview. Use '@field' to avoid a breaking change when compiling with language version preview or later. + // (10,27): info CS9258: 'field' is a contextual keyword in property accessors starting in language version preview. Use '@field' instead. // a = delegate (object field, object @value) { }; Diagnostic(ErrorCode.INF_IdentifierConflictWithContextualKeyword, "object field").WithArguments("field", "preview").WithLocation(10, 27), - // (11,42): info CS9258: 'value' is a contextual keyword, with a specific meaning, starting in language version preview. Use '@value' to avoid a breaking change when compiling with language version preview or later. + // (11,42): info CS9258: 'value' is a contextual keyword in property accessors starting in language version preview. Use '@value' instead. // a = delegate (object @field, object value) { }; Diagnostic(ErrorCode.INF_IdentifierConflictWithContextualKeyword, "object value").WithArguments("value", "preview").WithLocation(11, 42)); } @@ -1406,10 +1227,10 @@ object P """; var comp = CreateCompilation(source, parseOptions: TestOptions.Regular12); comp.VerifyEmitDiagnostics( - // (8,34): info CS9258: 'field' is a contextual keyword, with a specific meaning, starting in language version preview. Use '@field' to avoid a breaking change when compiling with language version preview or later. + // (8,34): info CS9258: 'field' is a contextual keyword in property accessors starting in language version preview. Use '@field' instead. // object F1() { object field = 1; return null; }; Diagnostic(ErrorCode.INF_IdentifierConflictWithContextualKeyword, "field = 1").WithArguments("field", "preview").WithLocation(8, 34), - // (14,32): info CS9258: 'value' is a contextual keyword, with a specific meaning, starting in language version preview. Use '@value' to avoid a breaking change when compiling with language version preview or later. + // (14,32): info CS9258: 'value' is a contextual keyword in property accessors starting in language version preview. Use '@value' instead. // void G1() { object value = 1; } Diagnostic(ErrorCode.INF_IdentifierConflictWithContextualKeyword, "value = 1").WithArguments("value", "preview").WithLocation(14, 32)); } @@ -1439,10 +1260,10 @@ void G2(object @value) { } """; var comp = CreateCompilation(source, parseOptions: TestOptions.Regular12); comp.VerifyEmitDiagnostics( - // (8,23): info CS9258: 'field' is a contextual keyword, with a specific meaning, starting in language version preview. Use '@field' to avoid a breaking change when compiling with language version preview or later. + // (8,23): info CS9258: 'field' is a contextual keyword in property accessors starting in language version preview. Use '@field' instead. // object F1(object field) => null; Diagnostic(ErrorCode.INF_IdentifierConflictWithContextualKeyword, "object field").WithArguments("field", "preview").WithLocation(8, 23), - // (14,21): info CS9258: 'value' is a contextual keyword, with a specific meaning, starting in language version preview. Use '@value' to avoid a breaking change when compiling with language version preview or later. + // (14,21): info CS9258: 'value' is a contextual keyword in property accessors starting in language version preview. Use '@value' instead. // void G1(object value) { } Diagnostic(ErrorCode.INF_IdentifierConflictWithContextualKeyword, "object value").WithArguments("value", "preview").WithLocation(14, 21)); } @@ -1584,23 +1405,23 @@ object P3 } """; var comp = CreateCompilation(source, parseOptions: TestOptions.Regular.WithLanguageVersion(languageVersion)); - if (languageVersion > LanguageVersion.CSharp12 || escapeIdentifier) + if (escapeIdentifier) { comp.VerifyEmitDiagnostics(); } else { comp.VerifyEmitDiagnostics( - // (13,23): info CS9258: 'field' is a contextual keyword, with a specific meaning, starting in language version preview. Use '@field' to avoid a breaking change when compiling with language version preview or later. + // (13,23): info CS9258: 'field' is a contextual keyword in property accessors starting in language version preview. Use '@field' instead. // [A(nameof(field))] void F1(int field) { } Diagnostic(ErrorCode.INF_IdentifierConflictWithContextualKeyword, "field").WithArguments("field", "preview").WithLocation(13, 23), - // (13,40): info CS9258: 'field' is a contextual keyword, with a specific meaning, starting in language version preview. Use '@field' to avoid a breaking change when compiling with language version preview or later. + // (13,40): info CS9258: 'field' is a contextual keyword in property accessors starting in language version preview. Use '@field' instead. // [A(nameof(field))] void F1(int field) { } Diagnostic(ErrorCode.INF_IdentifierConflictWithContextualKeyword, "int field").WithArguments("field", "preview").WithLocation(13, 40), - // (21,23): info CS9258: 'value' is a contextual keyword, with a specific meaning, starting in language version preview. Use '@value' to avoid a breaking change when compiling with language version preview or later. + // (21,23): info CS9258: 'value' is a contextual keyword in property accessors starting in language version preview. Use '@value' instead. // [A(nameof(value))] void F2(int value) { } Diagnostic(ErrorCode.INF_IdentifierConflictWithContextualKeyword, "value").WithArguments("value", "preview").WithLocation(21, 23), - // (21,40): info CS9258: 'value' is a contextual keyword, with a specific meaning, starting in language version preview. Use '@value' to avoid a breaking change when compiling with language version preview or later. + // (21,40): info CS9258: 'value' is a contextual keyword in property accessors starting in language version preview. Use '@value' instead. // [A(nameof(value))] void F2(int value) { } Diagnostic(ErrorCode.INF_IdentifierConflictWithContextualKeyword, "int value").WithArguments("value", "preview").WithLocation(21, 40)); }