Skip to content

Commit

Permalink
Enc: Clean up SemanticEdit (#70449)
Browse files Browse the repository at this point in the history
  • Loading branch information
tmat authored Nov 13, 2023
1 parent af2a7cb commit 782b8cf
Show file tree
Hide file tree
Showing 26 changed files with 1,391 additions and 1,371 deletions.
4 changes: 4 additions & 0 deletions docs/Breaking API Changes.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,3 +114,7 @@ PR: https://github.com/dotnet/roslyn/pull/70277
### Changes in `Microsoft.CodeAnalysis.Emit.EmitBaseline.CreateInitialBaseline` method

A new required parameter `Compilation` has been added. Existing overloads without this parameter no longer work and throw `NotSupportedException`.

### Changes in `Microsoft.CodeAnalysis.Emit.SemanticEdit` constructors

The value of `preserveLocalVariables` passed to the constructors is no longer used.
Original file line number Diff line number Diff line change
Expand Up @@ -604,7 +604,7 @@ static void F()
// First update adds some new synthesized members (lambda related)
var diff1 = compilation1.EmitDifference(
generation0,
ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, m0, m1, GetSyntaxMapFromMarkers(source0, source1), preserveLocalVariables: true)));
ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, m0, m1, GetSyntaxMapFromMarkers(source0, source1))));

diff1.VerifySynthesizedMembers(
"C: {<>c}",
Expand All @@ -613,7 +613,7 @@ static void F()
// Second update is to a method that doesn't produce any synthesized members
var diff2 = compilation2.EmitDifference(
diff1.NextGeneration,
ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, f1, f2, GetSyntaxMapFromMarkers(source1, source2), preserveLocalVariables: true)));
ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, f1, f2, GetSyntaxMapFromMarkers(source1, source2))));

diff2.VerifySynthesizedMembers(
"C: {<>c}",
Expand All @@ -625,7 +625,7 @@ static void F()
// hence we need to account for wildcards when comparing the versions.
var diff3 = compilation3.EmitDifference(
diff2.NextGeneration,
ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, m2, m3, GetSyntaxMapFromMarkers(source2, source3), preserveLocalVariables: true)));
ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, m2, m3, GetSyntaxMapFromMarkers(source2, source3))));

diff3.VerifySynthesizedMembers(
"C: {<>c}",
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class C
var diff1 = compilation1.EmitDifference(
generation0,
ImmutableArray.Create(
SemanticEdit.Create(SemanticEditKind.Update, f0, f1, preserveLocalVariables: true)));
SemanticEdit.Create(SemanticEditKind.Update, f0, f1)));

diff1.EmitResult.Diagnostics.Verify();
diff1.VerifyIL("C.F", @"
Expand Down Expand Up @@ -122,7 +122,7 @@ class C<T>
var diff1 = compilation1.EmitDifference(
generation0,
ImmutableArray.Create(
SemanticEdit.Create(SemanticEditKind.Update, f0, f1, preserveLocalVariables: true)));
SemanticEdit.Create(SemanticEditKind.Update, f0, f1)));

diff1.EmitResult.Diagnostics.Verify();
diff1.VerifyIL("C<T>.F", @"
Expand Down Expand Up @@ -186,7 +186,7 @@ class C<T>
var diff1 = compilation1.EmitDifference(
generation0,
ImmutableArray.Create(
SemanticEdit.Create(SemanticEditKind.Update, f0, f1, preserveLocalVariables: true)));
SemanticEdit.Create(SemanticEditKind.Update, f0, f1)));

diff1.EmitResult.Diagnostics.Verify();
diff1.VerifyIL("C<T>.F<G>", @"
Expand Down Expand Up @@ -250,7 +250,7 @@ class C<T>
var diff1 = compilation1.EmitDifference(
generation0,
ImmutableArray.Create(
SemanticEdit.Create(SemanticEditKind.Update, f0, f1, preserveLocalVariables: true)));
SemanticEdit.Create(SemanticEditKind.Update, f0, f1)));

diff1.EmitResult.Diagnostics.Verify();
diff1.VerifyIL("C<T>.F<G>", @"
Expand Down Expand Up @@ -314,7 +314,7 @@ class C<T>
var diff1 = compilation1.EmitDifference(
generation0,
ImmutableArray.Create(
SemanticEdit.Create(SemanticEditKind.Update, f0, f1, preserveLocalVariables: true)));
SemanticEdit.Create(SemanticEditKind.Update, f0, f1)));

diff1.EmitResult.Diagnostics.Verify();
diff1.VerifyIL("C<T>.F<G>", @"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,8 @@ void G()
var diff1 = compilation1.EmitDifference(
generation0,
ImmutableArray.Create(
SemanticEdit.Create(SemanticEditKind.Update, f0, f1, syntaxMap1, preserveLocalVariables: true),
SemanticEdit.Create(SemanticEditKind.Update, g0, g1, syntaxMap1, preserveLocalVariables: true)));
SemanticEdit.Create(SemanticEditKind.Update, f0, f1, syntaxMap1),
SemanticEdit.Create(SemanticEditKind.Update, g0, g1, syntaxMap1)));

diff1.VerifySynthesizedMembers(
"C: {<>c}",
Expand Down Expand Up @@ -268,9 +268,9 @@ void G()
var diff2 = compilation2.EmitDifference(
diff1.NextGeneration,
ImmutableArray.Create(
SemanticEdit.Create(SemanticEditKind.Update, f1, f2, syntaxMap2, preserveLocalVariables: true),
SemanticEdit.Create(SemanticEditKind.Update, g1, g2, syntaxMap2, preserveLocalVariables: true),
SemanticEdit.Create(SemanticEditKind.Update, a1, a2, syntaxMap2, preserveLocalVariables: true),
SemanticEdit.Create(SemanticEditKind.Update, f1, f2, syntaxMap2),
SemanticEdit.Create(SemanticEditKind.Update, g1, g2, syntaxMap2),
SemanticEdit.Create(SemanticEditKind.Update, a1, a2, syntaxMap2),
SemanticEdit.Create(SemanticEditKind.Insert, null, b2)));

diff2.VerifySynthesizedMembers(
Expand Down
Loading

0 comments on commit 782b8cf

Please sign in to comment.