Skip to content

Commit 427f3d3

Browse files
authored
Fix handling of partial definition deletes (#77735)
1 parent 28b8657 commit 427f3d3

File tree

3 files changed

+17
-20
lines changed

3 files changed

+17
-20
lines changed

src/Features/CSharpTest/EditAndContinue/TopLevelEditingTests.cs

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10257,6 +10257,17 @@ public void Method_Partial_DeleteImplementation()
1025710257
]);
1025810258
}
1025910259

10260+
[Fact]
10261+
public void Method_Partial_DeleteDefinition()
10262+
{
10263+
var src1 = "partial class C { partial void F(); }";
10264+
var src2 = "partial class C { }";
10265+
10266+
var edits = GetTopEdits(src1, src2);
10267+
10268+
edits.VerifySemantics();
10269+
}
10270+
1026010271
[Fact]
1026110272
public void Method_Partial_DeleteBoth()
1026210273
{
@@ -10269,8 +10280,7 @@ public void Method_Partial_DeleteBoth()
1026910280
EditAndContinueValidation.VerifySemantics(
1027010281
[GetTopEdits(srcA1, srcA2), GetTopEdits(srcB1, srcB2)],
1027110282
[
10272-
DocumentResults(
10273-
semanticEdits: [SemanticEdit(SemanticEditKind.Delete, c => c.GetMember<IMethodSymbol>("C.F").PartialImplementationPart, deletedSymbolContainerProvider: c => c.GetMember("C"), partialType: "C")]),
10283+
DocumentResults(),
1027410284
DocumentResults(
1027510285
semanticEdits: [SemanticEdit(SemanticEditKind.Delete, c => c.GetMember<IMethodSymbol>("C.F").PartialImplementationPart, deletedSymbolContainerProvider: c => c.GetMember("C"), partialType: "C")]),
1027610286
]);
@@ -11830,11 +11840,7 @@ public void Constructor_Parameter_Insert_Primary_Record_WithCustomDeconstructor_
1183011840
SemanticEdit(SemanticEditKind.Delete, c => c.GetPrimaryConstructor("C"), deletedSymbolContainerProvider: c => c.GetMember("C")),
1183111841
SemanticEdit(SemanticEditKind.Insert, c => c.GetPrimaryConstructor("C")),
1183211842
]),
11833-
DocumentResults(
11834-
semanticEdits:
11835-
[
11836-
SemanticEdit(SemanticEditKind.Delete, c => c.GetPrimaryDeconstructor("C").PartialImplementationPart, deletedSymbolContainerProvider: c => c.GetMember("C"), partialType: "C"),
11837-
]),
11843+
DocumentResults(),
1183811844
],
1183911845
capabilities: EditAndContinueCapabilities.AddMethodToExistingType | EditAndContinueCapabilities.AddInstanceFieldToExistingType);
1184011846
}
@@ -19301,12 +19307,7 @@ public void Property_Partial_DeleteBoth()
1930119307
EditAndContinueValidation.VerifySemantics(
1930219308
[GetTopEdits(srcA1, srcA2), GetTopEdits(srcB1, srcB2)],
1930319309
[
19304-
DocumentResults(
19305-
semanticEdits:
19306-
[
19307-
SemanticEdit(SemanticEditKind.Delete, c => c.GetMember<IPropertySymbol>("C.P").PartialImplementationPart, deletedSymbolContainerProvider: c => c.GetMember("C"), partialType: "C"),
19308-
SemanticEdit(SemanticEditKind.Delete, c => c.GetMember<IMethodSymbol>("C.get_P").PartialImplementationPart, deletedSymbolContainerProvider: c => c.GetMember("C"), partialType: "C")
19309-
]),
19310+
DocumentResults(),
1931019311
DocumentResults(
1931119312
semanticEdits:
1931219313
[

src/Features/Core/Portable/EditAndContinue/AbstractEditAndContinueAnalyzer.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2721,8 +2721,8 @@ newSymbol is IPropertySymbol newProperty &&
27212721
}
27222722

27232723
// If a partial method/property/indexer definition is deleted (and not moved to another partial type declaration, which is handled above)
2724-
// so must be the implementation. An edit will be issued for the implementation change.
2725-
if (newSymbol?.IsPartialDefinition() == true)
2724+
// so must be the implementation (if it exists). An edit will be issued for the implementation change.
2725+
if (oldSymbol.IsPartialDefinition())
27262726
{
27272727
continue;
27282728
}

src/Features/VisualBasicTest/EditAndContinue/TopLevelEditingTests.vb

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6029,11 +6029,7 @@ End Interface
60296029
EditAndContinueValidation.VerifySemantics(
60306030
{GetTopEdits(srcA1, srcA2), GetTopEdits(srcB1, srcB2)},
60316031
{
6032-
DocumentResults(
6033-
semanticEdits:=
6034-
{
6035-
SemanticEdit(SemanticEditKind.Delete, Function(c) c.GetMember(Of MethodSymbol)("C.F").PartialImplementationPart, deletedSymbolContainerProvider:=Function(c) c.GetMember("C"), partialType:="C")
6036-
}),
6032+
DocumentResults(),
60376033
DocumentResults(
60386034
semanticEdits:=
60396035
{

0 commit comments

Comments
 (0)