Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[EnC] Support more symbol deletes #62151

Merged
merged 6 commits into from
Jul 10, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Update existing tests
  • Loading branch information
davidwengier committed Jun 28, 2022
commit 472dce00105523fb8326fdccc802158f97b33831
Original file line number Diff line number Diff line change
@@ -3233,8 +3233,13 @@ public void Record_DeleteProperty_NotPrimary()

var edits = GetTopEdits(src1, src2);

edits.VerifySemanticDiagnostics(
Diagnostic(RudeEditKind.Delete, "record C", DeletedSymbolDisplay(FeaturesResources.auto_property, "P")));
edits.VerifySemantics(
new[]
{
SemanticEdit(SemanticEditKind.Delete, c => c.GetMember("C.get_P"), deletedSymbolContainerProvider: c => c.GetMember("C")),
SemanticEdit(SemanticEditKind.Delete, c => c.GetMember("C.set_P"), deletedSymbolContainerProvider: c => c.GetMember("C")),
},
capabilities: EditAndContinueCapabilities.Baseline);
}

[Fact]
@@ -3627,8 +3632,13 @@ record C(int X)

var edits = GetTopEdits(src1, src2);

edits.VerifySemanticDiagnostics(
Diagnostic(RudeEditKind.Delete, "record C", DeletedSymbolDisplay(FeaturesResources.auto_property, "Y")));
edits.VerifySemantics(
new[]
{
SemanticEdit(SemanticEditKind.Delete, c => c.GetMember("C.get_Y"), deletedSymbolContainerProvider: c => c.GetMember("C")),
SemanticEdit(SemanticEditKind.Delete, c => c.GetMember("C.set_Y"), deletedSymbolContainerProvider: c => c.GetMember("C")),
},
capabilities: EditAndContinueCapabilities.Baseline);
}

[Fact]
@@ -9037,9 +9047,13 @@ class C
}";
var edits = GetTopEdits(src1, src2);

edits.VerifySemanticDiagnostics(
Diagnostic(RudeEditKind.Delete, "class C", DeletedSymbolDisplay(CSharpFeaturesResources.conversion_operator, "implicit operator bool(C c)")),
Diagnostic(RudeEditKind.Delete, "class C", DeletedSymbolDisplay(FeaturesResources.operator_, "operator +(C c, C d)")));
edits.VerifySemantics(
new[]
{
SemanticEdit(SemanticEditKind.Delete, c => c.GetMember("C.op_Implicit"), deletedSymbolContainerProvider: c => c.GetMember("C")),
davidwengier marked this conversation as resolved.
Show resolved Hide resolved
SemanticEdit(SemanticEditKind.Delete, c => c.GetMember("C.op_Addition"), deletedSymbolContainerProvider: c => c.GetMember("C")),
},
capabilities: EditAndContinueCapabilities.Baseline);
}

[Fact]
@@ -13474,8 +13488,13 @@ public void Property_BlockBodyToExpressionBody2()
"Delete [get { return 2; }]@18",
"Delete [set { }]@36");

edits.VerifySemanticDiagnostics(
Diagnostic(RudeEditKind.Delete, "int P", DeletedSymbolDisplay(CSharpFeaturesResources.property_setter, "P.set")));
edits.VerifySemantics(
new[]
{
SemanticEdit(SemanticEditKind.Update, c => c.GetMember("C.get_P"), preserveLocalVariables: false),
SemanticEdit(SemanticEditKind.Delete, c => c.GetMember("C.set_P"), deletedSymbolContainerProvider: c => c.GetMember("C")),
},
capabilities: EditAndContinueCapabilities.Baseline);
}

[Fact, WorkItem(17681, "https://github.com/dotnet/roslyn/issues/17681")]
@@ -14011,8 +14030,12 @@ public void PrivatePropertyAccessorDelete()

edits.VerifyEdits("Delete [set { _p = value; }]@44");

edits.VerifySemanticDiagnostics(
Diagnostic(RudeEditKind.Delete, "int P", DeletedSymbolDisplay(CSharpFeaturesResources.property_setter, "P.set")));
edits.VerifySemantics(
new[]
{
SemanticEdit(SemanticEditKind.Delete, c => c.GetMember("C.set_P"), deletedSymbolContainerProvider: c => c.GetMember("C")),
},
capabilities: EditAndContinueCapabilities.Baseline);
}

[Fact]
@@ -14110,8 +14133,12 @@ public void PrivateAutoPropertyAccessorDelete_Get()

