From d5ba2a9448ea06cd59fffbe8b957b4dd4c30c55b Mon Sep 17 00:00:00 2001 From: Tomas Matousek Date: Fri, 22 May 2015 12:38:11 -0700 Subject: [PATCH] C# EnC: handle addition of indexer --- .../EditAndContinue/RudeEditTopLevelTests.cs | 10 ++++++++++ .../EditAndContinue/CSharpEditAndContinueAnalyzer.cs | 5 +++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/EditorFeatures/CSharpTest/EditAndContinue/RudeEditTopLevelTests.cs b/src/EditorFeatures/CSharpTest/EditAndContinue/RudeEditTopLevelTests.cs index 0c10aebd9ba..b619b1b5a8b 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 647350b692f..9a31d465abf 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) -- GitLab