diff --git a/src/EditorFeatures/CSharpTest/EditAndContinue/RudeEditTopLevelTests.cs b/src/EditorFeatures/CSharpTest/EditAndContinue/RudeEditTopLevelTests.cs index 0c10aebd9ba063bada7bf9165eec2a00d0d42590..b619b1b5a8b407ac875272177d6ad89edc25502c 100644 --- a/src/EditorFeatures/CSharpTest/EditAndContinue/RudeEditTopLevelTests.cs +++ b/src/EditorFeatures/CSharpTest/EditAndContinue/RudeEditTopLevelTests.cs @@ -6881,6 +6881,16 @@ class SampleCollection Diagnostic(RudeEditKind.Delete, "public T this[int i]", CSharpFeaturesResources.IndexerSetter)); } + [Fact, WorkItem(1174850)] + public void Indexer_Insert() + { + var src1 = "struct C { }"; + var src2 = "struct C { public int this[int x, int y] { get { return x + y; } } }"; + + var edits = GetTopEdits(src1, src2); + edits.VerifySemanticDiagnostics(); + } + [WorkItem(1120407)] [Fact] public void ConstField_Update() diff --git a/src/Features/CSharp/EditAndContinue/CSharpEditAndContinueAnalyzer.cs b/src/Features/CSharp/EditAndContinue/CSharpEditAndContinueAnalyzer.cs index 647350b692fc1353e1c56558f444ae19910294a0..9a31d465abfdd6e06e8b4cb6d7d48887c71a22a2 100644 --- a/src/Features/CSharp/EditAndContinue/CSharpEditAndContinueAnalyzer.cs +++ b/src/Features/CSharp/EditAndContinue/CSharpEditAndContinueAnalyzer.cs @@ -825,9 +825,10 @@ internal override SyntaxNode TryGetContainingTypeDeclaration(SyntaxNode memberDe return memberDeclaration.Parent.FirstAncestorOrSelf(); } - internal override bool HasBackingField(SyntaxNode propertyDeclaration) + internal override bool HasBackingField(SyntaxNode propertyOrIndexerDeclaration) { - return SyntaxUtilities.HasBackingField((PropertyDeclarationSyntax)propertyDeclaration); + return propertyOrIndexerDeclaration.IsKind(SyntaxKind.PropertyDeclaration) && + SyntaxUtilities.HasBackingField((PropertyDeclarationSyntax)propertyOrIndexerDeclaration); } internal override bool IsDeclarationWithInitializer(SyntaxNode declaration)