edits.VerifyEdits("Delete [get;]@18");

edits.VerifySemanticDiagnostics(
Diagnostic(RudeEditKind.Delete, "int P", DeletedSymbolDisplay(CSharpFeaturesResources.property_getter, "P.get")));
edits.VerifySemantics(
new[]
{
SemanticEdit(SemanticEditKind.Delete, c => c.GetMember("C.get_P"), deletedSymbolContainerProvider: c => c.GetMember("C")),
},
capabilities: EditAndContinueCapabilities.Baseline);
}

[Fact]
@@ -14156,8 +14183,13 @@ public void PrivateAutoPropertyAccessorDelete_Set()

edits.VerifyEdits("Delete [set;]@23");

edits.VerifySemanticDiagnostics(
Diagnostic(RudeEditKind.Delete, "int P", DeletedSymbolDisplay(CSharpFeaturesResources.property_setter, "P.set")));
edits.VerifySemantics(
new[]
{
SemanticEdit(SemanticEditKind.Delete, c => c.GetMember("C.set_P"), deletedSymbolContainerProvider: c => c.GetMember("C")),
SemanticEdit(SemanticEditKind.Update, c => c.GetMember("C..ctor"), preserveLocalVariables: true),
},
capabilities: EditAndContinueCapabilities.Baseline);
}

[Fact]
@@ -14170,8 +14202,13 @@ public void PrivateAutoPropertyAccessorDelete_Init()

edits.VerifyEdits("Delete [init;]@23");

edits.VerifySemanticDiagnostics(
Diagnostic(RudeEditKind.Delete, "int P", DeletedSymbolDisplay(CSharpFeaturesResources.property_setter, "P.init")));
edits.VerifySemantics(
new[]
{
SemanticEdit(SemanticEditKind.Delete, c => c.GetMember("C.set_P"), deletedSymbolContainerProvider: c => c.GetMember("C")),
SemanticEdit(SemanticEditKind.Update, c => c.GetMember("C..ctor"), preserveLocalVariables: true),
},
capabilities: EditAndContinueCapabilities.Baseline);
}

[Fact]
@@ -14837,8 +14874,13 @@ public void Indexer_GetterAndSetterBlockBodiesToExpressionBody()
"Delete [get { return 1; }]@28",
"Delete [set { Console.WriteLine(0); }]@46");

edits.VerifySemanticDiagnostics(
Diagnostic(RudeEditKind.Delete, "int this[int a]", DeletedSymbolDisplay(CSharpFeaturesResources.indexer_setter, "this[int a].set")));
edits.VerifySemantics(
new[]
{
SemanticEdit(SemanticEditKind.Update, c => c.GetMember("C.get_Item")),
SemanticEdit(SemanticEditKind.Delete, c => c.GetMember("C.set_Item"), deletedSymbolContainerProvider: c => c.GetMember("C")),
},
capabilities: EditAndContinueCapabilities.Baseline);
}

[Fact, WorkItem(17681, "https://github.com/dotnet/roslyn/issues/17681")]
@@ -15118,10 +15160,12 @@ public T this[int i]
}";
var edits = GetTopEdits(src1, src2);

edits.VerifyEdits("Delete [get { return arr[i]; }]@58");

edits.VerifySemanticDiagnostics(
Diagnostic(RudeEditKind.Delete, "public T this[int i]", DeletedSymbolDisplay(CSharpFeaturesResources.indexer_getter, "this[int i].get")));
edits.VerifySemantics(
new[]
{
SemanticEdit(SemanticEditKind.Delete, c => c.GetMember("C.get_Item"), deletedSymbolContainerProvider: c => c.GetMember("C")),
},
capabilities: EditAndContinueCapabilities.Baseline);
}

[Fact]
@@ -15139,10 +15183,12 @@ class C
}";
var edits = GetTopEdits(src1, src2);

edits.VerifyEdits("Delete [set { }]@61");

edits.VerifySemanticDiagnostics(
Diagnostic(RudeEditKind.Delete, "public int this[int i]", DeletedSymbolDisplay(CSharpFeaturesResources.indexer_setter, "this[int i].set")));
edits.VerifySemantics(
new[]
{
SemanticEdit(SemanticEditKind.Delete, c => c.GetMember("C.set_Item"), deletedSymbolContainerProvider: c => c.GetMember("C")),
},
capabilities: EditAndContinueCapabilities.Baseline);
}

