diff --git a/src/Compilers/CSharp/Portable/Binder/Binder.QueryTranslationState.cs b/src/Compilers/CSharp/Portable/Binder/Binder.QueryTranslationState.cs index f478125bd43d7..9a03f2d86a0ff 100644 --- a/src/Compilers/CSharp/Portable/Binder/Binder.QueryTranslationState.cs +++ b/src/Compilers/CSharp/Portable/Binder/Binder.QueryTranslationState.cs @@ -76,7 +76,6 @@ internal RangeVariableSymbol AddRangeVariable(Binder binder, SyntaxToken identif bool error = false; Debug.Assert(identifier.Parent is { }); - binder.ReportFieldOrValueContextualKeywordConflictIfAny(identifier.Parent, identifier, diagnostics); foreach (var existingRangeVariable in allRangeVariables.Keys) { diff --git a/src/Compilers/CSharp/Portable/Binder/Binder_Deconstruct.cs b/src/Compilers/CSharp/Portable/Binder/Binder_Deconstruct.cs index 95cba95f8b1ab..5341638741f87 100644 --- a/src/Compilers/CSharp/Portable/Binder/Binder_Deconstruct.cs +++ b/src/Compilers/CSharp/Portable/Binder/Binder_Deconstruct.cs @@ -869,8 +869,6 @@ private BoundExpression BindDeconstructionVariable( { SourceLocalSymbol localSymbol = LookupLocal(designation.Identifier); - ReportFieldOrValueContextualKeywordConflictIfAny(designation, designation.Identifier, diagnostics); - // is this a local? if ((object)localSymbol != null) { diff --git a/src/Compilers/CSharp/Portable/Binder/Binder_Expressions.cs b/src/Compilers/CSharp/Portable/Binder/Binder_Expressions.cs index 2953c9871b130..bb0a83055f3ea 100644 --- a/src/Compilers/CSharp/Portable/Binder/Binder_Expressions.cs +++ b/src/Compilers/CSharp/Portable/Binder/Binder_Expressions.cs @@ -3116,8 +3116,6 @@ private BoundExpression BindOutVariableDeclarationArgument( var designation = (SingleVariableDesignationSyntax)declarationExpression.Designation; TypeSyntax typeSyntax = declarationExpression.Type; - ReportFieldOrValueContextualKeywordConflictIfAny(designation, designation.Identifier, diagnostics); - // Is this a local? SourceLocalSymbol localSymbol = this.LookupLocal(designation.Identifier); if ((object)localSymbol != null) @@ -7510,8 +7508,6 @@ private BoundExpression BindMemberAccessWithBoundLeft( boundLeft = MakeMemberAccessValue(boundLeft, diagnostics); - ReportFieldOrValueContextualKeywordConflictIfAny(right, right.Identifier, diagnostics); - TypeSymbol leftType = boundLeft.Type; if ((object)leftType != null && leftType.IsDynamic()) diff --git a/src/Compilers/CSharp/Portable/Binder/Binder_Lambda.cs b/src/Compilers/CSharp/Portable/Binder/Binder_Lambda.cs index 9fbebe75d6656..fd65a700503d9 100644 --- a/src/Compilers/CSharp/Portable/Binder/Binder_Lambda.cs +++ b/src/Compilers/CSharp/Portable/Binder/Binder_Lambda.cs @@ -69,7 +69,6 @@ private UnboundLambda AnalyzeAnonymousFunction( // x => ... hasSignature = true; var simple = (SimpleLambdaExpressionSyntax)syntax; - ReportFieldOrValueContextualKeywordConflictIfAny(simple.Parameter, simple.Parameter.Identifier, diagnostics); namesBuilder.Add(simple.Parameter.Identifier.ValueText); break; case SyntaxKind.ParenthesizedLambdaExpression: @@ -193,8 +192,6 @@ private UnboundLambda AnalyzeAnonymousFunction( } } - ReportFieldOrValueContextualKeywordConflictIfAny(p, p.Identifier, diagnostics); - namesBuilder.Add(p.Identifier.ValueText); typesBuilder.Add(type); refKindsBuilder.Add(refKind); diff --git a/src/Compilers/CSharp/Portable/Binder/Binder_Statements.cs b/src/Compilers/CSharp/Portable/Binder/Binder_Statements.cs index 4c34e43f527fc..b0f799d6ae6c3 100644 --- a/src/Compilers/CSharp/Portable/Binder/Binder_Statements.cs +++ b/src/Compilers/CSharp/Portable/Binder/Binder_Statements.cs @@ -474,8 +474,6 @@ private BoundLabeledStatement BindLabeled(LabeledStatementSyntax node, BindingDi CompoundUseSiteInfo useSiteInfo = GetNewCompoundUseSiteInfo(diagnostics); var binder = this.LookupSymbolsWithFallback(result, node.Identifier.ValueText, arity: 0, useSiteInfo: ref useSiteInfo, options: LookupOptions.LabelsOnly); - ReportFieldOrValueContextualKeywordConflictIfAny(node, node.Identifier, diagnostics); - // result.Symbols can be empty in some malformed code, e.g. when a labeled statement is used an embedded statement in an if or foreach statement // In this case we create new label symbol on the fly, and an error is reported by parser var symbol = result.Symbols.Count > 0 && result.IsMultiViable ? @@ -556,8 +554,6 @@ private BoundStatement BindLocalFunctionStatement(LocalFunctionStatementSyntax n { MessageID.IDS_FeatureLocalFunctions.CheckFeatureAvailability(diagnostics, node.Identifier); - ReportFieldOrValueContextualKeywordConflictIfAny(node, node.Identifier, diagnostics); - // already defined symbol in containing block var localSymbol = this.LookupLocalFunction(node.Identifier); @@ -960,7 +956,7 @@ protected BoundLocalDeclaration BindVariableDeclaration( { Debug.Assert(declarator != null); - return BindVariableDeclaration(LocateDeclaredVariableSymbol(declarator, typeSyntax, kind, diagnostics), + return BindVariableDeclaration(LocateDeclaredVariableSymbol(declarator, typeSyntax, kind), kind, isVar, declarator, @@ -1194,10 +1190,8 @@ internal ImmutableArray BindDeclaratorArguments(VariableDeclara return arguments; } - private SourceLocalSymbol LocateDeclaredVariableSymbol(VariableDeclaratorSyntax declarator, TypeSyntax typeSyntax, LocalDeclarationKind outerKind, BindingDiagnosticBag diagnostics) + private SourceLocalSymbol LocateDeclaredVariableSymbol(VariableDeclaratorSyntax declarator, TypeSyntax typeSyntax, LocalDeclarationKind outerKind) { - ReportFieldOrValueContextualKeywordConflictIfAny(declarator, declarator.Identifier, diagnostics); - LocalDeclarationKind kind = outerKind == LocalDeclarationKind.UsingVariable ? LocalDeclarationKind.UsingVariable : LocalDeclarationKind.RegularVariable; return LocateDeclaredVariableSymbol(declarator.Identifier, typeSyntax, declarator.Initializer, kind); } @@ -3152,8 +3146,6 @@ private BoundCatchBlock BindCatchBlock(CatchClauseSyntax node, ArrayBuilder useSiteInfo = GetNewCompoundUseSiteInfo(diagnostics); this.LookupSymbolsSimpleName(result, qualifierOpt, identifierValueText, 0, basesBeingResolved, options, diagnose: true, useSiteInfo: ref useSiteInfo); diagnostics.Add(node, useSiteInfo); @@ -1213,8 +1210,6 @@ private TypeWithAnnotations BindGenericSimpleNamespaceOrTypeOrAliasSymbol( diagnostics, basesBeingResolved, qualifierOpt, node, plainName, node.Arity, options); NamedTypeSymbol resultType; - ReportFieldOrValueContextualKeywordConflictIfAny(node, node.Identifier, diagnostics); - if (isUnboundTypeExpr) { if (!IsUnboundTypeAllowed(node)) diff --git a/src/Compilers/CSharp/Portable/Binder/ForEachLoopBinder.cs b/src/Compilers/CSharp/Portable/Binder/ForEachLoopBinder.cs index 8a60227881fd5..888094f169b44 100644 --- a/src/Compilers/CSharp/Portable/Binder/ForEachLoopBinder.cs +++ b/src/Compilers/CSharp/Portable/Binder/ForEachLoopBinder.cs @@ -220,11 +220,6 @@ private BoundForEachStatement BindForEachPartsWorker(BindingDiagnosticBag diagno CheckFeatureAvailability(_syntax.AwaitKeyword, MessageID.IDS_FeatureAsyncStreams, diagnostics); } - if (_syntax is ForEachStatementSyntax forEachStatement) - { - ReportFieldOrValueContextualKeywordConflictIfAny(forEachStatement, forEachStatement.Identifier, diagnostics); - } - // Use the right binder to avoid seeing iteration variable BoundExpression collectionExpr = originalBinder.GetBinder(_syntax.Expression).BindRValueWithoutTargetType(_syntax.Expression, diagnostics); diff --git a/src/Compilers/CSharp/Portable/Symbols/Source/LocalFunctionSymbol.cs b/src/Compilers/CSharp/Portable/Symbols/Source/LocalFunctionSymbol.cs index 135b21292c1a7..365ff44b2d4f9 100644 --- a/src/Compilers/CSharp/Portable/Symbols/Source/LocalFunctionSymbol.cs +++ b/src/Compilers/CSharp/Portable/Symbols/Source/LocalFunctionSymbol.cs @@ -201,11 +201,6 @@ private void ComputeParameters() addRefReadOnlyModifier: false, diagnostics: diagnostics).Cast(); - foreach (var parameter in this.Syntax.ParameterList.Parameters) - { - WithTypeParametersBinder.ReportFieldOrValueContextualKeywordConflictIfAny(parameter, parameter.Identifier, diagnostics); - } - // Note: we don't need to warn on annotations used in #nullable disable context for local functions, as this is handled in binding already var isVararg = arglistToken.Kind() == SyntaxKind.ArgListKeyword; @@ -437,7 +432,6 @@ private ImmutableArray MakeTypeParameters(Bindi } SourceMemberContainerTypeSymbol.ReportReservedTypeName(identifier.Text, this.DeclaringCompilation, diagnostics.DiagnosticBag, location); - _binder.ReportFieldOrValueContextualKeywordConflictIfAny(parameter, identifier, diagnostics); var tpEnclosing = ContainingSymbol.FindEnclosingTypeParameter(name); if ((object?)tpEnclosing != null) diff --git a/src/Compilers/CSharp/Test/Semantic/Semantics/SemanticErrorTests.cs b/src/Compilers/CSharp/Test/Semantic/Semantics/SemanticErrorTests.cs index 6b9d8dbbb42ec..a84424081226b 100644 --- a/src/Compilers/CSharp/Test/Semantic/Semantics/SemanticErrorTests.cs +++ b/src/Compilers/CSharp/Test/Semantic/Semantics/SemanticErrorTests.cs @@ -4010,9 +4010,6 @@ 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 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 in property accessors starting in language version preview. Use '@value' instead. // M(value); Diagnostic(ErrorCode.INF_IdentifierConflictWithContextualKeyword, "value").WithArguments("value", "preview").WithLocation(25, 15), @@ -4028,9 +4025,6 @@ 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), diff --git a/src/Compilers/CSharp/Test/Symbol/Symbols/SymbolErrorTests.cs b/src/Compilers/CSharp/Test/Symbol/Symbols/SymbolErrorTests.cs index 0eae9509c6c3e..67598be201e58 100644 --- a/src/Compilers/CSharp/Test/Symbol/Symbols/SymbolErrorTests.cs +++ b/src/Compilers/CSharp/Test/Symbol/Symbols/SymbolErrorTests.cs @@ -2495,9 +2495,6 @@ public byte MyProp // (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), diff --git a/src/Compilers/CSharp/Test/Syntax/Syntax/FieldAndValueKeywordTests.cs b/src/Compilers/CSharp/Test/Syntax/Syntax/FieldAndValueKeywordTests.cs index d480140254fdf..c75aa8c128a83 100644 --- a/src/Compilers/CSharp/Test/Syntax/Syntax/FieldAndValueKeywordTests.cs +++ b/src/Compilers/CSharp/Test/Syntax/Syntax/FieldAndValueKeywordTests.cs @@ -101,20 +101,7 @@ 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) - { - comp.VerifyEmitDiagnostics(); - } - else - { - comp.VerifyEmitDiagnostics( - // (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 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)); - } + comp.VerifyEmitDiagnostics(); } [Theory] @@ -231,13 +218,7 @@ event EventHandler E3 } """; var comp = CreateCompilation(source, parseOptions: TestOptions.Regular.WithLanguageVersion(languageVersion)); - 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)); + comp.VerifyEmitDiagnostics(); } [Theory] @@ -300,20 +281,7 @@ class C : I } """; var comp = CreateCompilation(source, parseOptions: TestOptions.Regular.WithLanguageVersion(languageVersion)); - if (escapeIdentifier) - { - comp.VerifyEmitDiagnostics(); - } - else - { - comp.VerifyEmitDiagnostics( - // (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 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)); - } + comp.VerifyEmitDiagnostics(); } [Theory] @@ -338,20 +306,7 @@ class C : I } """; 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)); - } + comp.VerifyEmitDiagnostics(); } [Theory] @@ -380,20 +335,7 @@ event EventHandler I.E } """; var comp = CreateCompilation(source, parseOptions: TestOptions.Regular.WithLanguageVersion(languageVersion)); - if (escapeIdentifier || identifier == "field") - { - comp.VerifyEmitDiagnostics(); - } - else - { - comp.VerifyEmitDiagnostics( - // (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 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)); - } + comp.VerifyEmitDiagnostics(); } [Theory] @@ -414,13 +356,7 @@ class C } """; var comp = CreateCompilation(source, parseOptions: TestOptions.Regular.WithLanguageVersion(languageVersion)); - 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)); + comp.VerifyEmitDiagnostics(); } [Theory] @@ -441,13 +377,29 @@ class C } """; var comp = CreateCompilation(source, parseOptions: TestOptions.Regular.WithLanguageVersion(languageVersion)); + comp.VerifyEmitDiagnostics(); + } + + [Theory] + [CombinatorialData] + public void IdentifierToken_Invocation( + [CombinatorialValues(LanguageVersion.CSharp12, LanguageVersion.Preview)] LanguageVersion languageVersion) + { + string source = """ + #pragma warning disable 649 + using System; + class C + { + Func field; + object P1 { get { return field(); } } + object P2 { get { return @field(); } } + } + """; + var comp = CreateCompilation(source, parseOptions: TestOptions.Regular.WithLanguageVersion(languageVersion)); 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)); + // (6,30): info CS9258: 'field' is a contextual keyword in property accessors starting in language version preview. Use '@field' instead. + // object P1 { get { return field(); } } + Diagnostic(ErrorCode.INF_IdentifierConflictWithContextualKeyword, "field").WithArguments("field", "preview").WithLocation(6, 30)); } [Theory] @@ -464,13 +416,7 @@ class C } """; var comp = CreateCompilation(source, parseOptions: TestOptions.Regular.WithLanguageVersion(languageVersion)); - 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)); + comp.VerifyEmitDiagnostics(); } [Theory] @@ -490,15 +436,9 @@ class C """; var comp = CreateCompilation(source, parseOptions: TestOptions.Regular.WithLanguageVersion(languageVersion)); 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), @@ -527,15 +467,9 @@ class C """; var comp = CreateCompilation(source, parseOptions: TestOptions.Regular.WithLanguageVersion(languageVersion)); 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), @@ -564,15 +498,9 @@ class C """; var comp = CreateCompilation(source, parseOptions: TestOptions.Regular.WithLanguageVersion(languageVersion)); 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), @@ -601,15 +529,9 @@ class C """; var comp = CreateCompilation(source, parseOptions: TestOptions.Regular.WithLanguageVersion(languageVersion)); 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), @@ -638,15 +560,9 @@ class C """; var comp = CreateCompilation(source, parseOptions: TestOptions.Regular.WithLanguageVersion(languageVersion)); 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), @@ -675,12 +591,6 @@ class C """; var comp = CreateCompilation(source, parseOptions: TestOptions.Regular.WithLanguageVersion(languageVersion)); 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), @@ -706,15 +616,9 @@ class C """; var comp = CreateCompilation(source, parseOptions: TestOptions.Regular.WithLanguageVersion(languageVersion)); 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)); @@ -739,15 +643,9 @@ class C """; var comp = CreateCompilation(source, parseOptions: TestOptions.Regular.WithLanguageVersion(languageVersion)); 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)); @@ -769,13 +667,7 @@ class C } """; var comp = CreateCompilation(source, parseOptions: TestOptions.Regular.WithLanguageVersion(languageVersion)); - 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)); + comp.VerifyEmitDiagnostics(); } [Theory] @@ -794,12 +686,6 @@ class C """; var comp = CreateCompilation(source, parseOptions: TestOptions.Regular.WithLanguageVersion(languageVersion)); 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), @@ -822,18 +708,12 @@ class C """; var comp = CreateCompilation(source, parseOptions: TestOptions.Regular.WithLanguageVersion(languageVersion)); 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)); + Diagnostic(ErrorCode.ERR_LocalIllegallyOverrides, "value").WithArguments("value").WithLocation(4, 45)); } [Theory] @@ -854,12 +734,6 @@ class C """; var comp = CreateCompilation(source, parseOptions: TestOptions.Regular.WithLanguageVersion(languageVersion)); 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), @@ -884,13 +758,7 @@ class C } """; var comp = CreateCompilation(source, parseOptions: TestOptions.Regular.WithLanguageVersion(languageVersion)); - 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)); + comp.VerifyEmitDiagnostics(); } [Theory] @@ -910,15 +778,9 @@ class C """; var comp = CreateCompilation(source, parseOptions: TestOptions.Regular.WithLanguageVersion(languageVersion)); 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)); @@ -1023,13 +885,7 @@ object P 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)); + Diagnostic(ErrorCode.INF_IdentifierConflictWithContextualKeyword, "field").WithArguments("field", "preview").WithLocation(12, 23)); } [Theory] @@ -1063,13 +919,7 @@ object P 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)); + Diagnostic(ErrorCode.INF_IdentifierConflictWithContextualKeyword, "field").WithArguments("field", "preview").WithLocation(10, 28)); } [Fact] @@ -1099,13 +949,7 @@ object P } """; var comp = CreateCompilation(source, parseOptions: TestOptions.Regular12); - comp.VerifyEmitDiagnostics( - // (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 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)); + comp.VerifyEmitDiagnostics(); } [Fact] @@ -1135,13 +979,7 @@ object P } """; var comp = CreateCompilation(source, parseOptions: TestOptions.Regular12); - comp.VerifyEmitDiagnostics( - // (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 in property accessors starting in language version preview. Use '@value' instead. - // a = value => { }; - Diagnostic(ErrorCode.INF_IdentifierConflictWithContextualKeyword, "value").WithArguments("value", "preview").WithLocation(17, 17)); + comp.VerifyEmitDiagnostics(); } [Fact] @@ -1164,13 +1002,7 @@ object P } """; var comp = CreateCompilation(source, parseOptions: TestOptions.Regular12); - comp.VerifyEmitDiagnostics( - // (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 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)); + comp.VerifyEmitDiagnostics(); } [Fact] @@ -1193,13 +1025,7 @@ object P } """; var comp = CreateCompilation(source, parseOptions: TestOptions.Regular12); - comp.VerifyEmitDiagnostics( - // (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 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)); + comp.VerifyEmitDiagnostics(); } [Fact] @@ -1226,13 +1052,7 @@ object P } """; var comp = CreateCompilation(source, parseOptions: TestOptions.Regular12); - comp.VerifyEmitDiagnostics( - // (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 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)); + comp.VerifyEmitDiagnostics(); } [Fact] @@ -1259,13 +1079,7 @@ void G2(object @value) { } } """; var comp = CreateCompilation(source, parseOptions: TestOptions.Regular12); - comp.VerifyEmitDiagnostics( - // (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 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)); + comp.VerifyEmitDiagnostics(); } [Theory] @@ -1415,15 +1229,9 @@ object P3 // (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 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 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 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)); + Diagnostic(ErrorCode.INF_IdentifierConflictWithContextualKeyword, "value").WithArguments("value", "preview").WithLocation(21, 23)); } } }