[Fact, WorkItem(1174850, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/1174850")]
Original file line number Diff line number Diff line change
@@ -5523,9 +5523,12 @@ Class C
End Class"
Dim edits = GetTopEdits(src1, src2)

edits.VerifySemanticDiagnostics(
Diagnostic(RudeEditKind.Delete, "Class C", DeletedSymbolDisplay(FeaturesResources.operator_, "+(d As C, g As C)")),
Diagnostic(RudeEditKind.Delete, "Class C", DeletedSymbolDisplay(FeaturesResources.operator_, "CType(d As C)")))
edits.VerifySemantics(
semanticEdits:=
{
SemanticEdit(SemanticEditKind.Delete, Function(c) c.GetMember("C.op_Addition"), deletedSymbolContainerProvider:=Function(c) c.GetMember("C")),
SemanticEdit(SemanticEditKind.Delete, Function(c) c.GetMember("C.op_Explicit"), deletedSymbolContainerProvider:=Function(c) c.GetMember("C"))
})
End Sub

<Fact(Skip:="https://github.com/dotnet/roslyn/issues/51011"), WorkItem(51011, "https://github.com/dotnet/roslyn/issues/51011")>
@@ -7198,8 +7201,14 @@ End Class
"Insert [a]@14",
"Delete [Event a As Action]@10")

edits.VerifySemanticDiagnostics(
Diagnostic(RudeEditKind.Delete, "Class C", DeletedSymbolDisplay(FeaturesResources.event_, "a")))
edits.VerifySemantics(
semanticEdits:=
{
SemanticEdit(SemanticEditKind.Insert, Function(c) c.GetMember("C.a")),
SemanticEdit(SemanticEditKind.Delete, Function(c) c.GetMember("C.add_a"), deletedSymbolContainerProvider:=Function(c) c.GetMember("C")),
SemanticEdit(SemanticEditKind.Delete, Function(c) c.GetMember("C.remove_a"), deletedSymbolContainerProvider:=Function(c) c.GetMember("C"))
},
capabilities:=EditAndContinueCapabilities.AddInstanceFieldToExistingType)
End Sub

<Fact>
@@ -7932,8 +7941,11 @@ End Class"
"Delete [value As Integer]@91",
"Delete [value]@91")

edits.VerifySemanticDiagnostics(
Diagnostic(RudeEditKind.Delete, "Private ReadOnly Property P", DeletedSymbolDisplay(FeaturesResources.property_accessor, "P(value As Integer)")))
edits.VerifySemantics(
semanticEdits:=
{
SemanticEdit(SemanticEditKind.Delete, Function(c) c.GetMember("C.set_P"), deletedSymbolContainerProvider:=Function(c) c.GetMember("C"))
})
End Sub

<Fact>
@@ -9167,8 +9179,12 @@ End Class
edits.VerifyEdits(
"Delete [Private Property a As Integer = 1]@10")

edits.VerifySemanticDiagnostics(
Diagnostic(RudeEditKind.Delete, "Class C", DeletedSymbolDisplay(FeaturesResources.auto_property, "a")))
edits.VerifySemantics(
semanticEdits:=
{
SemanticEdit(SemanticEditKind.Delete, Function(c) c.GetMember("C.get_a"), deletedSymbolContainerProvider:=Function(c) c.GetMember("C")),
SemanticEdit(SemanticEditKind.Delete, Function(c) c.GetMember("C.set_a"), deletedSymbolContainerProvider:=Function(c) c.GetMember("C"))
})
End Sub

<Fact>
@@ -10277,8 +10293,13 @@ Class C
End Class
"
Dim edits = GetTopEdits(src1, src2)
edits.VerifySemanticDiagnostics(
Diagnostic(RudeEditKind.Delete, "Class C", DeletedSymbolDisplay(FeaturesResources.event_, "E")))
edits.VerifySemantics(
semanticEdits:=
{
SemanticEdit(SemanticEditKind.Delete, Function(c) c.GetMember("C.add_E"), deletedSymbolContainerProvider:=Function(c) c.GetMember("C")),
SemanticEdit(SemanticEditKind.Delete, Function(c) c.GetMember("C.remove_E"), deletedSymbolContainerProvider:=Function(c) c.GetMember("C")),
SemanticEdit(SemanticEditKind.Delete, Function(c) c.GetMember("C.raise_E"), deletedSymbolContainerProvider:=Function(c) c.GetMember("C"))
})
End Sub

<Fact>