From 782b8cfd1c2d03592e13d840ffcdee1f60e5b142 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Matou=C5=A1ek?= Date: Sun, 12 Nov 2023 21:12:03 -0600 Subject: [PATCH] Enc: Clean up SemanticEdit (#70449) --- docs/Breaking API Changes.md | 4 + .../AssemblyReferencesTests.cs | 6 +- .../EditAndContinueClosureTests.cs | 124 +- .../EditAndContinueDelegateCacheTests.cs | 10 +- .../EditAndContinuePdbTests.cs | 10 +- .../EditAndContinueStateMachineTests.cs | 1085 ++++++++--------- .../EditAndContinue/EditAndContinueTest.cs | 4 +- .../EditAndContinueTestBase.cs | 43 +- .../EditAndContinue/EditAndContinueTests.cs | 253 ++-- .../EditAndContinue/LocalSlotMappingTests.cs | 96 +- .../Emit/EditAndContinue/DefinitionMap.cs | 2 +- .../Core/Portable/Emit/SemanticEdit.cs | 76 +- .../Core/Portable/PublicAPI.Unshipped.txt | 3 + .../AssemblyReferencesTests.vb | 6 +- .../EditAndContinueClosureTests.vb | 60 +- .../EditAndContinuePdbTests.vb | 10 +- .../EditAndContinueStateMachineTests.vb | 570 ++++----- .../EditAndContinue/EditAndContinueTest.vb | 5 +- .../EditAndContinue/EditAndContinueTests.vb | 271 ++-- .../EditAndContinue/LocalSlotMappingTests.vb | 10 +- .../EditAndContinue/TopLevelEditingTests.cs | 4 +- .../AbstractEditAndContinueAnalyzer.cs | 4 + .../Portable/EditAndContinue/EditSession.cs | 5 +- .../EditAndContinueTest.GenerationVerifier.cs | 38 +- .../EditAndContinue/EditAndContinueTest.cs | 8 +- .../EditAndContinueTestUtilities.cs | 55 +- 26 files changed, 1391 insertions(+), 1371 deletions(-) diff --git a/docs/Breaking API Changes.md b/docs/Breaking API Changes.md index 7022353666d55..ddef6a29c9f5b 100644 --- a/docs/Breaking API Changes.md +++ b/docs/Breaking API Changes.md @@ -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. diff --git a/src/Compilers/CSharp/Test/Emit/Emit/EditAndContinue/AssemblyReferencesTests.cs b/src/Compilers/CSharp/Test/Emit/Emit/EditAndContinue/AssemblyReferencesTests.cs index acffb85e9d2c0..7a67122fa4787 100644 --- a/src/Compilers/CSharp/Test/Emit/Emit/EditAndContinue/AssemblyReferencesTests.cs +++ b/src/Compilers/CSharp/Test/Emit/Emit/EditAndContinue/AssemblyReferencesTests.cs @@ -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}", @@ -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}", @@ -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}", diff --git a/src/Compilers/CSharp/Test/Emit/Emit/EditAndContinue/EditAndContinueClosureTests.cs b/src/Compilers/CSharp/Test/Emit/Emit/EditAndContinue/EditAndContinueClosureTests.cs index 4386f771465b9..2753a3ff2f6d9 100644 --- a/src/Compilers/CSharp/Test/Emit/Emit/EditAndContinue/EditAndContinueClosureTests.cs +++ b/src/Compilers/CSharp/Test/Emit/Emit/EditAndContinue/EditAndContinueClosureTests.cs @@ -109,7 +109,7 @@ void F() var diff1 = compilation1.EmitDifference( generation0, - ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1), preserveLocalVariables: true))); + ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1)))); // no new synthesized members generated (with #1 in names): diff1.VerifySynthesizedMembers( @@ -170,7 +170,7 @@ int F(object o) var diff1 = compilation1.EmitDifference( generation0, - ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1), preserveLocalVariables: true))); + ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1)))); // no new synthesized members generated (with #1 in names): diff1.VerifySynthesizedMembers( @@ -242,7 +242,7 @@ int F(object o) var diff1 = compilation1.EmitDifference( generation0, - ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1), preserveLocalVariables: true))); + ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1)))); // no new synthesized members generated (with #1 in names): diff1.VerifySynthesizedMembers( @@ -300,7 +300,7 @@ void F() var diff1 = compilation1.EmitDifference( generation0, - ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1), preserveLocalVariables: true))); + ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1)))); diff1.VerifySynthesizedMembers( "C: {g__x|0_0}"); @@ -353,7 +353,7 @@ void F() var diff1 = compilation1.EmitDifference( generation0, - ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1), preserveLocalVariables: true))); + ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1)))); diff1.VerifySynthesizedMembers( "C: {g__x|0_0}"); @@ -412,7 +412,7 @@ void F() var diff1 = compilation1.EmitDifference( generation0, - ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1), preserveLocalVariables: true))); + ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1)))); // no new synthesized members generated (with #1 in names): diff1.VerifySynthesizedMembers( @@ -466,7 +466,7 @@ void F() var diff1 = compilation1.EmitDifference( generation0, - ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1), preserveLocalVariables: true))); + ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1)))); // no new synthesized members generated (with #1 in names): diff1.VerifySynthesizedMembers( @@ -521,7 +521,7 @@ int F(int a) var diff1 = compilation1.EmitDifference( generation0, - ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1), preserveLocalVariables: true))); + ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1)))); // no new synthesized members generated (with #1 in names): diff1.VerifySynthesizedMembers( @@ -577,7 +577,7 @@ int F(int a) var diff1 = compilation1.EmitDifference( generation0, - ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1), preserveLocalVariables: true))); + ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1)))); diff1.VerifySynthesizedMembers( "C: {g__x|0_0}"); @@ -632,7 +632,7 @@ int F(int a) var diff1 = compilation1.EmitDifference( generation0, - ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1), preserveLocalVariables: true))); + ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1)))); // no new synthesized members generated (with #1 in names): diff1.VerifySynthesizedMembers( @@ -700,7 +700,7 @@ public void F(string? x) var diff1 = compilation1.EmitDifference( generation0, - ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1), preserveLocalVariables: true))); + ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1)))); diff1.VerifySynthesizedMembers( "Microsoft.CodeAnalysis: {EmbeddedAttribute}", @@ -778,7 +778,7 @@ int F(int a) var diff1 = compilation1.EmitDifference( generation0, - ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1), preserveLocalVariables: true))); + ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1)))); diff1.VerifySynthesizedMembers( "C: {g__x|0_0, <>c__DisplayClass0_0}", @@ -852,7 +852,7 @@ class C : D var diff1 = compilation1.EmitDifference( generation0, - ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, ctor0, ctor1, GetSyntaxMapFromMarkers(source0, source1), preserveLocalVariables: true))); + ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, ctor0, ctor1, GetSyntaxMapFromMarkers(source0, source1)))); // no new synthesized members generated (with #1 in names): diff1.VerifySynthesizedMembers( @@ -919,7 +919,7 @@ partial class C var diff1 = compilation1.EmitDifference( generation0, - ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, ctor0, ctor1, GetSyntaxMapFromMarkers(source0, source1), preserveLocalVariables: true))); + ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, ctor0, ctor1, GetSyntaxMapFromMarkers(source0, source1)))); // no new synthesized members generated (with #1 in names): diff1.VerifySynthesizedMembers( @@ -978,7 +978,7 @@ void F() var diff1 = compilation1.EmitDifference( generation0, - ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1), preserveLocalVariables: true))); + ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1)))); // no new synthesized members generated (with #1 in names): diff1.VerifySynthesizedMembers( @@ -1066,7 +1066,7 @@ void F() var diff1 = compilation1.EmitDifference( generation0, - ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1), preserveLocalVariables: true))); + ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1)))); // no new synthesized members generated (with #1 in names): diff1.VerifySynthesizedMembers( @@ -1155,7 +1155,7 @@ void F() var diff1 = compilation1.EmitDifference( generation0, - ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1), preserveLocalVariables: true))); + ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1)))); // no new synthesized members generated (with #1 in names): diff1.VerifySynthesizedMembers( @@ -1239,7 +1239,7 @@ public void F() var diff1 = compilation1.EmitDifference( generation0, - ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1), preserveLocalVariables: true))); + ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1)))); // no new synthesized members generated (with #1 in names): diff1.VerifySynthesizedMembers( @@ -1330,7 +1330,7 @@ public void F() var diff1 = compilation1.EmitDifference( generation0, - ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1), preserveLocalVariables: true))); + ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1)))); // no new synthesized members generated (with #1 in names): diff1.VerifySynthesizedMembers( @@ -1412,7 +1412,7 @@ public void F() var diff1 = compilation1.EmitDifference( generation0, - ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1), preserveLocalVariables: true))); + ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1)))); // no new synthesized members generated (with #1 in names): diff1.VerifySynthesizedMembers( @@ -1490,7 +1490,7 @@ static object F() var diff1 = compilation1.EmitDifference( generation0, - ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1), preserveLocalVariables: true))); + ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1)))); var md1 = diff1.GetMetadata(); var reader1 = md1.Reader; @@ -1514,7 +1514,7 @@ .maxstack 2 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}", @@ -1589,7 +1589,7 @@ static object F() var diff1 = compilation1.EmitDifference( generation0, - ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1), preserveLocalVariables: true))); + ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1)))); var md1 = diff1.GetMetadata(); var reader1 = md1.Reader; @@ -1612,7 +1612,7 @@ .maxstack 2 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: {g__f|0#1}"); @@ -1680,7 +1680,7 @@ static object F() var diff1 = compilation1.EmitDifference( generation0, - ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1), preserveLocalVariables: true))); + ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1)))); var md1 = diff1.GetMetadata(); var reader1 = md1.Reader; @@ -1703,7 +1703,7 @@ .maxstack 2 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: {g__f|0#1}"); @@ -1789,7 +1789,7 @@ static object F() var diff1 = compilation1.EmitDifference( generation0, - ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1), preserveLocalVariables: true))); + ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1)))); var md1 = diff1.GetMetadata(); var reader1 = md1.Reader; @@ -1824,7 +1824,7 @@ .maxstack 2 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)))); // new lambda "b__1_2#2" has been added: diff2.VerifySynthesizedMembers( @@ -1868,7 +1868,7 @@ .maxstack 2 var diff3 = compilation3.EmitDifference( diff2.NextGeneration, - ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, f2, f3, GetSyntaxMapFromMarkers(source2, source3), preserveLocalVariables: true))); + ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, f2, f3, GetSyntaxMapFromMarkers(source2, source3)))); diff3.VerifySynthesizedMembers( "C: {<>c}", @@ -1987,7 +1987,7 @@ static object F() var diff1 = compilation1.EmitDifference( generation0, - ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1), preserveLocalVariables: true))); + ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1)))); var md1 = diff1.GetMetadata(); var reader1 = md1.Reader; @@ -2021,7 +2021,7 @@ .maxstack 2 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: {g__f1|1_0, g__f2|1_1#1, g__f3|1_2#2}"); @@ -2063,7 +2063,7 @@ .maxstack 2 var diff3 = compilation3.EmitDifference( diff2.NextGeneration, - ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, f2, f3, GetSyntaxMapFromMarkers(source2, source3), preserveLocalVariables: true))); + ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, f2, f3, GetSyntaxMapFromMarkers(source2, source3)))); diff3.VerifySynthesizedMembers( "C: {g__f1|1_0, g__f2|1_1#1, g__f3|1_2#2}"); @@ -2197,7 +2197,7 @@ private void F() var diff1 = compilation1.EmitDifference( generation0, - ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1), preserveLocalVariables: true))); + ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1)))); var md1 = diff1.GetMetadata(); var reader1 = md1.Reader; @@ -2221,7 +2221,7 @@ .maxstack 1 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)))); // no new members: diff2.VerifySynthesizedMembers( @@ -2587,7 +2587,7 @@ public int F() generation0, ImmutableArray.Create( SemanticEdit.Create(SemanticEditKind.Insert, null, f1), - SemanticEdit.Create(SemanticEditKind.Update, main0, main1, preserveLocalVariables: true))); + SemanticEdit.Create(SemanticEditKind.Update, main0, main1))); diff1.VerifySynthesizedMembers( "C.<>c: {<>9__1#1_0#1, b__1#1_0#1}", @@ -2598,7 +2598,7 @@ public int F() diff1.NextGeneration, ImmutableArray.Create( SemanticEdit.Create(SemanticEditKind.Insert, null, f_int2), - SemanticEdit.Create(SemanticEditKind.Update, main1, main2, preserveLocalVariables: true))); + SemanticEdit.Create(SemanticEditKind.Update, main1, main2))); diff2.VerifySynthesizedMembers( "C.<>c__DisplayClass1#2_0#2: {<>4__this, a, b__1#2, b__2#2}", @@ -2609,7 +2609,7 @@ public int F() var diff3 = compilation3.EmitDifference( diff2.NextGeneration, ImmutableArray.Create( - SemanticEdit.Create(SemanticEditKind.Update, main2, main3, preserveLocalVariables: true))); + SemanticEdit.Create(SemanticEditKind.Update, main2, main3))); diff3.VerifySynthesizedMembers( "C.<>c__DisplayClass1#1_0#1: {<>4__this, a, b__1#1, b__2#1}", @@ -2657,7 +2657,7 @@ static object F() var diff1 = compilation1.EmitDifference( generation0, - ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1), preserveLocalVariables: true))); + ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1)))); var md1 = diff1.GetMetadata(); var reader1 = md1.Reader; @@ -2730,8 +2730,8 @@ public C(int x) var diff1 = compilation1.EmitDifference( generation0, ImmutableArray.Create( - SemanticEdit.Create(SemanticEditKind.Update, ctor00, ctor01, GetSyntaxMapFromMarkers(source0, source1), preserveLocalVariables: true), - SemanticEdit.Create(SemanticEditKind.Update, ctor10, ctor11, GetSyntaxMapFromMarkers(source0, source1), preserveLocalVariables: true))); + SemanticEdit.Create(SemanticEditKind.Update, ctor00, ctor01, GetSyntaxMapFromMarkers(source0, source1)), + SemanticEdit.Create(SemanticEditKind.Update, ctor10, ctor11, GetSyntaxMapFromMarkers(source0, source1)))); var md1 = diff1.GetMetadata(); var reader1 = md1.Reader; @@ -2836,8 +2836,8 @@ public C(int x) var diff1 = compilation1.EmitDifference( generation0, ImmutableArray.Create( - SemanticEdit.Create(SemanticEditKind.Update, ctor00, ctor01, GetSyntaxMapFromMarkers(source0, source1), preserveLocalVariables: true), - SemanticEdit.Create(SemanticEditKind.Update, ctor10, ctor11, GetSyntaxMapFromMarkers(source0, source1), preserveLocalVariables: true))); + SemanticEdit.Create(SemanticEditKind.Update, ctor00, ctor01, GetSyntaxMapFromMarkers(source0, source1)), + SemanticEdit.Create(SemanticEditKind.Update, ctor10, ctor11, GetSyntaxMapFromMarkers(source0, source1)))); var md1 = diff1.GetMetadata(); var reader1 = md1.Reader; @@ -2956,7 +2956,7 @@ class C generation0, ImmutableArray.Create( SemanticEdit.Create(SemanticEditKind.Insert, null, b1), - SemanticEdit.Create(SemanticEditKind.Update, ctor0, ctor1, GetSyntaxMapFromMarkers(source0, source1), preserveLocalVariables: true))); + SemanticEdit.Create(SemanticEditKind.Update, ctor0, ctor1, GetSyntaxMapFromMarkers(source0, source1)))); diff1.VerifySynthesizedMembers( "C: {<>c}", @@ -3051,7 +3051,7 @@ class C generation0, ImmutableArray.Create( SemanticEdit.Create(SemanticEditKind.Insert, null, b1), - SemanticEdit.Create(SemanticEditKind.Insert, null, ctor1, GetSyntaxMapFromMarkers(source0, source1), preserveLocalVariables: true))); + SemanticEdit.Create(SemanticEditKind.Insert, null, ctor1, GetSyntaxMapFromMarkers(source0, source1)))); var md1 = diff1.GetMetadata(); var reader1 = md1.Reader; @@ -3111,7 +3111,7 @@ void F() var diff1 = compilation1.EmitDifference( generation0, ImmutableArray.Create( - SemanticEdit.Create(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1), preserveLocalVariables: true))); + SemanticEdit.Create(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1)))); var md1 = diff1.GetMetadata(); var reader1 = md1.Reader; @@ -3239,7 +3239,7 @@ void F() var diff1 = compilation1.EmitDifference( generation0, ImmutableArray.Create( - SemanticEdit.Create(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1), preserveLocalVariables: true))); + SemanticEdit.Create(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1)))); var md1 = diff1.GetMetadata(); var reader1 = md1.Reader; @@ -3355,7 +3355,7 @@ void F() var diff1 = compilation1.EmitDifference( generation0, ImmutableArray.Create( - SemanticEdit.Create(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1), preserveLocalVariables: true))); + SemanticEdit.Create(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1)))); var md1 = diff1.GetMetadata(); var reader1 = md1.Reader; @@ -3480,7 +3480,7 @@ void F() var diff1 = compilation1.EmitDifference( generation0, ImmutableArray.Create( - SemanticEdit.Create(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1), preserveLocalVariables: true))); + SemanticEdit.Create(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1)))); var md1 = diff1.GetMetadata(); var reader1 = md1.Reader; @@ -3627,7 +3627,7 @@ .locals init (C.<>c__DisplayClass0_0 V_0, //CS$<>8__locals0 var diff1 = compilation1.EmitDifference(generation0, ImmutableArray.Create( - SemanticEdit.Create(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1), preserveLocalVariables: true))); + SemanticEdit.Create(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1)))); diff1.VerifySynthesizedMembers( "C: {<>c__DisplayClass0_0}", @@ -3659,7 +3659,7 @@ .locals init (C.<>c__DisplayClass0_0 V_0, //CS$<>8__locals0 var diff2 = compilation2.EmitDifference(diff1.NextGeneration, ImmutableArray.Create( - SemanticEdit.Create(SemanticEditKind.Update, f1, f2, GetSyntaxMapFromMarkers(source1, source2), preserveLocalVariables: true))); + SemanticEdit.Create(SemanticEditKind.Update, f1, f2, GetSyntaxMapFromMarkers(source1, source2)))); diff2.VerifySynthesizedMembers( "C: {<>c__DisplayClass0_0}", @@ -3752,7 +3752,7 @@ .locals init (C.<>c__DisplayClass0_0 V_0, //CS$<>8__locals0 var diff1 = compilation1.EmitDifference( generation0, ImmutableArray.Create( - SemanticEdit.Create(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1), preserveLocalVariables: true))); + SemanticEdit.Create(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1)))); diff1.VerifySynthesizedMembers( "C: {<>c__DisplayClass0_0}", @@ -3764,7 +3764,7 @@ .locals init (C.<>c__DisplayClass0_0 V_0, //CS$<>8__locals0 var diff2 = compilation2.EmitDifference( diff1.NextGeneration, ImmutableArray.Create( - SemanticEdit.Create(SemanticEditKind.Update, f1, f2, GetSyntaxMapFromMarkers(source1, source2), preserveLocalVariables: true))); + SemanticEdit.Create(SemanticEditKind.Update, f1, f2, GetSyntaxMapFromMarkers(source1, source2)))); diff2.VerifySynthesizedMembers( "C: {<>c__DisplayClass0_0}", @@ -3852,7 +3852,7 @@ .maxstack 9 var diff1 = compilation1.EmitDifference( generation0, ImmutableArray.Create( - SemanticEdit.Create(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1), preserveLocalVariables: true))); + SemanticEdit.Create(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1)))); diff1.VerifyIL("C.F", @"{ // Code size 113 (0x71) @@ -3904,7 +3904,7 @@ .maxstack 9 var diff2 = compilation2.EmitDifference( diff1.NextGeneration, ImmutableArray.Create( - SemanticEdit.Create(SemanticEditKind.Update, f1, f2, GetSyntaxMapFromMarkers(source1, source2), preserveLocalVariables: true))); + SemanticEdit.Create(SemanticEditKind.Update, f1, f2, GetSyntaxMapFromMarkers(source1, source2)))); diff2.VerifyIL("C.F", @"{ // Code size 113 (0x71) @@ -3997,7 +3997,7 @@ public void F() var diff1 = compilation1.EmitDifference( generation0, - ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1), preserveLocalVariables: true))); + ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1)))); var md1 = diff1.GetMetadata(); var reader1 = md1.Reader; @@ -4082,7 +4082,7 @@ public void F() var diff1 = compilation1.EmitDifference( generation0, - ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1), preserveLocalVariables: true))); + ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1)))); var md1 = diff1.GetMetadata(); var reader1 = md1.Reader; @@ -4164,7 +4164,7 @@ public void F() var diff1 = compilation1.EmitDifference( generation0, - ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1), preserveLocalVariables: true))); + ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1)))); var md1 = diff1.GetMetadata(); var reader1 = md1.Reader; @@ -4237,7 +4237,7 @@ public void F(int x) var diff1 = compilation1.EmitDifference( generation0, - ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1), preserveLocalVariables: true))); + ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1)))); var md1 = diff1.GetMetadata(); var reader1 = md1.Reader; @@ -4319,7 +4319,7 @@ public void F(int x) var diff1 = compilation1.EmitDifference( generation0, - ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1), preserveLocalVariables: true))); + ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1)))); var md1 = diff1.GetMetadata(); var reader1 = md1.Reader; @@ -4416,7 +4416,7 @@ public void F(int x) var diff1 = compilation1.EmitDifference( generation0, - ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1), preserveLocalVariables: true))); + ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1)))); var md1 = diff1.GetMetadata(); var reader1 = md1.Reader; @@ -4503,7 +4503,7 @@ public void TopLevelStatement_Closure() var diff1 = compilation1.EmitDifference( generation0, - ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1), preserveLocalVariables: true))); + ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1)))); // no new synthesized members generated (with #1 in names): diff1.VerifySynthesizedMembers( @@ -4562,7 +4562,7 @@ public static void F(int arg) var diff1 = compilation1.EmitDifference( generation0, - ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1), preserveLocalVariables: true))); + ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1)))); // no new synthesized members generated (with #1 in names): diff1.VerifySynthesizedMembers( diff --git a/src/Compilers/CSharp/Test/Emit/Emit/EditAndContinue/EditAndContinueDelegateCacheTests.cs b/src/Compilers/CSharp/Test/Emit/Emit/EditAndContinue/EditAndContinueDelegateCacheTests.cs index 7fd0d19fd3744..a1eb68abd38d2 100644 --- a/src/Compilers/CSharp/Test/Emit/Emit/EditAndContinue/EditAndContinueDelegateCacheTests.cs +++ b/src/Compilers/CSharp/Test/Emit/Emit/EditAndContinue/EditAndContinueDelegateCacheTests.cs @@ -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", @" @@ -122,7 +122,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", @" @@ -186,7 +186,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", @" @@ -250,7 +250,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", @" @@ -314,7 +314,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", @" diff --git a/src/Compilers/CSharp/Test/Emit/Emit/EditAndContinue/EditAndContinuePdbTests.cs b/src/Compilers/CSharp/Test/Emit/Emit/EditAndContinue/EditAndContinuePdbTests.cs index e6a95b7840c50..4ab420ddd6beb 100644 --- a/src/Compilers/CSharp/Test/Emit/Emit/EditAndContinue/EditAndContinuePdbTests.cs +++ b/src/Compilers/CSharp/Test/Emit/Emit/EditAndContinue/EditAndContinuePdbTests.cs @@ -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}", @@ -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( diff --git a/src/Compilers/CSharp/Test/Emit/Emit/EditAndContinue/EditAndContinueStateMachineTests.cs b/src/Compilers/CSharp/Test/Emit/Emit/EditAndContinue/EditAndContinueStateMachineTests.cs index 9a43d565da3d4..ed6be2357601c 100644 --- a/src/Compilers/CSharp/Test/Emit/Emit/EditAndContinue/EditAndContinueStateMachineTests.cs +++ b/src/Compilers/CSharp/Test/Emit/Emit/EditAndContinue/EditAndContinueStateMachineTests.cs @@ -598,500 +598,483 @@ static Task F() [Fact] public void AsyncMethodOverloads() { - var source0 = @" -using System.Threading.Tasks; - -class C -{ - static async Task F(long a) - { - return await Task.FromResult(1); - } - - static async Task F(int a) - { - return await Task.FromResult(1); - } - - static async Task F(short a) - { - return await Task.FromResult(1); - } -}"; - var source1 = @" -using System.Threading.Tasks; - -class C -{ - static async Task F(short a) - { - return await Task.FromResult(2); - } - - static async Task F(long a) - { - return await Task.FromResult(3); - } - - static async Task F(int a) - { - return await Task.FromResult(4); - } -}"; - var compilation0 = CreateCompilationWithMscorlib45(source0, parseOptions: TestOptions.Regular.WithNoRefSafetyRulesAttribute(), options: TestOptions.DebugDll); - var compilation1 = compilation0.WithSource(source1); - - var v0 = CompileAndVerify(compilation0); - - using var md0 = ModuleMetadata.CreateFromImage(v0.EmittedAssemblyData); - var methodShort0 = compilation0.GetMembers("C.F").Single(m => m.ToTestDisplayString() == "System.Threading.Tasks.Task C.F(System.Int16 a)"); - var methodShort1 = compilation1.GetMembers("C.F").Single(m => m.ToTestDisplayString() == "System.Threading.Tasks.Task C.F(System.Int16 a)"); - - var methodInt0 = compilation0.GetMembers("C.F").Single(m => m.ToTestDisplayString() == "System.Threading.Tasks.Task C.F(System.Int32 a)"); - var methodInt1 = compilation1.GetMembers("C.F").Single(m => m.ToTestDisplayString() == "System.Threading.Tasks.Task C.F(System.Int32 a)"); - - var methodLong0 = compilation0.GetMembers("C.F").Single(m => m.ToTestDisplayString() == "System.Threading.Tasks.Task C.F(System.Int64 a)"); - var methodLong1 = compilation1.GetMembers("C.F").Single(m => m.ToTestDisplayString() == "System.Threading.Tasks.Task C.F(System.Int64 a)"); - - var generation0 = CreateInitialBaseline(compilation0, md0, v0.CreateSymReader().GetEncMethodDebugInfo); - var diff1 = compilation1.EmitDifference( - generation0, - ImmutableArray.Create( - SemanticEdit.Create(SemanticEditKind.Update, methodShort0, methodShort1, preserveLocalVariables: true), - SemanticEdit.Create(SemanticEditKind.Update, methodInt0, methodInt1, preserveLocalVariables: true), - SemanticEdit.Create(SemanticEditKind.Update, methodLong0, methodLong1, preserveLocalVariables: true) - )); - - using var md1 = diff1.GetMetadata(); + using var _ = new EditAndContinueTest() + .AddBaseline( + """ + using System.Threading.Tasks; + + class C + { + static async Task F(short a) + { + return await Task.FromResult(1); + } - // notice no TypeDefs, FieldDefs - CheckEncLogDefinitions(md1.Reader, - Row(7, TableIndex.StandAloneSig, EditAndContinueOperation.Default), - Row(8, TableIndex.StandAloneSig, EditAndContinueOperation.Default), - Row(9, TableIndex.StandAloneSig, EditAndContinueOperation.Default), - Row(10, TableIndex.StandAloneSig, EditAndContinueOperation.Default), - Row(11, TableIndex.StandAloneSig, EditAndContinueOperation.Default), - Row(12, TableIndex.StandAloneSig, EditAndContinueOperation.Default), - Row(1, TableIndex.MethodDef, EditAndContinueOperation.Default), - Row(2, TableIndex.MethodDef, EditAndContinueOperation.Default), - Row(3, TableIndex.MethodDef, EditAndContinueOperation.Default), - Row(6, TableIndex.MethodDef, EditAndContinueOperation.Default), - Row(9, TableIndex.MethodDef, EditAndContinueOperation.Default), - Row(12, TableIndex.MethodDef, EditAndContinueOperation.Default), - Row(1, TableIndex.Param, EditAndContinueOperation.Default), - Row(2, TableIndex.Param, EditAndContinueOperation.Default), - Row(3, TableIndex.Param, EditAndContinueOperation.Default), - Row(1, TableIndex.CustomAttribute, EditAndContinueOperation.Default), - Row(2, TableIndex.CustomAttribute, EditAndContinueOperation.Default), - Row(6, TableIndex.CustomAttribute, EditAndContinueOperation.Default), - Row(7, TableIndex.CustomAttribute, EditAndContinueOperation.Default), - Row(8, TableIndex.CustomAttribute, EditAndContinueOperation.Default), - Row(9, TableIndex.CustomAttribute, EditAndContinueOperation.Default)); + static async Task F(long a) + { + return await Task.FromResult(1); + } + + static async Task F(int a) + { + return await Task.FromResult(1); + } + } + """) + .AddGeneration( + """ + using System.Threading.Tasks; + + class C + { + static async Task F(short a) + { + return await Task.FromResult(2); + } + + static async Task F(long a) + { + return await Task.FromResult(3); + } + + static async Task F(int a) + { + return await Task.FromResult(4); + } + } + """, + edits: + [ + Edit(SemanticEditKind.Update, c => c.GetMembers("C.F").Single(m => m.ToTestDisplayString() == "System.Threading.Tasks.Task C.F(System.Int16 a)"), preserveLocalVariables: true), + Edit(SemanticEditKind.Update, c => c.GetMembers("C.F").Single(m => m.ToTestDisplayString() == "System.Threading.Tasks.Task C.F(System.Int32 a)"), preserveLocalVariables: true), + Edit(SemanticEditKind.Update, c => c.GetMembers("C.F").Single(m => m.ToTestDisplayString() == "System.Threading.Tasks.Task C.F(System.Int64 a)"), preserveLocalVariables: true), + ], + validator: g => + { + // notice no TypeDefs, FieldDefs + g.VerifyEncLogDefinitions( + [ + Row(7, TableIndex.StandAloneSig, EditAndContinueOperation.Default), + Row(8, TableIndex.StandAloneSig, EditAndContinueOperation.Default), + Row(9, TableIndex.StandAloneSig, EditAndContinueOperation.Default), + Row(10, TableIndex.StandAloneSig, EditAndContinueOperation.Default), + Row(11, TableIndex.StandAloneSig, EditAndContinueOperation.Default), + Row(12, TableIndex.StandAloneSig, EditAndContinueOperation.Default), + Row(1, TableIndex.MethodDef, EditAndContinueOperation.Default), + Row(2, TableIndex.MethodDef, EditAndContinueOperation.Default), + Row(3, TableIndex.MethodDef, EditAndContinueOperation.Default), + Row(6, TableIndex.MethodDef, EditAndContinueOperation.Default), + Row(9, TableIndex.MethodDef, EditAndContinueOperation.Default), + Row(12, TableIndex.MethodDef, EditAndContinueOperation.Default), + Row(1, TableIndex.Param, EditAndContinueOperation.Default), + Row(2, TableIndex.Param, EditAndContinueOperation.Default), + Row(3, TableIndex.Param, EditAndContinueOperation.Default), + Row(1, TableIndex.CustomAttribute, EditAndContinueOperation.Default), + Row(2, TableIndex.CustomAttribute, EditAndContinueOperation.Default), + Row(6, TableIndex.CustomAttribute, EditAndContinueOperation.Default), + Row(7, TableIndex.CustomAttribute, EditAndContinueOperation.Default), + Row(8, TableIndex.CustomAttribute, EditAndContinueOperation.Default), + Row(9, TableIndex.CustomAttribute, EditAndContinueOperation.Default) + ]); + }) + .Verify(); } [Fact] public void UpdateIterator_NoVariables() { - var source0 = @" -using System.Collections.Generic; - -class C -{ - static IEnumerable F() - { - yield return 1; - } -}"; - var source1 = @" -using System.Collections.Generic; - -class C -{ - static IEnumerable F() - { - yield return 2; - } -}"; - var compilation0 = CreateCompilationWithMscorlib45(source0, parseOptions: TestOptions.Regular.WithNoRefSafetyRulesAttribute(), options: TestOptions.DebugDll); - var compilation1 = compilation0.WithSource(source1); - - var v0 = CompileAndVerify(compilation0); - - using var md0 = ModuleMetadata.CreateFromImage(v0.EmittedAssemblyData); - var method0 = compilation0.GetMember("C.F"); - var method1 = compilation1.GetMember("C.F"); - - var generation0 = CreateInitialBaseline(compilation0, md0, EmptyLocalsProvider); - var diff1 = compilation1.EmitDifference( - generation0, - ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, method0, method1, preserveLocalVariables: true))); - - // Verify delta metadata contains expected rows. - using var md1 = diff1.GetMetadata(); - var reader1 = md1.Reader; - var readers = new List { md0.MetadataReader, reader1 }; - - // only methods with sequence points should be listed in UpdatedMethods: - CheckNames(readers, diff1.EmitResult.UpdatedMethods, "MoveNext"); - CheckNames(readers, diff1.EmitResult.ChangedTypes, "C", "d__0"); - - // Verify that no new TypeDefs, FieldDefs or MethodDefs were added, - // 3 methods were updated: - // - the kick-off method (might be changed if the method previously wasn't an iterator) - // - Finally method - // - MoveNext method - CheckEncLogDefinitions(md1.Reader, - Row(3, TableIndex.StandAloneSig, EditAndContinueOperation.Default), - Row(1, TableIndex.MethodDef, EditAndContinueOperation.Default), - Row(4, TableIndex.MethodDef, EditAndContinueOperation.Default), - Row(5, TableIndex.MethodDef, EditAndContinueOperation.Default), - Row(1, TableIndex.CustomAttribute, EditAndContinueOperation.Default), - Row(7, TableIndex.CustomAttribute, EditAndContinueOperation.Default)); - - diff1.VerifyIL("C.d__0.System.Collections.IEnumerator.MoveNext", @" -{ - // Code size 57 (0x39) - .maxstack 2 - .locals init (int V_0) - IL_0000: ldarg.0 - IL_0001: ldfld ""int C.d__0.<>1__state"" - IL_0006: stloc.0 - IL_0007: ldloc.0 - IL_0008: brfalse.s IL_0012 - IL_000a: br.s IL_000c - IL_000c: ldloc.0 - IL_000d: ldc.i4.1 - IL_000e: beq.s IL_0014 - IL_0010: br.s IL_0016 - IL_0012: br.s IL_0018 - IL_0014: br.s IL_0030 - IL_0016: ldc.i4.0 - IL_0017: ret - IL_0018: ldarg.0 - IL_0019: ldc.i4.m1 - IL_001a: stfld ""int C.d__0.<>1__state"" - IL_001f: nop - IL_0020: ldarg.0 - IL_0021: ldc.i4.2 - IL_0022: stfld ""int C.d__0.<>2__current"" - IL_0027: ldarg.0 - IL_0028: ldc.i4.1 - IL_0029: stfld ""int C.d__0.<>1__state"" - IL_002e: ldc.i4.1 - IL_002f: ret - IL_0030: ldarg.0 - IL_0031: ldc.i4.m1 - IL_0032: stfld ""int C.d__0.<>1__state"" - IL_0037: ldc.i4.0 - IL_0038: ret -}"); - v0.VerifyIL("C.d__0.System.Collections.IEnumerator.MoveNext", @" -{ - // Code size 57 (0x39) - .maxstack 2 - .locals init (int V_0) - IL_0000: ldarg.0 - IL_0001: ldfld ""int C.d__0.<>1__state"" - IL_0006: stloc.0 - IL_0007: ldloc.0 - IL_0008: brfalse.s IL_0012 - IL_000a: br.s IL_000c - IL_000c: ldloc.0 - IL_000d: ldc.i4.1 - IL_000e: beq.s IL_0014 - IL_0010: br.s IL_0016 - IL_0012: br.s IL_0018 - IL_0014: br.s IL_0030 - IL_0016: ldc.i4.0 - IL_0017: ret - IL_0018: ldarg.0 - IL_0019: ldc.i4.m1 - IL_001a: stfld ""int C.d__0.<>1__state"" - IL_001f: nop - IL_0020: ldarg.0 - IL_0021: ldc.i4.1 - IL_0022: stfld ""int C.d__0.<>2__current"" - IL_0027: ldarg.0 - IL_0028: ldc.i4.1 - IL_0029: stfld ""int C.d__0.<>1__state"" - IL_002e: ldc.i4.1 - IL_002f: ret - IL_0030: ldarg.0 - IL_0031: ldc.i4.m1 - IL_0032: stfld ""int C.d__0.<>1__state"" - IL_0037: ldc.i4.0 - IL_0038: ret -}"); + using var _ = new EditAndContinueTest() + .AddBaseline(""" + using System.Collections.Generic; + + class C + { + static IEnumerable F() + { + yield return 1; + } + } + """, + validator: g => + { + g.VerifyIL("C.d__0.System.Collections.IEnumerator.MoveNext", """ + { + // Code size 57 (0x39) + .maxstack 2 + .locals init (int V_0) + IL_0000: ldarg.0 + IL_0001: ldfld "int C.d__0.<>1__state" + IL_0006: stloc.0 + IL_0007: ldloc.0 + IL_0008: brfalse.s IL_0012 + IL_000a: br.s IL_000c + IL_000c: ldloc.0 + IL_000d: ldc.i4.1 + IL_000e: beq.s IL_0014 + IL_0010: br.s IL_0016 + IL_0012: br.s IL_0018 + IL_0014: br.s IL_0030 + IL_0016: ldc.i4.0 + IL_0017: ret + IL_0018: ldarg.0 + IL_0019: ldc.i4.m1 + IL_001a: stfld "int C.d__0.<>1__state" + IL_001f: nop + IL_0020: ldarg.0 + IL_0021: ldc.i4.1 + IL_0022: stfld "int C.d__0.<>2__current" + IL_0027: ldarg.0 + IL_0028: ldc.i4.1 + IL_0029: stfld "int C.d__0.<>1__state" + IL_002e: ldc.i4.1 + IL_002f: ret + IL_0030: ldarg.0 + IL_0031: ldc.i4.m1 + IL_0032: stfld "int C.d__0.<>1__state" + IL_0037: ldc.i4.0 + IL_0038: ret + } + """); + }) + .AddGeneration(""" + using System.Collections.Generic; + + class C + { + static IEnumerable F() + { + yield return 2; + } + } + """, + edits: new[] { Edit(SemanticEditKind.Update, c => c.GetMember("C.F"), preserveLocalVariables: true) }, + validator: g => + { + // only methods with sequence points should be listed in UpdatedMethods: + g.VerifyUpdatedMethodNames("MoveNext"); + g.VerifyChangedTypeNames("C", "d__0"); + + // Verify that no new TypeDefs, FieldDefs or MethodDefs were added, + // 3 methods were updated: + // - the kick-off method (might be changed if the method previously wasn't an iterator) + // - Finally method + // - MoveNext method + g.VerifyEncLogDefinitions( + [ + Row(3, TableIndex.StandAloneSig, EditAndContinueOperation.Default), + Row(1, TableIndex.MethodDef, EditAndContinueOperation.Default), + Row(4, TableIndex.MethodDef, EditAndContinueOperation.Default), + Row(5, TableIndex.MethodDef, EditAndContinueOperation.Default), + Row(1, TableIndex.CustomAttribute, EditAndContinueOperation.Default), + Row(7, TableIndex.CustomAttribute, EditAndContinueOperation.Default) + ]); + + g.VerifyIL("C.d__0.System.Collections.IEnumerator.MoveNext", """ + { + // Code size 57 (0x39) + .maxstack 2 + .locals init (int V_0) + IL_0000: ldarg.0 + IL_0001: ldfld "int C.d__0.<>1__state" + IL_0006: stloc.0 + IL_0007: ldloc.0 + IL_0008: brfalse.s IL_0012 + IL_000a: br.s IL_000c + IL_000c: ldloc.0 + IL_000d: ldc.i4.1 + IL_000e: beq.s IL_0014 + IL_0010: br.s IL_0016 + IL_0012: br.s IL_0018 + IL_0014: br.s IL_0030 + IL_0016: ldc.i4.0 + IL_0017: ret + IL_0018: ldarg.0 + IL_0019: ldc.i4.m1 + IL_001a: stfld "int C.d__0.<>1__state" + IL_001f: nop + IL_0020: ldarg.0 + IL_0021: ldc.i4.2 + IL_0022: stfld "int C.d__0.<>2__current" + IL_0027: ldarg.0 + IL_0028: ldc.i4.1 + IL_0029: stfld "int C.d__0.<>1__state" + IL_002e: ldc.i4.1 + IL_002f: ret + IL_0030: ldarg.0 + IL_0031: ldc.i4.m1 + IL_0032: stfld "int C.d__0.<>1__state" + IL_0037: ldc.i4.0 + IL_0038: ret + } + """); + }) + .Verify(); } [Fact] public void UpdateAsync_NoVariables() { - var source0 = WithWindowsLineBreaks(@" -using System.Threading.Tasks; - -class C -{ - static async Task F() - { - await Task.FromResult(1); - return 2; - } -}"); - var source1 = WithWindowsLineBreaks(@" -using System.Threading.Tasks; - -class C -{ - static async Task F() - { - await Task.FromResult(10); - return 20; - } -}"); - var compilation0 = CreateCompilationWithMscorlib45(source0, parseOptions: TestOptions.Regular.WithNoRefSafetyRulesAttribute(), options: TestOptions.DebugDll); - var compilation1 = compilation0.WithSource(source1); - - var v0 = CompileAndVerify(compilation0); - - using var md0 = ModuleMetadata.CreateFromImage(v0.EmittedAssemblyData); - var method0 = compilation0.GetMember("C.F"); - var method1 = compilation1.GetMember("C.F"); - - var generation0 = CreateInitialBaseline(compilation0, md0, EmptyLocalsProvider); - var diff1 = compilation1.EmitDifference( - generation0, - ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, method0, method1, preserveLocalVariables: true))); - - using var md1 = diff1.GetMetadata(); - var reader1 = md1.Reader; - var readers = new List { md0.MetadataReader, reader1 }; - - // only methods with sequence points should be listed in UpdatedMethods: - CheckNames(readers, diff1.EmitResult.UpdatedMethods, "MoveNext"); - CheckNames(readers, diff1.EmitResult.ChangedTypes, "C", "d__0"); - - // Verify that no new TypeDefs, FieldDefs or MethodDefs were added, - // 2 methods were updated: - // - the kick-off method (might be changed if the method previously wasn't async) - // - MoveNext method - CheckEncLogDefinitions(md1.Reader, - Row(3, TableIndex.StandAloneSig, EditAndContinueOperation.Default), - Row(4, TableIndex.StandAloneSig, EditAndContinueOperation.Default), - Row(1, TableIndex.MethodDef, EditAndContinueOperation.Default), - Row(4, TableIndex.MethodDef, EditAndContinueOperation.Default), - Row(1, TableIndex.CustomAttribute, EditAndContinueOperation.Default), - Row(2, TableIndex.CustomAttribute, EditAndContinueOperation.Default)); - - diff1.VerifyIL("C.d__0.System.Runtime.CompilerServices.IAsyncStateMachine.MoveNext", @" -{ - // Code size 162 (0xa2) - .maxstack 3 - .locals init (int V_0, - int V_1, - System.Runtime.CompilerServices.TaskAwaiter V_2, - C.d__0 V_3, - System.Exception V_4) - IL_0000: ldarg.0 - IL_0001: ldfld ""int C.d__0.<>1__state"" - IL_0006: stloc.0 - .try - { - IL_0007: ldloc.0 - IL_0008: brfalse.s IL_000c - IL_000a: br.s IL_000e - IL_000c: br.s IL_0049 - IL_000e: nop - IL_000f: ldc.i4.s 10 - IL_0011: call ""System.Threading.Tasks.Task System.Threading.Tasks.Task.FromResult(int)"" - IL_0016: callvirt ""System.Runtime.CompilerServices.TaskAwaiter System.Threading.Tasks.Task.GetAwaiter()"" - IL_001b: stloc.2 - IL_001c: ldloca.s V_2 - IL_001e: call ""bool System.Runtime.CompilerServices.TaskAwaiter.IsCompleted.get"" - IL_0023: brtrue.s IL_0065 - IL_0025: ldarg.0 - IL_0026: ldc.i4.0 - IL_0027: dup - IL_0028: stloc.0 - IL_0029: stfld ""int C.d__0.<>1__state"" - IL_002e: ldarg.0 - IL_002f: ldloc.2 - IL_0030: stfld ""System.Runtime.CompilerServices.TaskAwaiter C.d__0.<>u__1"" - IL_0035: ldarg.0 - IL_0036: stloc.3 - IL_0037: ldarg.0 - IL_0038: ldflda ""System.Runtime.CompilerServices.AsyncTaskMethodBuilder C.d__0.<>t__builder"" - IL_003d: ldloca.s V_2 - IL_003f: ldloca.s V_3 - IL_0041: call ""void System.Runtime.CompilerServices.AsyncTaskMethodBuilder.AwaitUnsafeOnCompleted, C.d__0>(ref System.Runtime.CompilerServices.TaskAwaiter, ref C.d__0)"" - IL_0046: nop - IL_0047: leave.s IL_00a1 - IL_0049: ldarg.0 - IL_004a: ldfld ""System.Runtime.CompilerServices.TaskAwaiter C.d__0.<>u__1"" - IL_004f: stloc.2 - IL_0050: ldarg.0 - IL_0051: ldflda ""System.Runtime.CompilerServices.TaskAwaiter C.d__0.<>u__1"" - IL_0056: initobj ""System.Runtime.CompilerServices.TaskAwaiter"" - IL_005c: ldarg.0 - IL_005d: ldc.i4.m1 - IL_005e: dup - IL_005f: stloc.0 - IL_0060: stfld ""int C.d__0.<>1__state"" - IL_0065: ldloca.s V_2 - IL_0067: call ""int System.Runtime.CompilerServices.TaskAwaiter.GetResult()"" - IL_006c: pop - IL_006d: ldc.i4.s 20 - IL_006f: stloc.1 - IL_0070: leave.s IL_008c - } - catch System.Exception - { - IL_0072: stloc.s V_4 - IL_0074: ldarg.0 - IL_0075: ldc.i4.s -2 - IL_0077: stfld ""int C.d__0.<>1__state"" - IL_007c: ldarg.0 - IL_007d: ldflda ""System.Runtime.CompilerServices.AsyncTaskMethodBuilder C.d__0.<>t__builder"" - IL_0082: ldloc.s V_4 - IL_0084: call ""void System.Runtime.CompilerServices.AsyncTaskMethodBuilder.SetException(System.Exception)"" - IL_0089: nop - IL_008a: leave.s IL_00a1 - } - IL_008c: ldarg.0 - IL_008d: ldc.i4.s -2 - IL_008f: stfld ""int C.d__0.<>1__state"" - IL_0094: ldarg.0 - IL_0095: ldflda ""System.Runtime.CompilerServices.AsyncTaskMethodBuilder C.d__0.<>t__builder"" - IL_009a: ldloc.1 - IL_009b: call ""void System.Runtime.CompilerServices.AsyncTaskMethodBuilder.SetResult(int)"" - IL_00a0: nop - IL_00a1: ret -}"); - v0.VerifyIL("C.d__0.System.Runtime.CompilerServices.IAsyncStateMachine.MoveNext", @" -{ - // Code size 160 (0xa0) - .maxstack 3 - .locals init (int V_0, - int V_1, - System.Runtime.CompilerServices.TaskAwaiter V_2, - C.d__0 V_3, - System.Exception V_4) - ~IL_0000: ldarg.0 - IL_0001: ldfld ""int C.d__0.<>1__state"" - IL_0006: stloc.0 - .try - { - ~IL_0007: ldloc.0 - IL_0008: brfalse.s IL_000c - IL_000a: br.s IL_000e - IL_000c: br.s IL_0048 - -IL_000e: nop - -IL_000f: ldc.i4.1 - IL_0010: call ""System.Threading.Tasks.Task System.Threading.Tasks.Task.FromResult(int)"" - IL_0015: callvirt ""System.Runtime.CompilerServices.TaskAwaiter System.Threading.Tasks.Task.GetAwaiter()"" - IL_001a: stloc.2 - ~IL_001b: ldloca.s V_2 - IL_001d: call ""bool System.Runtime.CompilerServices.TaskAwaiter.IsCompleted.get"" - IL_0022: brtrue.s IL_0064 - IL_0024: ldarg.0 - IL_0025: ldc.i4.0 - IL_0026: dup - IL_0027: stloc.0 - IL_0028: stfld ""int C.d__0.<>1__state"" - C.d__0.<>u__1"" - IL_0034: ldarg.0 - IL_0035: stloc.3 - IL_0036: ldarg.0 - IL_0037: ldflda ""System.Runtime.CompilerServices.AsyncTaskMethodBuilder C.d__0.<>t__builder"" - IL_003c: ldloca.s V_2 - IL_003e: ldloca.s V_3 - IL_0040: call ""void System.Runtime.CompilerServices.AsyncTaskMethodBuilder.AwaitUnsafeOnCompleted, C.d__0>(ref System.Runtime.CompilerServices.TaskAwaiter, ref C.d__0)"" - IL_0045: nop - IL_0046: leave.s IL_009f - >IL_0048: ldarg.0 - IL_0049: ldfld ""System.Runtime.CompilerServices.TaskAwaiter C.d__0.<>u__1"" - IL_004e: stloc.2 - IL_004f: ldarg.0 - IL_0050: ldflda ""System.Runtime.CompilerServices.TaskAwaiter C.d__0.<>u__1"" - IL_0055: initobj ""System.Runtime.CompilerServices.TaskAwaiter"" - IL_005b: ldarg.0 - IL_005c: ldc.i4.m1 - IL_005d: dup - IL_005e: stloc.0 - IL_005f: stfld ""int C.d__0.<>1__state"" - IL_0064: ldloca.s V_2 - IL_0066: call ""int System.Runtime.CompilerServices.TaskAwaiter.GetResult()"" - IL_006b: pop - -IL_006c: ldc.i4.2 - IL_006d: stloc.1 - IL_006e: leave.s IL_008a - } - catch System.Exception - { - ~IL_0070: stloc.s V_4 - IL_0072: ldarg.0 - IL_0073: ldc.i4.s -2 - IL_0075: stfld ""int C.d__0.<>1__state"" - IL_007a: ldarg.0 - IL_007b: ldflda ""System.Runtime.CompilerServices.AsyncTaskMethodBuilder C.d__0.<>t__builder"" - IL_0080: ldloc.s V_4 - IL_0082: call ""void System.Runtime.CompilerServices.AsyncTaskMethodBuilder.SetException(System.Exception)"" - IL_0087: nop - IL_0088: leave.s IL_009f - } - -IL_008a: ldarg.0 - IL_008b: ldc.i4.s -2 - IL_008d: stfld ""int C.d__0.<>1__state"" - ~IL_0092: ldarg.0 - IL_0093: ldflda ""System.Runtime.CompilerServices.AsyncTaskMethodBuilder C.d__0.<>t__builder"" - IL_0098: ldloc.1 - IL_0099: call ""void System.Runtime.CompilerServices.AsyncTaskMethodBuilder.SetResult(int)"" - IL_009e: nop - IL_009f: ret -}", sequencePoints: "C+d__0.MoveNext"); - - v0.VerifyPdb("C+d__0.MoveNext", @" - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -"); + using var _ = new EditAndContinueTest() + .AddBaseline(""" + using System.Threading.Tasks; + + class C + { + static async Task F() + { + await Task.FromResult(1); + return 2; + } + } + """, + g => + { + g.VerifyMethodBody("C.d__0.System.Runtime.CompilerServices.IAsyncStateMachine.MoveNext", """ + { + // Code size 160 (0xa0) + .maxstack 3 + .locals init (int V_0, + int V_1, + System.Runtime.CompilerServices.TaskAwaiter V_2, + C.d__0 V_3, + System.Exception V_4) + // sequence point: + IL_0000: ldarg.0 + IL_0001: ldfld "int C.d__0.<>1__state" + IL_0006: stloc.0 + .try + { + // sequence point: + IL_0007: ldloc.0 + IL_0008: brfalse.s IL_000c + IL_000a: br.s IL_000e + IL_000c: br.s IL_0048 + // sequence point: { + IL_000e: nop + // sequence point: await Task.FromResult(1) ; + IL_000f: ldc.i4.1 + IL_0010: call "System.Threading.Tasks.Task System.Threading.Tasks.Task.FromResult(int)" + IL_0015: callvirt "System.Runtime.CompilerServices.TaskAwaiter System.Threading.Tasks.Task.GetAwaiter()" + IL_001a: stloc.2 + // sequence point: + IL_001b: ldloca.s V_2 + IL_001d: call "bool System.Runtime.CompilerServices.TaskAwaiter.IsCompleted.get" + IL_0022: brtrue.s IL_0064 + IL_0024: ldarg.0 + IL_0025: ldc.i4.0 + IL_0026: dup + IL_0027: stloc.0 + IL_0028: stfld "int C.d__0.<>1__state" + // async: yield + IL_002d: ldarg.0 + IL_002e: ldloc.2 + IL_002f: stfld "System.Runtime.CompilerServices.TaskAwaiter C.d__0.<>u__1" + IL_0034: ldarg.0 + IL_0035: stloc.3 + IL_0036: ldarg.0 + IL_0037: ldflda "System.Runtime.CompilerServices.AsyncTaskMethodBuilder C.d__0.<>t__builder" + IL_003c: ldloca.s V_2 + IL_003e: ldloca.s V_3 + IL_0040: call "void System.Runtime.CompilerServices.AsyncTaskMethodBuilder.AwaitUnsafeOnCompleted, C.d__0>(ref System.Runtime.CompilerServices.TaskAwaiter, ref C.d__0)" + IL_0045: nop + IL_0046: leave.s IL_009f + // async: resume + IL_0048: ldarg.0 + IL_0049: ldfld "System.Runtime.CompilerServices.TaskAwaiter C.d__0.<>u__1" + IL_004e: stloc.2 + IL_004f: ldarg.0 + IL_0050: ldflda "System.Runtime.CompilerServices.TaskAwaiter C.d__0.<>u__1" + IL_0055: initobj "System.Runtime.CompilerServices.TaskAwaiter" + IL_005b: ldarg.0 + IL_005c: ldc.i4.m1 + IL_005d: dup + IL_005e: stloc.0 + IL_005f: stfld "int C.d__0.<>1__state" + IL_0064: ldloca.s V_2 + IL_0066: call "int System.Runtime.CompilerServices.TaskAwaiter.GetResult()" + IL_006b: pop + // sequence point: return 2; + IL_006c: ldc.i4.2 + IL_006d: stloc.1 + IL_006e: leave.s IL_008a + } + catch System.Exception + { + // sequence point: + IL_0070: stloc.s V_4 + IL_0072: ldarg.0 + IL_0073: ldc.i4.s -2 + IL_0075: stfld "int C.d__0.<>1__state" + IL_007a: ldarg.0 + IL_007b: ldflda "System.Runtime.CompilerServices.AsyncTaskMethodBuilder C.d__0.<>t__builder" + IL_0080: ldloc.s V_4 + IL_0082: call "void System.Runtime.CompilerServices.AsyncTaskMethodBuilder.SetException(System.Exception)" + IL_0087: nop + IL_0088: leave.s IL_009f + } + // sequence point: } + IL_008a: ldarg.0 + IL_008b: ldc.i4.s -2 + IL_008d: stfld "int C.d__0.<>1__state" + // sequence point: + IL_0092: ldarg.0 + IL_0093: ldflda "System.Runtime.CompilerServices.AsyncTaskMethodBuilder C.d__0.<>t__builder" + IL_0098: ldloc.1 + IL_0099: call "void System.Runtime.CompilerServices.AsyncTaskMethodBuilder.SetResult(int)" + IL_009e: nop + IL_009f: ret + } + """); + + g.VerifyPdb("C+d__0.MoveNext", """ + + + + + + + + + + + + + + + + + + + + + + + + + + """, PdbValidationOptions.ExcludeSequencePoints | PdbValidationOptions.ExcludeDocuments); + }) + .AddGeneration( + """ + using System.Threading.Tasks; + + class C + { + static async Task F() + { + await Task.FromResult(10); + return 20; + } + } + """, + edits: new[] { Edit(SemanticEditKind.Update, c => c.GetMember("C.F"), preserveLocalVariables: true) }, + validator: g => + { + // only methods with sequence points should be listed in UpdatedMethods: + g.VerifyUpdatedMethodNames("MoveNext"); + g.VerifyChangedTypeNames("C", "d__0"); + + // Verify that no new TypeDefs, FieldDefs or MethodDefs were added, + // 2 methods were updated: + // - the kick-off method (might be changed if the method previously wasn't async) + // - MoveNext method + g.VerifyEncLogDefinitions( + [ + Row(3, TableIndex.StandAloneSig, EditAndContinueOperation.Default), + Row(4, TableIndex.StandAloneSig, EditAndContinueOperation.Default), + Row(1, TableIndex.MethodDef, EditAndContinueOperation.Default), + Row(4, TableIndex.MethodDef, EditAndContinueOperation.Default), + Row(1, TableIndex.CustomAttribute, EditAndContinueOperation.Default), + Row(2, TableIndex.CustomAttribute, EditAndContinueOperation.Default) + ]); + + g.VerifyIL("C.d__0.System.Runtime.CompilerServices.IAsyncStateMachine.MoveNext", """ + { + // Code size 162 (0xa2) + .maxstack 3 + .locals init (int V_0, + int V_1, + System.Runtime.CompilerServices.TaskAwaiter V_2, + C.d__0 V_3, + System.Exception V_4) + IL_0000: ldarg.0 + IL_0001: ldfld "int C.d__0.<>1__state" + IL_0006: stloc.0 + .try + { + IL_0007: ldloc.0 + IL_0008: brfalse.s IL_000c + IL_000a: br.s IL_000e + IL_000c: br.s IL_0049 + IL_000e: nop + IL_000f: ldc.i4.s 10 + IL_0011: call "System.Threading.Tasks.Task System.Threading.Tasks.Task.FromResult(int)" + IL_0016: callvirt "System.Runtime.CompilerServices.TaskAwaiter System.Threading.Tasks.Task.GetAwaiter()" + IL_001b: stloc.2 + IL_001c: ldloca.s V_2 + IL_001e: call "bool System.Runtime.CompilerServices.TaskAwaiter.IsCompleted.get" + IL_0023: brtrue.s IL_0065 + IL_0025: ldarg.0 + IL_0026: ldc.i4.0 + IL_0027: dup + IL_0028: stloc.0 + IL_0029: stfld "int C.d__0.<>1__state" + IL_002e: ldarg.0 + IL_002f: ldloc.2 + IL_0030: stfld "System.Runtime.CompilerServices.TaskAwaiter C.d__0.<>u__1" + IL_0035: ldarg.0 + IL_0036: stloc.3 + IL_0037: ldarg.0 + IL_0038: ldflda "System.Runtime.CompilerServices.AsyncTaskMethodBuilder C.d__0.<>t__builder" + IL_003d: ldloca.s V_2 + IL_003f: ldloca.s V_3 + IL_0041: call "void System.Runtime.CompilerServices.AsyncTaskMethodBuilder.AwaitUnsafeOnCompleted, C.d__0>(ref System.Runtime.CompilerServices.TaskAwaiter, ref C.d__0)" + IL_0046: nop + IL_0047: leave.s IL_00a1 + IL_0049: ldarg.0 + IL_004a: ldfld "System.Runtime.CompilerServices.TaskAwaiter C.d__0.<>u__1" + IL_004f: stloc.2 + IL_0050: ldarg.0 + IL_0051: ldflda "System.Runtime.CompilerServices.TaskAwaiter C.d__0.<>u__1" + IL_0056: initobj "System.Runtime.CompilerServices.TaskAwaiter" + IL_005c: ldarg.0 + IL_005d: ldc.i4.m1 + IL_005e: dup + IL_005f: stloc.0 + IL_0060: stfld "int C.d__0.<>1__state" + IL_0065: ldloca.s V_2 + IL_0067: call "int System.Runtime.CompilerServices.TaskAwaiter.GetResult()" + IL_006c: pop + IL_006d: ldc.i4.s 20 + IL_006f: stloc.1 + IL_0070: leave.s IL_008c + } + catch System.Exception + { + IL_0072: stloc.s V_4 + IL_0074: ldarg.0 + IL_0075: ldc.i4.s -2 + IL_0077: stfld "int C.d__0.<>1__state" + IL_007c: ldarg.0 + IL_007d: ldflda "System.Runtime.CompilerServices.AsyncTaskMethodBuilder C.d__0.<>t__builder" + IL_0082: ldloc.s V_4 + IL_0084: call "void System.Runtime.CompilerServices.AsyncTaskMethodBuilder.SetException(System.Exception)" + IL_0089: nop + IL_008a: leave.s IL_00a1 + } + IL_008c: ldarg.0 + IL_008d: ldc.i4.s -2 + IL_008f: stfld "int C.d__0.<>1__state" + IL_0094: ldarg.0 + IL_0095: ldflda "System.Runtime.CompilerServices.AsyncTaskMethodBuilder C.d__0.<>t__builder" + IL_009a: ldloc.1 + IL_009b: call "void System.Runtime.CompilerServices.AsyncTaskMethodBuilder.SetResult(int)" + IL_00a0: nop + IL_00a1: ret + } + """); + }) + .Verify(); } [Fact] @@ -1147,7 +1130,7 @@ static async Task F() var diff1 = compilation1.EmitDifference( generation0, ImmutableArray.Create( - SemanticEdit.Create(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1), preserveLocalVariables: true))); + SemanticEdit.Create(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1)))); v0.VerifyPdb("C.F", @" @@ -1572,7 +1555,7 @@ static void End() {} var diff1 = compilation1.EmitDifference( generation0, ImmutableArray.Create( - SemanticEdit.Create(SemanticEditKind.Update, ctor0, ctor1, GetSyntaxMapFromMarkers(source0, source1), preserveLocalVariables: true))); + SemanticEdit.Create(SemanticEditKind.Update, ctor0, ctor1, GetSyntaxMapFromMarkers(source0, source1)))); v0.VerifyPdb("C..ctor", @" @@ -2013,12 +1996,12 @@ static async Task F() var diff1 = compilation1.EmitDifference( generation0, ImmutableArray.Create( - SemanticEdit.Create(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1), preserveLocalVariables: true))); + SemanticEdit.Create(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1)))); var diff2 = compilation2.EmitDifference( diff1.NextGeneration, ImmutableArray.Create( - SemanticEdit.Create(SemanticEditKind.Update, f1, f2, GetSyntaxMapFromMarkers(source1, source2), preserveLocalVariables: true))); + SemanticEdit.Create(SemanticEditKind.Update, f1, f2, GetSyntaxMapFromMarkers(source1, source2)))); v0.VerifyPdb("C.F", @" @@ -2601,7 +2584,7 @@ static async Task F() var diff1 = compilation1.EmitDifference( generation0, ImmutableArray.Create( - SemanticEdit.Create(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1), preserveLocalVariables: true))); + SemanticEdit.Create(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1)))); diff1.VerifyIL("C.d__4.System.Runtime.CompilerServices.IAsyncStateMachine.MoveNext", @" { @@ -2773,7 +2756,7 @@ static async Task F() var diff1 = compilation1.EmitDifference( generation0, ImmutableArray.Create( - SemanticEdit.Create(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1), preserveLocalVariables: true))); + SemanticEdit.Create(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1)))); v0.VerifyIL("C.d__7.System.Runtime.CompilerServices.IAsyncStateMachine.MoveNext", @" { @@ -3321,7 +3304,7 @@ static async Task F() var diff1 = compilation1.EmitDifference( generation0, ImmutableArray.Create( - SemanticEdit.Create(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1), preserveLocalVariables: true))); + SemanticEdit.Create(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1)))); // Note that the CDI contains local variable declaration mapping to facilitate local variable slot allocation, // but these are not included in the state machine map since the V0 version of the local declaration statement does not have "await" keyword. @@ -3715,7 +3698,7 @@ static IEnumerable F(int p) var diff1 = compilation1.EmitDifference( generation0, - ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, method0, method1, GetSyntaxMapFromMarkers(source0, source1), preserveLocalVariables: true))); + ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, method0, method1, GetSyntaxMapFromMarkers(source0, source1)))); // Verify delta metadata contains expected rows. using var md1 = diff1.GetMetadata(); @@ -3819,7 +3802,7 @@ static IEnumerable F(int p) var generation0 = CreateInitialBaseline(compilation0, md0, symReader.GetEncMethodDebugInfo); var diff1 = compilation1.EmitDifference( generation0, - ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, method0, method1, GetSyntaxMapFromMarkers(source0, source1), preserveLocalVariables: true))); + ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, method0, method1, GetSyntaxMapFromMarkers(source0, source1)))); // Verify delta metadata contains expected rows. using var md1 = diff1.GetMetadata(); @@ -3928,7 +3911,7 @@ static IEnumerable F(int p) var generation0 = CreateInitialBaseline(compilation0, md0, symReader.GetEncMethodDebugInfo); var diff1 = compilation1.EmitDifference( generation0, - ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, method0, method1, GetSyntaxMapFromMarkers(source0, source1), preserveLocalVariables: true))); + ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, method0, method1, GetSyntaxMapFromMarkers(source0, source1)))); // Verify delta metadata contains expected rows. using var md1 = diff1.GetMetadata(); @@ -4034,7 +4017,7 @@ static IEnumerable F() var generation0 = CreateInitialBaseline(compilation0, md0, symReader.GetEncMethodDebugInfo); var diff1 = compilation1.EmitDifference( generation0, - ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, method0, method1, GetSyntaxMapFromMarkers(source0, source1), preserveLocalVariables: true))); + ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, method0, method1, GetSyntaxMapFromMarkers(source0, source1)))); // Verify delta metadata contains expected rows. using var md1 = diff1.GetMetadata(); @@ -4148,7 +4131,7 @@ static IEnumerable F() var generation0 = CreateInitialBaseline(compilation0, md0, symReader.GetEncMethodDebugInfo); var diff1 = compilation1.EmitDifference( generation0, - ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, method0, method1, GetSyntaxMapFromMarkers(source0, source1), preserveLocalVariables: true))); + ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, method0, method1, GetSyntaxMapFromMarkers(source0, source1)))); // Verify delta metadata contains expected rows. using var md1 = diff1.GetMetadata(); @@ -4301,7 +4284,7 @@ static IEnumerable F() var diff1 = compilation1.EmitDifference( generation0, ImmutableArray.Create( - SemanticEdit.Create(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1), preserveLocalVariables: true))); + SemanticEdit.Create(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1)))); v0.VerifyPdb("C.F", @" @@ -4535,7 +4518,7 @@ static IEnumerable F() var diff1 = compilation1.EmitDifference( generation0, ImmutableArray.Create( - SemanticEdit.Create(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1), preserveLocalVariables: true))); + SemanticEdit.Create(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1)))); diff1.VerifyIL("C.d__5.System.Collections.IEnumerator.MoveNext", @" { @@ -4698,7 +4681,7 @@ static void Finally3(int gen) {} var diff1 = compilation1.EmitDifference( generation0, ImmutableArray.Create( - SemanticEdit.Create(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1), preserveLocalVariables: true))); + SemanticEdit.Create(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1)))); v0.VerifyPdb("C.F", @" @@ -5155,7 +5138,7 @@ static void End() {} var diff1 = compilation1.EmitDifference( generation0, ImmutableArray.Create( - SemanticEdit.Create(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1), preserveLocalVariables: true))); + SemanticEdit.Create(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1)))); v0.VerifyPdb("C.F", @" @@ -5491,7 +5474,7 @@ static IEnumerable F() var diff1 = compilation1.EmitDifference( generation0, ImmutableArray.Create( - SemanticEdit.Create(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1), preserveLocalVariables: true))); + SemanticEdit.Create(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1)))); v0.VerifyPdb("C.F", @" @@ -5833,17 +5816,17 @@ static void End() { } var diff1 = compilation1.EmitDifference( generation0, ImmutableArray.Create( - SemanticEdit.Create(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1), preserveLocalVariables: true))); + SemanticEdit.Create(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1)))); var diff2 = compilation2.EmitDifference( diff1.NextGeneration, ImmutableArray.Create( - SemanticEdit.Create(SemanticEditKind.Update, f1, f2, GetSyntaxMapFromMarkers(source1, source2), preserveLocalVariables: true))); + SemanticEdit.Create(SemanticEditKind.Update, f1, f2, GetSyntaxMapFromMarkers(source1, source2)))); var diff3 = compilation3.EmitDifference( diff2.NextGeneration, ImmutableArray.Create( - SemanticEdit.Create(SemanticEditKind.Update, f2, f3, GetSyntaxMapFromMarkers(source2, source3), preserveLocalVariables: true))); + SemanticEdit.Create(SemanticEditKind.Update, f2, f3, GetSyntaxMapFromMarkers(source2, source3)))); v0.VerifyPdb("C.F", @" @@ -6744,7 +6727,7 @@ .locals init (int V_0, var diff1 = compilation1.EmitDifference( generation0, - ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1), preserveLocalVariables: true))); + ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1)))); diff1.VerifyIL("C.d__0.System.Runtime.CompilerServices.IAsyncStateMachine.MoveNext", @" { @@ -7183,7 +7166,7 @@ .locals init (int V_0, var diff1 = compilation1.EmitDifference( generation0, - ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1), preserveLocalVariables: true))); + ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1)))); diff1.VerifyIL("C.d__0.System.Runtime.CompilerServices.IAsyncStateMachine.MoveNext", @" { @@ -7468,8 +7451,8 @@ static async Task H() // updated 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: {d__0, d__1}", @@ -7480,7 +7463,7 @@ static async Task H() // updated var diff2 = compilation2.EmitDifference( diff1.NextGeneration, ImmutableArray.Create( - SemanticEdit.Create(SemanticEditKind.Update, f1, f2, syntaxMap2, preserveLocalVariables: true))); + SemanticEdit.Create(SemanticEditKind.Update, f1, f2, syntaxMap2))); diff2.VerifySynthesizedMembers( "C: {d__0, d__1}", @@ -7491,8 +7474,8 @@ static async Task H() // updated var diff3 = compilation3.EmitDifference( diff2.NextGeneration, ImmutableArray.Create( - SemanticEdit.Create(SemanticEditKind.Update, g2, g3, syntaxMap3, preserveLocalVariables: true), - SemanticEdit.Create(SemanticEditKind.Update, h2, h3, syntaxMap3, preserveLocalVariables: true))); + SemanticEdit.Create(SemanticEditKind.Update, g2, g3, syntaxMap3), + SemanticEdit.Create(SemanticEditKind.Update, h2, h3, syntaxMap3))); diff3.VerifySynthesizedMembers( "C: {d__1, d__2, d__0}", @@ -7847,7 +7830,7 @@ .locals init (int V_0) var diff1 = compilation1.EmitDifference( generation0, ImmutableArray.Create( - SemanticEdit.Create(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1), preserveLocalVariables: true))); + SemanticEdit.Create(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1)))); var baselineIL = @" { @@ -7922,7 +7905,7 @@ .locals init (int V_0) var diff2 = compilation2.EmitDifference( diff1.NextGeneration, ImmutableArray.Create( - SemanticEdit.Create(SemanticEditKind.Update, f1, f2, GetSyntaxMapFromMarkers(source1, source2), preserveLocalVariables: true))); + SemanticEdit.Create(SemanticEditKind.Update, f1, f2, GetSyntaxMapFromMarkers(source1, source2)))); diff2.VerifySynthesizedMembers( "C: {<>o__0#2, d__0, <>o__0#1}", @@ -7995,7 +7978,7 @@ private static IEnumerable F() var diff1 = compilation1.EmitDifference( generation0, ImmutableArray.Create( - SemanticEdit.Create(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1), preserveLocalVariables: true))); + SemanticEdit.Create(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1)))); diff1.VerifySynthesizedMembers( "C: {<>o__0#1, d__0}", @@ -8005,7 +7988,7 @@ private static IEnumerable F() var diff2 = compilation2.EmitDifference( diff1.NextGeneration, ImmutableArray.Create( - SemanticEdit.Create(SemanticEditKind.Update, f1, f2, GetSyntaxMapFromMarkers(source1, source2), preserveLocalVariables: true))); + SemanticEdit.Create(SemanticEditKind.Update, f1, f2, GetSyntaxMapFromMarkers(source1, source2)))); diff2.VerifySynthesizedMembers( "C: {<>o__0#2, d__0, <>o__0#1}", @@ -8219,8 +8202,8 @@ static async Task H() // updated 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: {d__3, d__4}", @@ -8231,7 +8214,7 @@ static async Task H() // updated var diff2 = compilation2.EmitDifference( diff1.NextGeneration, ImmutableArray.Create( - SemanticEdit.Create(SemanticEditKind.Update, f1, f2, syntaxMap2, preserveLocalVariables: true))); + SemanticEdit.Create(SemanticEditKind.Update, f1, f2, syntaxMap2))); diff2.VerifySynthesizedMembers( "C: {d__3, d__4}", @@ -8242,8 +8225,8 @@ static async Task H() // updated var diff3 = compilation3.EmitDifference( diff2.NextGeneration, ImmutableArray.Create( - SemanticEdit.Create(SemanticEditKind.Update, g2, g3, syntaxMap3, preserveLocalVariables: true), - SemanticEdit.Create(SemanticEditKind.Update, h2, h3, syntaxMap3, preserveLocalVariables: true))); + SemanticEdit.Create(SemanticEditKind.Update, g2, g3, syntaxMap3), + SemanticEdit.Create(SemanticEditKind.Update, h2, h3, syntaxMap3))); diff3.VerifySynthesizedMembers( "C: {d__4, d__5, d__3}", @@ -8761,7 +8744,7 @@ public static IEnumerable H() var diff2 = compilation2.EmitDifference( diff1.NextGeneration, ImmutableArray.Create( - SemanticEdit.Create(SemanticEditKind.Update, f1, f2, GetSyntaxMapByKind(f1, SyntaxKind.Block), preserveLocalVariables: true))); + SemanticEdit.Create(SemanticEditKind.Update, f1, f2, GetSyntaxMapByKind(f1, SyntaxKind.Block)))); diff2.VerifySynthesizedMembers( "C: {d__0#1}", @@ -8933,7 +8916,7 @@ static void F() var diff1 = compilation1.EmitDifference( generation0, - ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1), preserveLocalVariables: true))); + ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1)))); // note that the types of the awaiter fields <>u__1, <>u__2 are the same as in the previous generation: diff1.VerifySynthesizedFields("C.<>c.<b__0_0>d", @@ -8945,7 +8928,7 @@ static void F() 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)))); // note that the types of the awaiter fields <>u__1, <>u__2 are the same as in the previous generation: diff2.VerifySynthesizedFields("C.<>c.<b__0_0>d", @@ -9057,7 +9040,7 @@ static async Task M() var diff1 = compilation1.EmitDifference( generation0, ImmutableArray.Create( - SemanticEdit.Create(SemanticEditKind.Update, m0, m1, GetSyntaxMapFromMarkers(source0, source1), preserveLocalVariables: true))); + SemanticEdit.Create(SemanticEditKind.Update, m0, m1, GetSyntaxMapFromMarkers(source0, source1)))); // Notice that we reused field "<>8__1" (there is no "<>8__2"), which stores the local function closure pointer. diff1.VerifySynthesizedMembers( @@ -9179,7 +9162,7 @@ .locals init (int V_0) var diff1 = compilation1.EmitDifference( generation0, ImmutableArray.Create( - SemanticEdit.Create(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1), preserveLocalVariables: true))); + SemanticEdit.Create(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1)))); using var md1 = diff1.GetMetadata(); var reader1 = md1.Reader; @@ -9198,7 +9181,7 @@ .locals init (int V_0) var diff2 = compilation2.EmitDifference( diff1.NextGeneration, ImmutableArray.Create( - SemanticEdit.Create(SemanticEditKind.Update, f1, f2, GetSyntaxMapFromMarkers(source1, source2), preserveLocalVariables: true))); + SemanticEdit.Create(SemanticEditKind.Update, f1, f2, GetSyntaxMapFromMarkers(source1, source2)))); using var md2 = diff2.GetMetadata(); var reader2 = md2.Reader; @@ -9336,7 +9319,7 @@ .locals init (int V_0) var diff1 = compilation1.EmitDifference( generation0, ImmutableArray.Create( - SemanticEdit.Create(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1), preserveLocalVariables: true))); + SemanticEdit.Create(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1)))); diff1.VerifySynthesizedMembers( "C: {d__0}", @@ -9349,7 +9332,7 @@ .locals init (int V_0) var diff2 = compilation2.EmitDifference( diff1.NextGeneration, ImmutableArray.Create( - SemanticEdit.Create(SemanticEditKind.Update, f1, f2, GetSyntaxMapFromMarkers(source1, source2), preserveLocalVariables: true))); + SemanticEdit.Create(SemanticEditKind.Update, f1, f2, GetSyntaxMapFromMarkers(source1, source2)))); diff2.VerifySynthesizedMembers( "C: {d__0}", @@ -9491,7 +9474,7 @@ .locals init (int V_0) var diff1 = compilation1.EmitDifference( generation0, ImmutableArray.Create( - SemanticEdit.Create(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1), preserveLocalVariables: true))); + SemanticEdit.Create(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1)))); diff1.VerifySynthesizedMembers( "C: {d__0}", @@ -9502,7 +9485,7 @@ .locals init (int V_0) var diff2 = compilation2.EmitDifference( diff1.NextGeneration, ImmutableArray.Create( - SemanticEdit.Create(SemanticEditKind.Update, f1, f2, GetSyntaxMapFromMarkers(source1, source2), preserveLocalVariables: true))); + SemanticEdit.Create(SemanticEditKind.Update, f1, f2, GetSyntaxMapFromMarkers(source1, source2)))); diff2.VerifySynthesizedMembers( "C: {d__0}", @@ -9598,7 +9581,7 @@ .locals init (int V_0) var diff1 = compilation1.EmitDifference( generation0, ImmutableArray.Create( - SemanticEdit.Create(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1), preserveLocalVariables: true))); + SemanticEdit.Create(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1)))); var baselineIL = @" { @@ -9660,7 +9643,7 @@ .locals init (int V_0) var diff2 = compilation2.EmitDifference( diff1.NextGeneration, ImmutableArray.Create( - SemanticEdit.Create(SemanticEditKind.Update, f1, f2, GetSyntaxMapFromMarkers(source1, source2), preserveLocalVariables: true))); + SemanticEdit.Create(SemanticEditKind.Update, f1, f2, GetSyntaxMapFromMarkers(source1, source2)))); diff2.VerifySynthesizedMembers( "C: {d__0}", @@ -9728,7 +9711,7 @@ static async Task F() var diff1 = compilation1.EmitDifference( generation0, ImmutableArray.Create( - SemanticEdit.Create(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1), preserveLocalVariables: true))); + SemanticEdit.Create(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1)))); diff1.VerifySynthesizedMembers( "C: {<>c, d__0}", @@ -9740,7 +9723,7 @@ static async Task F() var diff2 = compilation2.EmitDifference( diff1.NextGeneration, ImmutableArray.Create( - SemanticEdit.Create(SemanticEditKind.Update, f1, f2, GetSyntaxMapFromMarkers(source1, source2), preserveLocalVariables: true))); + SemanticEdit.Create(SemanticEditKind.Update, f1, f2, GetSyntaxMapFromMarkers(source1, source2)))); // Synthesized members collection still includes y field since members are only added to it and never deleted. // The corresponding CLR field is also present. @@ -9754,7 +9737,7 @@ static async Task F() var diff3 = compilation3.EmitDifference( diff2.NextGeneration, ImmutableArray.Create( - SemanticEdit.Create(SemanticEditKind.Update, f2, f3, GetSyntaxMapFromMarkers(source2, source3), preserveLocalVariables: true))); + SemanticEdit.Create(SemanticEditKind.Update, f2, f3, GetSyntaxMapFromMarkers(source2, source3)))); diff3.VerifySynthesizedMembers( "C: {<>c, d__0}", @@ -9766,7 +9749,7 @@ static async Task F() var diff4 = compilation4.EmitDifference( diff3.NextGeneration, ImmutableArray.Create( - SemanticEdit.Create(SemanticEditKind.Update, f3, f4, GetSyntaxMapFromMarkers(source3, source4), preserveLocalVariables: true))); + SemanticEdit.Create(SemanticEditKind.Update, f3, f4, GetSyntaxMapFromMarkers(source3, source4)))); diff4.VerifySynthesizedMembers( "C: {<>c, d__0}", @@ -9778,7 +9761,7 @@ static async Task F() var diff5 = compilation5.EmitDifference( diff4.NextGeneration, ImmutableArray.Create( - SemanticEdit.Create(SemanticEditKind.Update, f4, f5, GetSyntaxMapFromMarkers(source4, source5), preserveLocalVariables: true))); + SemanticEdit.Create(SemanticEditKind.Update, f4, f5, GetSyntaxMapFromMarkers(source4, source5)))); diff5.VerifySynthesizedMembers( "C: {<>c, d__0}", @@ -10230,7 +10213,7 @@ .locals init (int V_0, var diff1 = compilation1.EmitDifference( generation0, ImmutableArray.Create( - SemanticEdit.Create(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1), preserveLocalVariables: true))); + SemanticEdit.Create(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1)))); diff1.VerifySynthesizedMembers( "Program.<>o__1#1: {<>p__0, <>p__1}", @@ -10540,7 +10523,7 @@ .locals init (int V_0, var diff2 = compilation2.EmitDifference( diff1.NextGeneration, ImmutableArray.Create( - SemanticEdit.Create(SemanticEditKind.Update, f1, f2, GetSyntaxMapFromMarkers(source1, source2), preserveLocalVariables: true))); + SemanticEdit.Create(SemanticEditKind.Update, f1, f2, GetSyntaxMapFromMarkers(source1, source2)))); diff2.VerifySynthesizedMembers( "Program.<>o__1#1: {<>p__0, <>p__1}", @@ -10606,7 +10589,7 @@ public IEnumerable F() var diff1 = compilation1.EmitDifference( generation0, ImmutableArray.Create( - SemanticEdit.Create(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1), preserveLocalVariables: true))); + SemanticEdit.Create(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1)))); diff1.EmitResult.Diagnostics.Verify( // (7,29): error CS7043: Cannot update 'C.F()'; attribute 'System.Runtime.CompilerServices.IteratorStateMachineAttribute' is missing. @@ -10673,7 +10656,7 @@ public IEnumerable F() var diff1 = compilation1.EmitDifference( generation0, ImmutableArray.Create( - SemanticEdit.Create(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1), preserveLocalVariables: true))); + SemanticEdit.Create(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1)))); diff1.EmitResult.Diagnostics.Verify( // (12,29): error CS7043: Cannot update 'C.F()'; attribute 'System.Runtime.CompilerServices.IteratorStateMachineAttribute' is missing. @@ -10739,7 +10722,7 @@ public IEnumerable F() generation0, ImmutableArray.Create( SemanticEdit.Create(SemanticEditKind.Insert, null, ism1), - SemanticEdit.Create(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1), preserveLocalVariables: true))); + SemanticEdit.Create(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1)))); // We conclude the original method wasn't a state machine. // The IDE however reports a Rude Edit in that case. @@ -10806,7 +10789,7 @@ public IEnumerable F() var diff1 = compilation1.EmitDifference( generation0, ImmutableArray.Create( - SemanticEdit.Create(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1), preserveLocalVariables: true))); + SemanticEdit.Create(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1)))); diff1.EmitResult.Diagnostics.Verify(); } @@ -10859,7 +10842,7 @@ public async Task F() var diff1 = compilation1.EmitDifference( generation0, ImmutableArray.Create( - SemanticEdit.Create(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1), preserveLocalVariables: true))); + SemanticEdit.Create(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1)))); diff1.EmitResult.Diagnostics.Verify( // (6,28): error CS7043: Cannot update 'C.F()'; attribute 'System.Runtime.CompilerServices.AsyncStateMachineAttribute' is missing. @@ -10921,7 +10904,7 @@ public async Task F() generation0, ImmutableArray.Create( SemanticEdit.Create(SemanticEditKind.Insert, null, asm1), - SemanticEdit.Create(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1), preserveLocalVariables: true))); + SemanticEdit.Create(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1)))); diff1.EmitResult.Diagnostics.Verify(); } @@ -10983,7 +10966,7 @@ public async Task F() var diff1 = compilation1.EmitDifference( generation0, ImmutableArray.Create( - SemanticEdit.Create(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1), preserveLocalVariables: true))); + SemanticEdit.Create(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1)))); diff1.EmitResult.Diagnostics.Verify(); } @@ -11032,7 +11015,7 @@ public async Task F() var diff1 = compilation1.EmitDifference( generation0, ImmutableArray.Create( - SemanticEdit.Create(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1), preserveLocalVariables: true))); + SemanticEdit.Create(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1)))); diff1.EmitResult.Diagnostics.Verify(); } @@ -11083,7 +11066,7 @@ public async Task F() var diff1 = compilation1.EmitDifference( generation0, ImmutableArray.Create( - SemanticEdit.Create(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1), preserveLocalVariables: true))); + SemanticEdit.Create(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1)))); diff1.EmitResult.Diagnostics.Verify( // (6,28): error CS7043: Cannot update 'C.F()'; attribute 'System.Runtime.CompilerServices.AsyncStateMachineAttribute' is missing. @@ -11134,7 +11117,7 @@ public IEnumerable F() var diff1 = compilation1.EmitDifference( generation0, ImmutableArray.Create( - SemanticEdit.Create(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1), preserveLocalVariables: true))); + SemanticEdit.Create(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1)))); diff1.EmitResult.Diagnostics.Verify( // (6,29): error CS7043: Cannot update 'C.F()'; attribute 'System.Runtime.CompilerServices.IteratorStateMachineAttribute' is missing. @@ -11195,7 +11178,7 @@ public IEnumerable F() var diff1 = compilation1.EmitDifference( generation0, ImmutableArray.Create( - SemanticEdit.Create(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1), preserveLocalVariables: true))); + SemanticEdit.Create(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1)))); diff1.EmitResult.Diagnostics.Verify(); } @@ -11250,7 +11233,7 @@ public object F() var diff1 = compilation1.EmitDifference( generation0, ImmutableArray.Create( - SemanticEdit.Create(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1), preserveLocalVariables: true))); + SemanticEdit.Create(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1)))); diff1.EmitResult.Diagnostics.Verify(); @@ -11317,7 +11300,7 @@ public async void F(string? x) var diff1 = compilation1.EmitDifference( generation0, ImmutableArray.Create( - SemanticEdit.Create(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1), preserveLocalVariables: true))); + SemanticEdit.Create(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1)))); diff1.EmitResult.Diagnostics.Verify(); diff --git a/src/Compilers/CSharp/Test/Emit/Emit/EditAndContinue/EditAndContinueTest.cs b/src/Compilers/CSharp/Test/Emit/Emit/EditAndContinue/EditAndContinueTest.cs index 5432755caf56d..c999a17a5372e 100644 --- a/src/Compilers/CSharp/Test/Emit/Emit/EditAndContinue/EditAndContinueTest.cs +++ b/src/Compilers/CSharp/Test/Emit/Emit/EditAndContinue/EditAndContinueTest.cs @@ -3,6 +3,7 @@ // See the LICENSE file in the project root for more information. using System; +using System.Collections.Generic; using Microsoft.CodeAnalysis.CSharp.Symbols; using Microsoft.CodeAnalysis.CSharp.Test.Utilities; using Microsoft.CodeAnalysis.EditAndContinue.UnitTests; @@ -16,6 +17,7 @@ internal sealed class EditAndContinueTest( CSharpCompilationOptions? options = null, CSharpParseOptions? parseOptions = null, TargetFramework targetFramework = TargetFramework.Standard, + IEnumerable? references = null, Verification? verification = null) : EditAndContinueTest(verification) { @@ -23,7 +25,7 @@ internal sealed class EditAndContinueTest( private readonly CSharpParseOptions _parseOptions = parseOptions ?? TestOptions.Regular.WithNoRefSafetyRulesAttribute(); protected override Compilation CreateCompilation(SyntaxTree tree) - => CSharpTestBase.CreateCompilation(tree, options: _compilationOptions, targetFramework: targetFramework); + => CSharpTestBase.CreateCompilation(tree, references, options: _compilationOptions, targetFramework: targetFramework); protected override SourceWithMarkedNodes CreateSourceWithMarkedNodes(string source) => EditAndContinueTestBase.MarkedSource(source, options: _parseOptions); diff --git a/src/Compilers/CSharp/Test/Emit/Emit/EditAndContinue/EditAndContinueTestBase.cs b/src/Compilers/CSharp/Test/Emit/Emit/EditAndContinue/EditAndContinueTestBase.cs index da7135cd7e7e7..a96e05f7fef08 100644 --- a/src/Compilers/CSharp/Test/Emit/Emit/EditAndContinue/EditAndContinueTestBase.cs +++ b/src/Compilers/CSharp/Test/Emit/Emit/EditAndContinue/EditAndContinueTestBase.cs @@ -202,46 +202,19 @@ internal static void CheckAttributes(MetadataReader reader, params CustomAttribu } internal static void CheckNames(MetadataReader reader, IEnumerable handles, params string[] expectedNames) - { - CheckNames(new[] { reader }, handles, expectedNames); - } + => EditAndContinueTestUtilities.CheckNames(reader, handles, expectedNames); internal static void CheckNames(IEnumerable readers, IEnumerable handles, params string[] expectedNames) - { - var actualNames = readers.GetStrings(handles); - AssertEx.Equal(expectedNames, actualNames); - } - - internal static void CheckNames(IList readers, IEnumerable<(StringHandle Namespace, StringHandle Name)> handles, params string[] expectedNames) - { - var actualNames = handles.Select(handlePair => string.Join(".", readers.GetString(handlePair.Namespace), readers.GetString(handlePair.Name))).ToArray(); - AssertEx.Equal(expectedNames, actualNames); - } + => EditAndContinueTestUtilities.CheckNames(readers, handles, expectedNames); - public static void CheckNames(IList readers, ImmutableArray typeHandles, params string[] expectedNames) - => CheckNames(readers, typeHandles, (reader, handle) => reader.GetTypeDefinition((TypeDefinitionHandle)handle).Name, handle => handle, expectedNames); + internal static void CheckNames(IReadOnlyList readers, IEnumerable<(StringHandle Namespace, StringHandle Name)> handles, params string[] expectedNames) + => EditAndContinueTestUtilities.CheckNames(readers, handles, expectedNames); - public static void CheckNames(IList readers, ImmutableArray methodHandles, params string[] expectedNames) - => CheckNames(readers, methodHandles, (reader, handle) => reader.GetMethodDefinition((MethodDefinitionHandle)handle).Name, handle => handle, expectedNames); + public static void CheckNames(IReadOnlyList readers, ImmutableArray typeHandles, params string[] expectedNames) + => EditAndContinueTestUtilities.CheckNames(readers, typeHandles, expectedNames); - private static void CheckNames( - IList readers, - ImmutableArray entityHandles, - Func getName, - Func toHandle, - string[] expectedNames) - { - var aggregator = GetAggregator(readers); - - AssertEx.Equal(expectedNames, entityHandles.Select(handle => - { - var genEntityHandle = aggregator.GetGenerationHandle(toHandle(handle), out int typeGeneration); - var nameHandle = getName(readers[typeGeneration], genEntityHandle); - - var genNameHandle = (StringHandle)aggregator.GetGenerationHandle(nameHandle, out int nameGeneration); - return readers[nameGeneration].GetString(genNameHandle); - })); - } + public static void CheckNames(IReadOnlyList readers, ImmutableArray methodHandles, params string[] expectedNames) + => EditAndContinueTestUtilities.CheckNames(readers, methodHandles, expectedNames); public static void CheckBlobValue(IList readers, BlobHandle valueHandle, byte[] expectedValue) { diff --git a/src/Compilers/CSharp/Test/Emit/Emit/EditAndContinue/EditAndContinueTests.cs b/src/Compilers/CSharp/Test/Emit/Emit/EditAndContinue/EditAndContinueTests.cs index fee4b80f7010c..f7810b6d431c7 100644 --- a/src/Compilers/CSharp/Test/Emit/Emit/EditAndContinue/EditAndContinueTests.cs +++ b/src/Compilers/CSharp/Test/Emit/Emit/EditAndContinue/EditAndContinueTests.cs @@ -298,7 +298,7 @@ public void Delta_AssemblyDefTable() var generation0 = CreateInitialBaseline(compilation0, md0, v0.CreateSymReader().GetEncMethodDebugInfo); var diff1 = compilation1.EmitDifference( generation0, - ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, f0, f1, preserveLocalVariables: true))); + ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, f0, f1))); // AssemblyDef record is not emitted to delta since changes in assembly identity are not allowed: Assert.True(md0.MetadataReader.IsAssembly); @@ -354,7 +354,7 @@ static void G() var diffError = compilation1.EmitDifference( generation0, ImmutableArray.Create( - SemanticEdit.Create(SemanticEditKind.Update, e0, e1, GetSyntaxMapFromMarkers(source0, source1), preserveLocalVariables: true))); + SemanticEdit.Create(SemanticEditKind.Update, e0, e1, GetSyntaxMapFromMarkers(source0, source1)))); diffError.EmitResult.Diagnostics.Verify( // (6,17): error CS0103: The name 'Unknown' does not exist in the current context @@ -364,7 +364,7 @@ static void G() var diffGood = compilation1.EmitDifference( generation0, ImmutableArray.Create( - SemanticEdit.Create(SemanticEditKind.Update, g0, g1, GetSyntaxMapFromMarkers(source0, source1), preserveLocalVariables: true))); + SemanticEdit.Create(SemanticEditKind.Update, g0, g1, GetSyntaxMapFromMarkers(source0, source1)))); diffGood.EmitResult.Diagnostics.Verify(); @@ -420,7 +420,7 @@ class Bad : Bad var diff = compilation1.EmitDifference( generation0, ImmutableArray.Create( - SemanticEdit.Create(SemanticEditKind.Update, g0, g1, GetSyntaxMapFromMarkers(source0, source1), preserveLocalVariables: true))); + SemanticEdit.Create(SemanticEditKind.Update, g0, g1, GetSyntaxMapFromMarkers(source0, source1)))); // All declaration errors are reported regardless of what member do we emit. @@ -1802,7 +1802,7 @@ void F() var diff1 = compilation1.EmitDifference( generation0, - ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, method0, method1, GetSyntaxMapFromMarkers(source0, source1), preserveLocalVariables: true))); + ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, method0, method1, GetSyntaxMapFromMarkers(source0, source1)))); // Verify delta metadata contains expected rows. using var md1 = diff1.GetMetadata(); @@ -1891,7 +1891,7 @@ void F() var diff1 = compilation1.EmitDifference( generation0, - ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, method0, method1, GetSyntaxMapFromMarkers(source0, source1), preserveLocalVariables: true))); + ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, method0, method1, GetSyntaxMapFromMarkers(source0, source1)))); // Verify delta metadata contains expected rows. using var md1 = diff1.GetMetadata(); @@ -1909,7 +1909,7 @@ void F() var diff2 = compilation2.EmitDifference( diff1.NextGeneration, - ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, method1, method2, GetSyntaxMapFromMarkers(source1, source2), preserveLocalVariables: true))); + ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, method1, method2, GetSyntaxMapFromMarkers(source1, source2)))); using var md2 = diff2.GetMetadata(); var reader2 = md2.Reader; @@ -1976,7 +1976,7 @@ static unsafe void F() var diff1 = compilation1.EmitDifference( generation0, - ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, method0, method1, GetSyntaxMapFromMarkers(source0, source1), preserveLocalVariables: true))); + ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, method0, method1, GetSyntaxMapFromMarkers(source0, source1)))); // Verify delta metadata contains expected rows. using var md1 = diff1.GetMetadata(); @@ -1994,7 +1994,7 @@ static unsafe void F() var diff2 = compilation2.EmitDifference( diff1.NextGeneration, - ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, method1, method2, GetSyntaxMapFromMarkers(source1, source2), preserveLocalVariables: true))); + ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, method1, method2, GetSyntaxMapFromMarkers(source1, source2)))); using var md2 = diff2.GetMetadata(); var reader2 = md2.Reader; @@ -2050,7 +2050,7 @@ static unsafe void F() var diff1 = compilation1.EmitDifference( generation0, - ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, method0, method1, GetSyntaxMapFromMarkers(source0, source1), preserveLocalVariables: true))); + ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, method0, method1, GetSyntaxMapFromMarkers(source0, source1)))); // Verify delta metadata contains expected rows. using var md1 = diff1.GetMetadata(); @@ -2116,7 +2116,7 @@ static unsafe void F() where U : unmanaged var diff1 = compilation1.EmitDifference( generation0, - ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, method0, method1, GetSyntaxMapFromMarkers(source0, source1), preserveLocalVariables: true))); + ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, method0, method1, GetSyntaxMapFromMarkers(source0, source1)))); // Verify delta metadata contains expected rows. using var md1 = diff1.GetMetadata(); @@ -2140,7 +2140,7 @@ static unsafe void F() where U : unmanaged var diff2 = compilation2.EmitDifference( diff1.NextGeneration, - ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, method1, method2, GetSyntaxMapFromMarkers(source1, source2), preserveLocalVariables: true))); + ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, method1, method2, GetSyntaxMapFromMarkers(source1, source2)))); using var md2 = diff2.GetMetadata(); var reader2 = md2.Reader; @@ -2200,7 +2200,7 @@ void F() var diff1 = compilation1.EmitDifference( generation0, - ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, method0, method1, GetSyntaxMapFromMarkers(source0, source1), preserveLocalVariables: true))); + ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, method0, method1, GetSyntaxMapFromMarkers(source0, source1)))); // Verify delta metadata contains expected rows. using var md1 = diff1.GetMetadata(); @@ -5484,7 +5484,7 @@ static int F() var diff1 = compilation1.EmitDifference( generation0, ImmutableArray.Create( - SemanticEdit.Create(SemanticEditKind.Update, f0, f1, preserveLocalVariables: true))); + SemanticEdit.Create(SemanticEditKind.Update, f0, f1))); diff1.VerifyIL("C.F", @" { @@ -7120,7 +7120,7 @@ void M() var diff1 = compilation1.EmitDifference( generation0, - ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, method0, method1, GetEquivalentNodesMap(method1, method0), preserveLocalVariables: true))); + ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, method0, method1, GetEquivalentNodesMap(method1, method0)))); // Verify delta metadata contains expected rows. using var md1 = diff1.GetMetadata(); @@ -8057,7 +8057,7 @@ .locals init (S1 V_0, //x var method1 = compilation1.GetMember("C.Main"); var diff1 = compilation1.EmitDifference( generation0, - ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, method0, method1, GetEquivalentNodesMap(method1, method0), preserveLocalVariables: true))); + ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, method0, method1, GetEquivalentNodesMap(method1, method0)))); diff1.VerifyIL("C.Main", @"{ // Code size 22 (0x16) @@ -8234,8 +8234,7 @@ public void ReferencesInIL() SemanticEditKind.Update, method0, method1, - GetEquivalentNodesMap(method1, method0), - preserveLocalVariables: true))); + GetEquivalentNodesMap(method1, method0)))); // "Write" should be included in string table, but "WriteLine" should not. Assert.True(diff1.MetadataDelta.IsIncluded("Write")); @@ -8364,7 +8363,7 @@ static void N() var method1 = compilation1.GetMember("B.M"); var diff1 = compilation1.EmitDifference( generation0, - ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, method0, method1, GetEquivalentNodesMap(method1, method0), preserveLocalVariables: true))); + ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, method0, method1, GetEquivalentNodesMap(method1, method0)))); diff1.VerifyIL( @"{ @@ -8422,7 +8421,7 @@ .maxstack 1 var method2 = compilation2.GetMember("B.M"); var diff2 = compilation2.EmitDifference( diff1.NextGeneration, - ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, method1, method2, GetEquivalentNodesMap(method2, method1), preserveLocalVariables: true))); + ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, method1, method2, GetEquivalentNodesMap(method2, method1)))); diff2.VerifyIL( @"{ @@ -8480,7 +8479,7 @@ .maxstack 1 var method3 = compilation3.GetMember("B.N"); var diff3 = compilation3.EmitDifference( diff2.NextGeneration, - ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, method2, method3, GetEquivalentNodesMap(method3, method2), preserveLocalVariables: true))); + ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, method2, method3, GetEquivalentNodesMap(method3, method2)))); diff3.VerifyIL( @"{ @@ -8570,11 +8569,11 @@ static void M() var diff1 = compilation1.EmitDifference( generation0, - ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Insert, null, m1, null, preserveLocalVariables: true))); + ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Insert, null, m1, null))); var diff2 = compilation2.EmitDifference( diff1.NextGeneration, - ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, m1, m2, GetEquivalentNodesMap(m2, m1), preserveLocalVariables: true))); + ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, m1, m2, GetEquivalentNodesMap(m2, m1)))); diff2.VerifyIL("C.M", @"{ @@ -8658,7 +8657,7 @@ static void Main() var diff1 = compilation1.EmitDifference( generation0, - ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, method0, method1, GetEquivalentNodesMap(method1, method0), preserveLocalVariables: true))); + ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, method0, method1, GetEquivalentNodesMap(method1, method0)))); diff1.VerifyIL("C.Main", @" { // Code size 17 (0x11) @@ -8708,7 +8707,7 @@ static void M() var method1 = compilation1.GetMember("C.M"); var diff1a = compilation1.EmitDifference( generation0, - ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, method0, method1, preserveLocalVariables: false))); + ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, method0, method1))); diff1a.VerifyIL("C.M", @" { @@ -8757,7 +8756,7 @@ .locals init (System.IDisposable V_0, var diff1b = compilation1.EmitDifference( generation0, - ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, method0, method1, preserveLocalVariables: true))); + ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, method0, method1))); diff1b.VerifyIL("C.M", @"{ @@ -8906,7 +8905,7 @@ static void M2() generation0, ImmutableArray.Create( SemanticEdit.Create(SemanticEditKind.Insert, null, compilation1.GetMember("A")), - SemanticEdit.Create(SemanticEditKind.Update, method0, method1, GetEquivalentNodesMap(method1, method0), preserveLocalVariables: true))); + SemanticEdit.Create(SemanticEditKind.Update, method0, method1, GetEquivalentNodesMap(method1, method0)))); diff1.VerifyIL("C.M1", @"{ @@ -8934,7 +8933,7 @@ .locals init ([unchanged] V_0, var diff2 = compilation2.EmitDifference( diff1.NextGeneration, ImmutableArray.Create( - SemanticEdit.Create(SemanticEditKind.Update, method1, method2, GetEquivalentNodesMap(method2, method1), preserveLocalVariables: true))); + SemanticEdit.Create(SemanticEditKind.Update, method1, method2, GetEquivalentNodesMap(method2, method1)))); diff2.VerifyIL("C.M2", @"{ @@ -8962,7 +8961,7 @@ .locals init ([unchanged] V_0, var diff3 = compilation3.EmitDifference( diff2.NextGeneration, ImmutableArray.Create( - SemanticEdit.Create(SemanticEditKind.Update, method2, method3, GetEquivalentNodesMap(method3, method2), preserveLocalVariables: true))); + SemanticEdit.Create(SemanticEditKind.Update, method2, method3, GetEquivalentNodesMap(method3, method2)))); diff3.VerifyIL("C.M2", @"{ @@ -9046,7 +9045,7 @@ .locals init (<>f__AnonymousType0 V_0) //x var diff1 = compilation1.EmitDifference( generation0, - ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1), preserveLocalVariables: true))); + ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1)))); diff1.VerifySynthesizedMembers( "<>f__AnonymousType0<j__TPar>: {Equals, GetHashCode, ToString}"); @@ -9069,7 +9068,7 @@ .locals init (<>f__AnonymousType0 V_0) //x 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( "<>f__AnonymousType0<j__TPar>: {Equals, GetHashCode, ToString}"); @@ -9135,7 +9134,7 @@ static void F() var diff1 = compilation1.EmitDifference( generation0, - ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1), preserveLocalVariables: true))); + ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1)))); var md1 = diff1.GetMetadata(); @@ -9156,7 +9155,7 @@ .locals init (<>f__AnonymousType0 V_0) //x "); 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( "<>f__AnonymousType0<j__TPar>: {Equals, GetHashCode, ToString}"); @@ -9242,7 +9241,7 @@ static void M() var diff1 = compilation1.EmitDifference( generation0, - ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, m0, m1, GetEquivalentNodesMap(m1, m0), preserveLocalVariables: true))); + ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, m0, m1, GetEquivalentNodesMap(m1, m0)))); using var md1 = diff1.GetMetadata(); var reader1 = md1.Reader; @@ -9346,7 +9345,7 @@ static object F() var diff1 = compilation1.EmitDifference( generation0, - ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, f0, f1, GetEquivalentNodesMap(f1, f0), preserveLocalVariables: true))); + ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, f0, f1, GetEquivalentNodesMap(f1, f0)))); using var md1 = diff1.GetMetadata(); diff1.VerifyIL("C.F", @@ -9462,7 +9461,7 @@ static object G() var diff1 = compilation1.EmitDifference( generation0, - ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, method0, method1, GetSyntaxMapFromMarkers(source0, source1), preserveLocalVariables: true))); + ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, method0, method1, GetSyntaxMapFromMarkers(source0, source1)))); var md1 = diff1.GetMetadata(); var reader1 = md1.Reader; @@ -9490,7 +9489,7 @@ .locals init (int V_0, //x var diff2 = compilation2.EmitDifference( diff1.NextGeneration, - ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, method1, method2, GetSyntaxMapFromMarkers(source1, source2), preserveLocalVariables: true))); + ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, method1, method2, GetSyntaxMapFromMarkers(source1, source2)))); var md2 = diff2.GetMetadata(); var reader2 = md2.Reader; @@ -9522,7 +9521,7 @@ .locals init ([int] V_0, var diff3 = compilation3.EmitDifference( diff2.NextGeneration, - ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, method2, method3, GetSyntaxMapFromMarkers(source2, source3), preserveLocalVariables: true))); + ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, method2, method3, GetSyntaxMapFromMarkers(source2, source3)))); var md3 = diff3.GetMetadata(); @@ -9649,7 +9648,7 @@ static object G() var diff1 = compilation1.EmitDifference( generation0, - ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, f0, f1, GetEquivalentNodesMap(f1, f0), preserveLocalVariables: true))); + ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, f0, f1, GetEquivalentNodesMap(f1, f0)))); using var md1 = diff1.GetMetadata(); var reader1 = md1.Reader; @@ -9659,7 +9658,7 @@ static object G() var diff2 = compilation2.EmitDifference( diff1.NextGeneration, - ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, g1, g2, GetEquivalentNodesMap(g2, g1), preserveLocalVariables: true))); + ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, g1, g2, GetEquivalentNodesMap(g2, g1)))); using var md2 = diff2.GetMetadata(); var reader2 = md2.Reader; @@ -9669,7 +9668,7 @@ static object G() var diff3 = compilation3.EmitDifference( diff2.NextGeneration, - ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, g2, g3, GetEquivalentNodesMap(g3, g2), preserveLocalVariables: true))); + ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, g2, g3, GetEquivalentNodesMap(g3, g2)))); using var md3 = diff3.GetMetadata(); var reader3 = md3.Reader; @@ -9755,7 +9754,7 @@ static object F() var method1 = compilation1.GetMember("C.F"); var diff1 = compilation1.EmitDifference( generation0, - ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, method0, method1, GetEquivalentNodesMap(method1, method0), preserveLocalVariables: true))); + ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, method0, method1, GetEquivalentNodesMap(method1, method0)))); using var md1 = diff1.GetMetadata(); var reader1 = md1.Reader; CheckNames(new[] { reader0, reader1 }, reader1.GetTypeDefNames(), "<>f__AnonymousType0`1"); // one additional type @@ -9834,7 +9833,7 @@ static void M() 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)))); var reader1 = diff1.GetMetadata().Reader; CheckNames(new[] { reader0, reader1 }, reader1.GetTypeDefNames(), "<>f__AnonymousType2`2", "<>f__AnonymousType3`1"); @@ -9861,7 +9860,7 @@ .locals init ([unchanged] V_0, var diff2 = compilation2.EmitDifference( diff1.NextGeneration, - ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, m1, m2, GetSyntaxMapFromMarkers(source1, source2), preserveLocalVariables: true))); + ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, m1, m2, GetSyntaxMapFromMarkers(source1, source2)))); var reader2 = diff2.GetMetadata().Reader; CheckNames(new[] { reader0, reader1, reader2 }, reader2.GetTypeDefNames(), "<>f__AnonymousType4`1"); @@ -9985,7 +9984,7 @@ .locals init (System.Collections.Generic.IEnumerable<c}", @@ -9999,7 +9998,7 @@ .locals init (System.Collections.Generic.IEnumerable<c}", @@ -10108,7 +10107,7 @@ .locals init (System.Collections.Generic.IEnumerable<c}", @@ -10122,7 +10121,7 @@ .locals init (System.Collections.Generic.IEnumerable<c}", @@ -10225,7 +10224,7 @@ .locals init (System.Collections.Generic.IEnumerable<o__0#1: {<>p__0}", @@ -10306,7 +10305,7 @@ .locals init (<>f__AnonymousType0 V_0) //x var diff1 = compilation1.EmitDifference( generation0, ImmutableArray.Create( - SemanticEdit.Create(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1), preserveLocalVariables: true))); + SemanticEdit.Create(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1)))); diff1.VerifySynthesizedMembers( "<>f__AnonymousType0<j__TPar, j__TPar>: {Equals, GetHashCode, ToString}"); @@ -10336,7 +10335,7 @@ .locals init (<>f__AnonymousType0 V_0) //x var diff2 = compilation2.EmitDifference( diff1.NextGeneration, ImmutableArray.Create( - SemanticEdit.Create(SemanticEditKind.Update, f1, f2, GetSyntaxMapFromMarkers(source1, source2), preserveLocalVariables: true))); + SemanticEdit.Create(SemanticEditKind.Update, f1, f2, GetSyntaxMapFromMarkers(source1, source2)))); diff2.VerifySynthesizedMembers( "<>f__AnonymousType0<j__TPar, j__TPar>: {Equals, GetHashCode, ToString}"); @@ -10413,7 +10412,7 @@ static void M2(object o) var method1 = compilation1.GetMember("C.M1"); var diff1 = compilation1.EmitDifference( generation0, - ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, method0, method1, GetEquivalentNodesMap(method1, method0), preserveLocalVariables: true))); + ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, method0, method1, GetEquivalentNodesMap(method1, method0)))); diff1.VerifyIL("C.M1", @"{ @@ -10486,7 +10485,7 @@ static object F(System.IDisposable d) var method1 = compilation1.GetMember("C.F"); var diff1 = compilation1.EmitDifference( generation0, - ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, method0, method1, GetEquivalentNodesMap(method1, method0), preserveLocalVariables: true))); + ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, method0, method1, GetEquivalentNodesMap(method1, method0)))); diff1.VerifyIL("C.F", @" { @@ -10561,7 +10560,7 @@ static int M() var method1 = compilation1.GetMember("C.M"); var diff1 = compilation1.EmitDifference( generation0, - ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, method0, method1, GetEquivalentNodesMap(method1, method0), preserveLocalVariables: true))); + ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, method0, method1, GetEquivalentNodesMap(method1, method0)))); diff1.VerifyIL("C.M", @" { @@ -10654,7 +10653,7 @@ .locals init (System.IDisposable V_0) //o var method1 = compilation1.GetMember("C.M"); var diff1 = compilation1.EmitDifference( generation0, - ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, method0, method1, GetEquivalentNodesMap(method1, method0), preserveLocalVariables: true))); + ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, method0, method1, GetEquivalentNodesMap(method1, method0)))); diff1.VerifyIL("C.M", @" { @@ -10747,7 +10746,7 @@ static void M() var method1 = compilation1.GetMember("C.M"); var diff1 = compilation1.EmitDifference( generation0, - ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, method0, method1, GetEquivalentNodesMap(method1, method0), preserveLocalVariables: true))); + ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, method0, method1, GetEquivalentNodesMap(method1, method0)))); diff1.VerifyIL("C.M", @" { @@ -10811,7 +10810,7 @@ static void M() var method1 = compilation1.GetMember("C.M"); var diff1 = compilation1.EmitDifference( generation0, - ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, method0, method1, GetEquivalentNodesMap(method1, method0), preserveLocalVariables: true))); + ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, method0, method1, GetEquivalentNodesMap(method1, method0)))); diff1.VerifyIL("C.M", @" @@ -10874,7 +10873,7 @@ class B var method1 = compilation1.GetMember("A.M"); var diff1 = compilation1.EmitDifference( generation0, - ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, method0, method1, GetEquivalentNodesMap(method1, method0), preserveLocalVariables: true))); + ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, method0, method1, GetEquivalentNodesMap(method1, method0)))); diff1.EmitResult.Diagnostics.Verify(); // Source method with no dynamic operations. @@ -10884,7 +10883,7 @@ class B method1 = compilation1.GetMember("A.N"); diff1 = compilation1.EmitDifference( generation0, - ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, method0, method1, GetEquivalentNodesMap(method1, method0), preserveLocalVariables: true))); + ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, method0, method1, GetEquivalentNodesMap(method1, method0)))); diff1.EmitResult.Diagnostics.Verify(); // Explicit .ctor with dynamic operations. @@ -10894,7 +10893,7 @@ class B method1 = compilation1.GetMember("A..ctor"); diff1 = compilation1.EmitDifference( generation0, - ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, method0, method1, GetEquivalentNodesMap(method1, method0), preserveLocalVariables: true))); + ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, method0, method1, GetEquivalentNodesMap(method1, method0)))); diff1.EmitResult.Diagnostics.Verify(); // Explicit .cctor with dynamic operations. @@ -10904,7 +10903,7 @@ class B method1 = compilation1.GetMember("A..cctor"); diff1 = compilation1.EmitDifference( generation0, - ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, method0, method1, GetEquivalentNodesMap(method1, method0), preserveLocalVariables: true))); + ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, method0, method1, GetEquivalentNodesMap(method1, method0)))); diff1.EmitResult.Diagnostics.Verify(); // Implicit .ctor with dynamic operations. @@ -10914,7 +10913,7 @@ class B method1 = compilation1.GetMember("B..ctor"); diff1 = compilation1.EmitDifference( generation0, - ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, method0, method1, GetEquivalentNodesMap(method1, method0), preserveLocalVariables: true))); + ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, method0, method1, GetEquivalentNodesMap(method1, method0)))); diff1.EmitResult.Diagnostics.Verify(); // Implicit .cctor with dynamic operations. @@ -10924,7 +10923,7 @@ class B method1 = compilation1.GetMember("B..cctor"); diff1 = compilation1.EmitDifference( generation0, - ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, method0, method1, GetEquivalentNodesMap(method1, method0), preserveLocalVariables: true))); + ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, method0, method1, GetEquivalentNodesMap(method1, method0)))); diff1.EmitResult.Diagnostics.Verify(); } @@ -10995,7 +10994,7 @@ .locals init (object V_0) //x var diff1 = compilation1.EmitDifference( generation0, ImmutableArray.Create( - SemanticEdit.Create(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1), preserveLocalVariables: true))); + SemanticEdit.Create(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1)))); diff1.VerifySynthesizedMembers( "C: {<>o__0#1}", @@ -11036,7 +11035,7 @@ .locals init (object V_0) //x var diff2 = compilation2.EmitDifference( diff1.NextGeneration, ImmutableArray.Create( - SemanticEdit.Create(SemanticEditKind.Update, f1, f2, GetSyntaxMapFromMarkers(source1, source2), preserveLocalVariables: true))); + SemanticEdit.Create(SemanticEditKind.Update, f1, f2, GetSyntaxMapFromMarkers(source1, source2)))); diff2.VerifySynthesizedMembers( "C: {<>o__0#2, <>o__0#1}", @@ -11143,7 +11142,7 @@ static void F() var diff1 = compilation1.EmitDifference( generation0, - ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1), preserveLocalVariables: true))); + ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1)))); diff1.VerifyIL("C.F", @" { @@ -11261,7 +11260,7 @@ static void M(I x) var diff1 = compilation1.EmitDifference( generation0, - ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, method0, method1, GetSyntaxMapFromMarkers(source0, source1), preserveLocalVariables: true))); + ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, method0, method1, GetSyntaxMapFromMarkers(source0, source1)))); diff1.EmitResult.Diagnostics.Verify( // error CS7096: Cannot continue since the edit includes a reference to an embedded type: 'I'. @@ -11314,7 +11313,7 @@ static void M(I x) var diff1 = compilation1.EmitDifference( generation0, - ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, method0, method1, GetSyntaxMapFromMarkers(source0, source1), preserveLocalVariables: true))); + ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, method0, method1, GetSyntaxMapFromMarkers(source0, source1)))); diff1.EmitResult.Diagnostics.Verify( // (6,16): warning CS0219: The variable 'y' is assigned but its value is never used @@ -11409,7 +11408,7 @@ static void M2(object o) // Disallow edits that require NoPIA references. var diff1A = compilation1A.EmitDifference( generation0, - ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, method0, method1A, GetEquivalentNodesMap(method1A, method0), preserveLocalVariables: true))); + ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, method0, method1A, GetEquivalentNodesMap(method1A, method0)))); diff1A.EmitResult.Diagnostics.Verify( // error CS7094: Cannot continue since the edit includes a reference to an embedded type: 'S'. @@ -11421,7 +11420,7 @@ static void M2(object o) // even if the previous code included references. var diff1B = compilation1B.EmitDifference( generation0, - ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, method0, method1B, GetEquivalentNodesMap(method1B, method0), preserveLocalVariables: true))); + ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, method0, method1B, GetEquivalentNodesMap(method1B, method0)))); diff1B.VerifyIL("C.M1", @"{ @@ -11608,7 +11607,7 @@ static void M() var diff1 = compilation1.EmitDifference( generation0, - ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, method0, method1, GetEquivalentNodesMap(method1, method0), preserveLocalVariables: true))); + ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, method0, method1, GetEquivalentNodesMap(method1, method0)))); using var md1 = diff1.GetMetadata(); var reader1 = md1.Reader; @@ -11723,7 +11722,7 @@ static string G() var diff1 = compilation1.EmitDifference( generation0, - ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, method0F, method1F, syntaxMap: s => null, preserveLocalVariables: true))); + ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, method0F, method1F, syntaxMap: s => null))); using var md1 = diff1.GetMetadata(); var reader1 = md1.Reader; @@ -11736,7 +11735,7 @@ static string G() // Change method updated in generation 1. var diff2F = compilation2.EmitDifference( diff1.NextGeneration, - ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, method1F, method2F, syntaxMap: s => null, preserveLocalVariables: true))); + ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, method1F, method2F, syntaxMap: s => null))); using var md2 = diff2F.GetMetadata(); var reader2 = md2.Reader; @@ -11748,7 +11747,7 @@ static string G() // Change method unchanged since generation 0. var diff2G = compilation2.EmitDifference( diff1.NextGeneration, - ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, method1G, method2G, syntaxMap: s => null, preserveLocalVariables: true))); + ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, method1G, method2G, syntaxMap: s => null))); } [Fact] @@ -11791,7 +11790,7 @@ static string F() var result = compilation1.EmitDifference( generation0, - ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, method0F, method1F, syntaxMap: s => null, preserveLocalVariables: true)), + ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, method0F, method1F, syntaxMap: s => null)), isAddedSymbol, badStream, ilStream, @@ -11806,7 +11805,7 @@ static string F() result = compilation1.EmitDifference( generation0, - ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, method0F, method1F, syntaxMap: s => null, preserveLocalVariables: true)), + ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, method0F, method1F, syntaxMap: s => null)), isAddedSymbol, mdStream, badStream, @@ -11821,7 +11820,7 @@ static string F() result = compilation1.EmitDifference( generation0, - ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, method0F, method1F, syntaxMap: s => null, preserveLocalVariables: true)), + ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, method0F, method1F, syntaxMap: s => null)), isAddedSymbol, mdStream, ilStream, @@ -11876,7 +11875,7 @@ static string F() var result = compilation1.EmitDifference( generation0, - ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, method0F, method1F, syntaxMap: s => null, preserveLocalVariables: true)), + ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, method0F, method1F, syntaxMap: s => null)), isAddedSymbol, mdStream, ilStream, @@ -12004,7 +12003,7 @@ static void F() var method1F = compilation1.GetMember("C.F"); var diff1 = compilation1.EmitDifference( generation0, - ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, method0F, method1F, syntaxMap: s => null, preserveLocalVariables: true))); + ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, method0F, method1F, syntaxMap: s => null))); var handle = MetadataTokens.BlobHandle(1); byte[] value0 = reader0.GetBlobBytes(handle); @@ -12015,7 +12014,7 @@ static void F() var method2F = compilation2.GetMember("C.F"); var diff2F = compilation2.EmitDifference( diff1.NextGeneration, - ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, method1F, method2F, syntaxMap: s => null, preserveLocalVariables: true))); + ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, method1F, method2F, syntaxMap: s => null))); byte[] value1 = reader1.GetBlobBytes(handle); Assert.Equal("07-02-0E-0C", BitConverter.ToString(value1)); @@ -12139,7 +12138,7 @@ public class B var diffB1 = compilationB1.EmitDifference( generationB0, - ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, f0, f1, GetEquivalentNodesMap(f1, f0), preserveLocalVariables: true))); + ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, f0, f1, GetEquivalentNodesMap(f1, f0)))); diffB1.VerifyIL("B.F", @" { @@ -12158,7 +12157,7 @@ .locals init (A V_0) //a var diffB2 = compilationB2.EmitDifference( diffB1.NextGeneration, - ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, f1, f2, GetEquivalentNodesMap(f2, f1), preserveLocalVariables: true))); + ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, f1, f2, GetEquivalentNodesMap(f2, f1)))); diffB2.VerifyIL("B.F", @" { @@ -12211,7 +12210,7 @@ public 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(); @@ -12303,7 +12302,7 @@ static void F() var diff1 = compilation1.EmitDifference( generation0, - ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1), preserveLocalVariables: true))); + ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1)))); diff1.EmitResult.Diagnostics.Verify( // (6,14): error CS7038: Failed to emit module 'Unable to read debug information of method 'C.F()' (token 0x06000001) from assembly 'PdbReadingErrorsAssembly, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null''. @@ -12352,7 +12351,7 @@ static void F() Assert.Throws(() => compilation1.EmitDifference( generation0, - ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1), preserveLocalVariables: true)))); + ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1))))); } [Fact] @@ -12421,7 +12420,7 @@ .locals init (int V_0, //i var diff1 = compilation1.EmitDifference( generation0, ImmutableArray.Create( - SemanticEdit.Create(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1), preserveLocalVariables: true))); + SemanticEdit.Create(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1)))); diff1.VerifyIL("C.F", @" { @@ -12464,7 +12463,7 @@ .locals init ([int] V_0, var diff2 = compilation2.EmitDifference( diff1.NextGeneration, ImmutableArray.Create( - SemanticEdit.Create(SemanticEditKind.Update, f1, f2, GetSyntaxMapFromMarkers(source1, source2), preserveLocalVariables: true))); + SemanticEdit.Create(SemanticEditKind.Update, f1, f2, GetSyntaxMapFromMarkers(source1, source2)))); diff2.VerifyIL("C.F", @" { @@ -12570,7 +12569,7 @@ .locals init (int V_0, //i var diff1 = compilation1.EmitDifference( generation0, ImmutableArray.Create( - SemanticEdit.Create(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1), preserveLocalVariables: true))); + SemanticEdit.Create(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1)))); diff1.VerifyIL("C.F", @" { @@ -12603,7 +12602,7 @@ .locals init ([int] V_0, var diff2 = compilation2.EmitDifference( diff1.NextGeneration, ImmutableArray.Create( - SemanticEdit.Create(SemanticEditKind.Update, f1, f2, GetSyntaxMapFromMarkers(source1, source2), preserveLocalVariables: true))); + SemanticEdit.Create(SemanticEditKind.Update, f1, f2, GetSyntaxMapFromMarkers(source1, source2)))); diff2.VerifyIL("C.F", @" { @@ -12698,7 +12697,7 @@ .locals init (int V_0, //x var diff1 = compilation1.EmitDifference( generation0, ImmutableArray.Create( - SemanticEdit.Create(SemanticEditKind.Update, ctor0, ctor1, GetSyntaxMapFromMarkers(source0, source1), preserveLocalVariables: true))); + SemanticEdit.Create(SemanticEditKind.Update, ctor0, ctor1, GetSyntaxMapFromMarkers(source0, source1)))); diff1.VerifyIL("C..ctor", @" { @@ -12722,7 +12721,7 @@ .locals init (int V_0, //x var diff2 = compilation2.EmitDifference( diff1.NextGeneration, ImmutableArray.Create( - SemanticEdit.Create(SemanticEditKind.Update, ctor1, ctor2, GetSyntaxMapFromMarkers(source1, source0), preserveLocalVariables: true))); + SemanticEdit.Create(SemanticEditKind.Update, ctor1, ctor2, GetSyntaxMapFromMarkers(source1, source0)))); diff2.VerifyIL("C..ctor", @" { @@ -12806,7 +12805,7 @@ .locals init (int V_0, //x var diff1 = compilation1.EmitDifference( generation0, ImmutableArray.Create( - SemanticEdit.Create(SemanticEditKind.Update, ctor0, ctor1, GetSyntaxMapFromMarkers(source0, source1), preserveLocalVariables: true))); + SemanticEdit.Create(SemanticEditKind.Update, ctor0, ctor1, GetSyntaxMapFromMarkers(source0, source1)))); diff1.VerifyIL("C..ctor", @" { @@ -12831,7 +12830,7 @@ .locals init (int V_0, //x var diff2 = compilation2.EmitDifference( diff1.NextGeneration, ImmutableArray.Create( - SemanticEdit.Create(SemanticEditKind.Update, ctor1, ctor2, GetSyntaxMapFromMarkers(source1, source0), preserveLocalVariables: true))); + SemanticEdit.Create(SemanticEditKind.Update, ctor1, ctor2, GetSyntaxMapFromMarkers(source1, source0)))); diff2.VerifyIL("C..ctor", @" { @@ -12949,7 +12948,7 @@ .locals init (int V_0, //x var diff1 = compilation1.EmitDifference( generation0, ImmutableArray.Create( - SemanticEdit.Create(SemanticEditKind.Update, n0, n1, GetSyntaxMapFromMarkers(source0, source1), preserveLocalVariables: true))); + SemanticEdit.Create(SemanticEditKind.Update, n0, n1, GetSyntaxMapFromMarkers(source0, source1)))); diff1.VerifySynthesizedMembers("Program: {<>c}", "Program.<>c: {<>9__0_0, b__0_0}"); @@ -13001,7 +13000,7 @@ .locals init (int V_0, //x var diff2 = compilation2.EmitDifference( diff1.NextGeneration, ImmutableArray.Create( - SemanticEdit.Create(SemanticEditKind.Update, n1, n2, GetSyntaxMapFromMarkers(source1, source0), preserveLocalVariables: true))); + SemanticEdit.Create(SemanticEditKind.Update, n1, n2, GetSyntaxMapFromMarkers(source1, source0)))); diff2.VerifySynthesizedMembers("Program: {<>c}", "Program.<>c: {<>9__0_0, b__0_0}"); @@ -13121,7 +13120,7 @@ .locals init (System.ValueTuple> V_0, //x var diff1 = compilation1.EmitDifference( generation0, ImmutableArray.Create( - SemanticEdit.Create(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1), preserveLocalVariables: true))); + SemanticEdit.Create(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1)))); diff1.VerifyIL("C.F", @" { @@ -13155,7 +13154,7 @@ .locals init ([unchanged] V_0, var diff2 = compilation2.EmitDifference( diff1.NextGeneration, ImmutableArray.Create( - SemanticEdit.Create(SemanticEditKind.Update, f1, f2, GetSyntaxMapFromMarkers(source1, source2), preserveLocalVariables: true))); + SemanticEdit.Create(SemanticEditKind.Update, f1, f2, GetSyntaxMapFromMarkers(source1, source2)))); diff2.VerifyIL("C.F", @" { @@ -13247,7 +13246,7 @@ .locals init (int V_0, //x var diff1 = compilation1.EmitDifference( generation0, ImmutableArray.Create( - SemanticEdit.Create(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1), preserveLocalVariables: true))); + SemanticEdit.Create(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1)))); diff1.VerifyIL("C.F", @" { @@ -13276,7 +13275,7 @@ .locals init (int V_0, //x var diff2 = compilation2.EmitDifference( diff1.NextGeneration, ImmutableArray.Create( - SemanticEdit.Create(SemanticEditKind.Update, f1, f2, GetSyntaxMapFromMarkers(source1, source2), preserveLocalVariables: true))); + SemanticEdit.Create(SemanticEditKind.Update, f1, f2, GetSyntaxMapFromMarkers(source1, source2)))); diff2.VerifyIL("C.F", @" { @@ -13417,7 +13416,7 @@ .locals init (System.ValueTuple>[] V_0, var diff1 = compilation1.EmitDifference( generation0, ImmutableArray.Create( - SemanticEdit.Create(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1), preserveLocalVariables: true))); + SemanticEdit.Create(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1)))); diff1.VerifyIL("C.G", @" { @@ -13474,7 +13473,7 @@ .locals init ([unchanged] V_0, var diff2 = compilation2.EmitDifference( diff1.NextGeneration, ImmutableArray.Create( - SemanticEdit.Create(SemanticEditKind.Update, f1, f2, GetSyntaxMapFromMarkers(source1, source2), preserveLocalVariables: true))); + SemanticEdit.Create(SemanticEditKind.Update, f1, f2, GetSyntaxMapFromMarkers(source1, source2)))); diff2.VerifyIL("C.G", @" { @@ -13585,7 +13584,7 @@ .locals init (int V_0, //x var diff1 = compilation1.EmitDifference( generation0, ImmutableArray.Create( - SemanticEdit.Create(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1), preserveLocalVariables: true))); + SemanticEdit.Create(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1)))); diff1.VerifyIL("C.G", @" { @@ -13613,7 +13612,7 @@ .locals init (int V_0, //x var diff2 = compilation2.EmitDifference( diff1.NextGeneration, ImmutableArray.Create( - SemanticEdit.Create(SemanticEditKind.Update, f1, f2, GetSyntaxMapFromMarkers(source1, source2), preserveLocalVariables: true))); + SemanticEdit.Create(SemanticEditKind.Update, f1, f2, GetSyntaxMapFromMarkers(source1, source2)))); diff2.VerifyIL("C.G", @" { @@ -13697,7 +13696,7 @@ .locals init (int V_0, //x var diff1 = compilation1.EmitDifference( generation0, ImmutableArray.Create( - SemanticEdit.Create(SemanticEditKind.Update, ctor0, ctor1, GetSyntaxMapFromMarkers(source0, source1), preserveLocalVariables: true))); + SemanticEdit.Create(SemanticEditKind.Update, ctor0, ctor1, GetSyntaxMapFromMarkers(source0, source1)))); diff1.VerifyIL("C..ctor", @" { @@ -13720,7 +13719,7 @@ .locals init (int V_0, //x var diff2 = compilation2.EmitDifference( diff1.NextGeneration, ImmutableArray.Create( - SemanticEdit.Create(SemanticEditKind.Update, ctor1, ctor2, GetSyntaxMapFromMarkers(source1, source0), preserveLocalVariables: true))); + SemanticEdit.Create(SemanticEditKind.Update, ctor1, ctor2, GetSyntaxMapFromMarkers(source1, source0)))); diff2.VerifyIL("C..ctor", @" { @@ -13818,7 +13817,7 @@ .maxstack 2 var diff1 = compilation1.EmitDifference( generation0, ImmutableArray.Create( - SemanticEdit.Create(SemanticEditKind.Update, ctor0, ctor1, GetSyntaxMapFromMarkers(source0, source1), preserveLocalVariables: true))); + SemanticEdit.Create(SemanticEditKind.Update, ctor0, ctor1, GetSyntaxMapFromMarkers(source0, source1)))); using var md1 = diff1.GetMetadata(); var reader1 = md1.Reader; @@ -13867,7 +13866,7 @@ .maxstack 2 var diff2 = compilation2.EmitDifference( diff1.NextGeneration, ImmutableArray.Create( - SemanticEdit.Create(SemanticEditKind.Update, ctor1, ctor2, GetSyntaxMapFromMarkers(source1, source0), preserveLocalVariables: true))); + SemanticEdit.Create(SemanticEditKind.Update, ctor1, ctor2, GetSyntaxMapFromMarkers(source1, source0)))); using var md2 = diff2.GetMetadata(); var reader2 = md2.Reader; @@ -13980,7 +13979,7 @@ .maxstack 2 var diff1 = compilation1.EmitDifference( generation0, ImmutableArray.Create( - SemanticEdit.Create(SemanticEditKind.Update, ctor0, ctor1, GetSyntaxMapFromMarkers(source0, source1), preserveLocalVariables: true))); + SemanticEdit.Create(SemanticEditKind.Update, ctor0, ctor1, GetSyntaxMapFromMarkers(source0, source1)))); diff1.VerifySynthesizedMembers("C: {<>c__DisplayClass0_0}", "C.<>c__DisplayClass0_0: {x, b__0}"); @@ -14021,7 +14020,7 @@ .maxstack 2 var diff2 = compilation2.EmitDifference( diff1.NextGeneration, ImmutableArray.Create( - SemanticEdit.Create(SemanticEditKind.Update, ctor1, ctor2, GetSyntaxMapFromMarkers(source1, source0), preserveLocalVariables: true))); + SemanticEdit.Create(SemanticEditKind.Update, ctor1, ctor2, GetSyntaxMapFromMarkers(source1, source0)))); diff2.VerifySynthesizedMembers("C: {<>c__DisplayClass0_0}", "C.<>c__DisplayClass0_0: {x, b__0}"); @@ -14114,7 +14113,7 @@ .locals init (int V_0, //x var diff1 = compilation1.EmitDifference( generation0, ImmutableArray.Create( - SemanticEdit.Create(SemanticEditKind.Update, ctor0, ctor1, GetSyntaxMapFromMarkers(source0, source1), preserveLocalVariables: true))); + SemanticEdit.Create(SemanticEditKind.Update, ctor0, ctor1, GetSyntaxMapFromMarkers(source0, source1)))); diff1.VerifyIL("C..ctor", @" { @@ -14138,7 +14137,7 @@ .locals init (int V_0, //x var diff2 = compilation2.EmitDifference( diff1.NextGeneration, ImmutableArray.Create( - SemanticEdit.Create(SemanticEditKind.Update, ctor1, ctor2, GetSyntaxMapFromMarkers(source1, source0), preserveLocalVariables: true))); + SemanticEdit.Create(SemanticEditKind.Update, ctor1, ctor2, GetSyntaxMapFromMarkers(source1, source0)))); diff2.VerifyIL("C..ctor", @" { @@ -14232,7 +14231,7 @@ .maxstack 2 var diff1 = compilation1.EmitDifference( generation0, ImmutableArray.Create( - SemanticEdit.Create(SemanticEditKind.Update, ctor0, ctor1, GetSyntaxMapFromMarkers(source0, source1), preserveLocalVariables: true))); + SemanticEdit.Create(SemanticEditKind.Update, ctor0, ctor1, GetSyntaxMapFromMarkers(source0, source1)))); diff1.VerifySynthesizedMembers( "C.<>c__DisplayClass3_0: {x, <.ctor>b__0}", @@ -14276,7 +14275,7 @@ .maxstack 2 var diff2 = compilation2.EmitDifference( diff1.NextGeneration, ImmutableArray.Create( - SemanticEdit.Create(SemanticEditKind.Update, ctor1, ctor2, GetSyntaxMapFromMarkers(source1, source0), preserveLocalVariables: true))); + SemanticEdit.Create(SemanticEditKind.Update, ctor1, ctor2, GetSyntaxMapFromMarkers(source1, source0)))); diff2.VerifySynthesizedMembers( "C.<>c__DisplayClass3_0: {x, <.ctor>b__0}", @@ -14409,7 +14408,7 @@ .locals init (int V_0, //x var diff1 = compilation1.EmitDifference( generation0, ImmutableArray.Create( - SemanticEdit.Create(SemanticEditKind.Update, n0, n1, GetSyntaxMapFromMarkers(source0, source1), preserveLocalVariables: true))); + SemanticEdit.Create(SemanticEditKind.Update, n0, n1, GetSyntaxMapFromMarkers(source0, source1)))); diff1.VerifySynthesizedMembers( "Program: {<>c}", @@ -14463,7 +14462,7 @@ .locals init (int V_0, //x var diff2 = compilation2.EmitDifference( diff1.NextGeneration, ImmutableArray.Create( - SemanticEdit.Create(SemanticEditKind.Update, n1, n2, GetSyntaxMapFromMarkers(source1, source0), preserveLocalVariables: true))); + SemanticEdit.Create(SemanticEditKind.Update, n1, n2, GetSyntaxMapFromMarkers(source1, source0)))); diff2.VerifySynthesizedMembers( "Program: {<>c}", @@ -14625,7 +14624,7 @@ .maxstack 2 var diff1 = compilation1.EmitDifference( generation0, ImmutableArray.Create( - SemanticEdit.Create(SemanticEditKind.Update, n0, n1, GetSyntaxMapFromMarkers(source0, source1), preserveLocalVariables: true))); + SemanticEdit.Create(SemanticEditKind.Update, n0, n1, GetSyntaxMapFromMarkers(source0, source1)))); diff1.VerifySynthesizedMembers( "Program: {<>c, <>c__DisplayClass2_0}", @@ -14696,7 +14695,7 @@ .maxstack 2 var diff2 = compilation2.EmitDifference( diff1.NextGeneration, ImmutableArray.Create( - SemanticEdit.Create(SemanticEditKind.Update, n1, n2, GetSyntaxMapFromMarkers(source1, source0), preserveLocalVariables: true))); + SemanticEdit.Create(SemanticEditKind.Update, n1, n2, GetSyntaxMapFromMarkers(source1, source0)))); diff2.VerifySynthesizedMembers( "Program.<>c__DisplayClass2_0: {x, b__1}", @@ -14859,7 +14858,7 @@ .locals init (object V_0) var diff1 = compilation1.EmitDifference( generation0, ImmutableArray.Create( - SemanticEdit.Create(SemanticEditKind.Update, n0, n1, GetSyntaxMapFromMarkers(source0, source1), preserveLocalVariables: true))); + SemanticEdit.Create(SemanticEditKind.Update, n0, n1, GetSyntaxMapFromMarkers(source0, source1)))); diff1.VerifySynthesizedMembers(); @@ -14909,7 +14908,7 @@ .locals init ([int] V_0, var diff2 = compilation2.EmitDifference( diff1.NextGeneration, ImmutableArray.Create( - SemanticEdit.Create(SemanticEditKind.Update, n1, n2, GetSyntaxMapFromMarkers(source1, source0), preserveLocalVariables: true))); + SemanticEdit.Create(SemanticEditKind.Update, n1, n2, GetSyntaxMapFromMarkers(source1, source0)))); diff2.VerifySynthesizedMembers(); @@ -14998,7 +14997,7 @@ static void G() var diffError = compilation1.EmitDifference( generation0, ImmutableArray.Create( - SemanticEdit.Create(SemanticEditKind.Update, e0, e1, GetSyntaxMapFromMarkers(source0, source1), preserveLocalVariables: true))); + SemanticEdit.Create(SemanticEditKind.Update, e0, e1, GetSyntaxMapFromMarkers(source0, source1)))); diffError.EmitResult.Diagnostics.Verify( // (9,21): error CS0104: 'Timer' is an ambiguous reference between 'System.Threading.Timer' and 'System.Timers.Timer' @@ -15596,7 +15595,7 @@ void M() var diff = compilation1.EmitDifference( generation0, ImmutableArray.Create( - SemanticEdit.Create(SemanticEditKind.Update, method0, method1, GetSyntaxMapFromMarkers(source0, source1), preserveLocalVariables: true))); + SemanticEdit.Create(SemanticEditKind.Update, method0, method1, GetSyntaxMapFromMarkers(source0, source1)))); // There should be no diagnostics from rude edits diff.EmitResult.Diagnostics.Verify(); @@ -17397,7 +17396,7 @@ .maxstack 1 var diff = compilation1.EmitDifference( generation0, ImmutableArray.Create( - SemanticEdit.Create(SemanticEditKind.Update, method0, method1, GetSyntaxMapFromMarkers(source0, source1), preserveLocalVariables: true))); + SemanticEdit.Create(SemanticEditKind.Update, method0, method1, GetSyntaxMapFromMarkers(source0, source1)))); // There should be no diagnostics from rude edits diff.EmitResult.Diagnostics.Verify(); @@ -17473,8 +17472,8 @@ .maxstack 1 var diff = compilation1.EmitDifference( generation0, ImmutableArray.Create( - SemanticEdit.Create(SemanticEditKind.Update, cm1_gen0, cm1_gen1, GetSyntaxMapFromMarkers(source0, source1), preserveLocalVariables: true), - SemanticEdit.Create(SemanticEditKind.Insert, null, c2_gen1, syntaxMap: null, preserveLocalVariables: true))); + SemanticEdit.Create(SemanticEditKind.Update, cm1_gen0, cm1_gen1, GetSyntaxMapFromMarkers(source0, source1)), + SemanticEdit.Create(SemanticEditKind.Insert, null, c2_gen1, syntaxMap: null))); // There should be no diagnostics from rude edits diff.EmitResult.Diagnostics.Verify(); @@ -17567,8 +17566,8 @@ .maxstack 1 var diff = compilation1.EmitDifference( generation0, ImmutableArray.Create( - SemanticEdit.Create(SemanticEditKind.Insert, null, c1_gen1, syntaxMap: null, preserveLocalVariables: true), - SemanticEdit.Create(SemanticEditKind.Insert, null, c2_gen1, syntaxMap: null, preserveLocalVariables: true))); + SemanticEdit.Create(SemanticEditKind.Insert, null, c1_gen1, syntaxMap: null), + SemanticEdit.Create(SemanticEditKind.Insert, null, c2_gen1, syntaxMap: null))); // There should be no diagnostics from rude edits diff.EmitResult.Diagnostics.Verify(); @@ -17656,7 +17655,7 @@ .maxstack 1 var diff = compilation1.EmitDifference( generation0, ImmutableArray.Create( - SemanticEdit.Create(SemanticEditKind.Insert, null, c2_gen1, syntaxMap: null, preserveLocalVariables: true))); + SemanticEdit.Create(SemanticEditKind.Insert, null, c2_gen1, syntaxMap: null))); // There should be no diagnostics from rude edits diff.EmitResult.Diagnostics.Verify(); diff --git a/src/Compilers/CSharp/Test/Emit/Emit/EditAndContinue/LocalSlotMappingTests.cs b/src/Compilers/CSharp/Test/Emit/Emit/EditAndContinue/LocalSlotMappingTests.cs index ba3c00cdf62a9..e0a1c151e92d1 100644 --- a/src/Compilers/CSharp/Test/Emit/Emit/EditAndContinue/LocalSlotMappingTests.cs +++ b/src/Compilers/CSharp/Test/Emit/Emit/EditAndContinue/LocalSlotMappingTests.cs @@ -77,7 +77,7 @@ .locals init (bool V_0, //b var diff1 = compilation1.EmitDifference( generation0, - ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, method0, method1, syntaxMap: null, preserveLocalVariables: true))); + ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, method0, method1, syntaxMap: null))); diff1.VerifyIL("C.Main", @" { @@ -251,7 +251,7 @@ .locals init (int V_0, //j var method1 = compilation1.GetMember("C.M"); var diff1 = compilation1.EmitDifference( generation0, - ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, method0, method1, GetEquivalentNodesMap(method1, method0), preserveLocalVariables: true))); + ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, method0, method1, GetEquivalentNodesMap(method1, method0)))); // check that all user-defined and long-lived synthesized local slots are reused diff1.VerifyIL("C.M", @" @@ -435,7 +435,7 @@ static void M() var method1 = compilation1.GetMember("C.M"); var diff1 = compilation1.EmitDifference( generation0, - ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, method0, method1, GetEquivalentNodesMap(method1, method0), preserveLocalVariables: true))); + ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, method0, method1, GetEquivalentNodesMap(method1, method0)))); diff1.VerifyIL("C.M", @" { @@ -541,7 +541,7 @@ static void M() var diff1 = compilation1.EmitDifference( generation0, - ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, method0, method1, GetSyntaxMapFromMarkers(source0, source1), preserveLocalVariables: true))); + ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, method0, method1, GetSyntaxMapFromMarkers(source0, source1)))); v0.VerifyPdb("C.M", @" @@ -653,7 +653,7 @@ static void M() var diff1 = compilation1.EmitDifference( generation0, - ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, method0, method1, GetSyntaxMapFromMarkers(source0, source1), preserveLocalVariables: true))); + ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, method0, method1, GetSyntaxMapFromMarkers(source0, source1)))); v0.VerifyPdb("C.M", @" @@ -763,7 +763,7 @@ static async Task M() var diff1 = compilation1.EmitDifference( generation0, - ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, method0, method1, GetSyntaxMapFromMarkers(source0, source1), preserveLocalVariables: true))); + ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, method0, method1, GetSyntaxMapFromMarkers(source0, source1)))); v0.VerifyPdb("C.M", @" @@ -854,7 +854,7 @@ static async Task M() var diff1 = compilation1.EmitDifference( generation0, - ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, method0, method1, GetSyntaxMapFromMarkers(source0, source1), preserveLocalVariables: true))); + ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, method0, method1, GetSyntaxMapFromMarkers(source0, source1)))); v0.VerifyPdb("C.M", @" @@ -935,7 +935,7 @@ static void M() var method1 = compilation1.GetMember("C.M"); var diff1 = compilation1.EmitDifference( generation0, - ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, method0, method1, GetEquivalentNodesMap(method1, method0), preserveLocalVariables: true))); + ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, method0, method1, GetEquivalentNodesMap(method1, method0)))); diff1.VerifyIL("C.M", @" { @@ -1029,7 +1029,7 @@ static void M() var method1 = compilation1.GetMember("C.M"); var diff1 = compilation1.EmitDifference( generation0, - ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, method0, method1, GetEquivalentNodesMap(method1, method0), preserveLocalVariables: true))); + ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, method0, method1, GetEquivalentNodesMap(method1, method0)))); diff1.VerifyIL("C.M", @"{ @@ -1092,7 +1092,7 @@ unsafe static void M(string s, int[] i) var method1 = compilation1.GetMember("C.M"); var diff1 = compilation1.EmitDifference( generation0, - ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, method0, method1, GetEquivalentNodesMap(method1, method0), preserveLocalVariables: true))); + ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, method0, method1, GetEquivalentNodesMap(method1, method0)))); diff1.VerifyIL("C.M", @" @@ -1200,7 +1200,7 @@ unsafe static void M(string s1, string s2, string s3, string s4) var method1 = compilation1.GetMember("C.M"); var diff1 = compilation1.EmitDifference( generation0, - ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, method0, method1, GetEquivalentNodesMap(method1, method0), preserveLocalVariables: true))); + ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, method0, method1, GetEquivalentNodesMap(method1, method0)))); diff1.VerifyIL("C.M", @" @@ -1364,7 +1364,7 @@ static void M() var method1 = compilation1.GetMember("C.M"); var diff1 = compilation1.EmitDifference( generation0, - ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, method0, method1, GetEquivalentNodesMap(method1, method0), preserveLocalVariables: true))); + ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, method0, method1, GetEquivalentNodesMap(method1, method0)))); diff1.VerifyIL("C.M", @"{ @@ -1620,7 +1620,7 @@ .locals init (double[,,] V_0, var method1 = compilation1.GetMember("C.M"); var diff1 = compilation1.EmitDifference( generation0, - ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, method0, method1, GetEquivalentNodesMap(method1, method0), preserveLocalVariables: true))); + ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, method0, method1, GetEquivalentNodesMap(method1, method0)))); diff1.VerifyIL("C.M", @" { @@ -1732,7 +1732,7 @@ static void M(string a, object[] b, double[,,] c) var method1 = compilation1.GetMember("C.M"); var diff1 = compilation1.EmitDifference( generation0, - ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, method0, method1, GetEquivalentNodesMap(method1, method0), preserveLocalVariables: true))); + ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, method0, method1, GetEquivalentNodesMap(method1, method0)))); diff1.VerifyIL("C.M", @" @@ -1892,7 +1892,7 @@ static void M(object o) var method1 = compilation1.GetMember("C.M"); var diff1 = compilation1.EmitDifference( generation0, - ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, method0, method1, GetEquivalentNodesMap(method1, method0), preserveLocalVariables: true))); + ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, method0, method1, GetEquivalentNodesMap(method1, method0)))); } [Fact] @@ -1925,7 +1925,7 @@ static void M((dynamic, int) t) var method1 = compilation1.GetMember("C.M"); var diff1 = compilation1.EmitDifference( generation0, - ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, method0, method1, GetEquivalentNodesMap(method1, method0), preserveLocalVariables: true))); + ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, method0, method1, GetEquivalentNodesMap(method1, method0)))); diff1.VerifyIL("C.M", @"{ @@ -2074,7 +2074,7 @@ .locals init (string[] V_0, //arr var method1 = compilation1.GetMember("C.M"); var diff1 = compilation1.EmitDifference( generation0, - ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, method0, method1, GetSyntaxMapFromMarkers(source0, source1), preserveLocalVariables: true))); + ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, method0, method1, GetSyntaxMapFromMarkers(source0, source1)))); diff1.VerifyIL("C.M", @" { @@ -2122,7 +2122,7 @@ .locals init (string[] V_0, //arr var method2 = compilation2.GetMember("C.M"); var diff2 = compilation2.EmitDifference( diff1.NextGeneration, - ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, method1, method2, GetSyntaxMapFromMarkers(source1, source2), preserveLocalVariables: true))); + ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, method1, method2, GetSyntaxMapFromMarkers(source1, source2)))); diff2.VerifyIL("C.M", @"{ @@ -2298,7 +2298,7 @@ .locals init (object V_0, var method1 = compilation1.GetMember("C.M"); var diff1 = compilation1.EmitDifference( generation0, - ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, method0, method1, GetEquivalentNodesMap(method1, method0), preserveLocalVariables: true))); + ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, method0, method1, GetEquivalentNodesMap(method1, method0)))); diff1.VerifyIL("C.M", @" { @@ -2360,7 +2360,7 @@ .locals init (object V_0, var method2 = compilation2.GetMember("C.M"); var diff2 = compilation2.EmitDifference( diff1.NextGeneration, - ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, method1, method2, GetEquivalentNodesMap(method2, method1), preserveLocalVariables: true))); + ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, method1, method2, GetEquivalentNodesMap(method2, method1)))); diff2.VerifyIL("C.M", @"{ @@ -2482,7 +2482,7 @@ static void M() var method1 = compilation1.GetMember("C.M"); var diff1 = compilation1.EmitDifference( generation0, - ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, method0, method1, GetEquivalentNodesMap(method1, method0), preserveLocalVariables: true))); + ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, method0, method1, GetEquivalentNodesMap(method1, method0)))); // Note that the order of unique ids in temporaries follows the // order of declaration in the updated method. Specifically, the @@ -2620,7 +2620,7 @@ static void M(A a) var method1 = compilation1.GetMember("C.M"); var diff1 = compilation1.EmitDifference( generation0, - ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, method0, method1, GetEquivalentNodesMap(method1, method0), preserveLocalVariables: true))); + ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, method0, method1, GetEquivalentNodesMap(method1, method0)))); diff1.VerifyIL("C.M", @" @@ -2795,7 +2795,7 @@ .locals init (string V_0, var diff1 = compilation1.EmitDifference( generation0, - ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, method0, method1, GetSyntaxMapByKind(method0, SyntaxKind.SwitchStatement), preserveLocalVariables: true))); + ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, method0, method1, GetSyntaxMapByKind(method0, SyntaxKind.SwitchStatement)))); diff1.VerifyIL("C.M", @" { @@ -2931,7 +2931,7 @@ .locals init (int V_0, var diff1 = compilation1.EmitDifference( generation0, - ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, method0, method1, GetSyntaxMapByKind(method0, SyntaxKind.SwitchStatement), preserveLocalVariables: true))); + ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, method0, method1, GetSyntaxMapByKind(method0, SyntaxKind.SwitchStatement)))); diff1.VerifyIL("C.M", @" { @@ -3094,7 +3094,7 @@ .locals init (byte V_0, //b var diff1 = compilation1.EmitDifference( generation0, - ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, method0, method1, GetEquivalentNodesMap(method1, method0), preserveLocalVariables: true))); + ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, method0, method1, GetEquivalentNodesMap(method1, method0)))); diff1.VerifyIL("C.M", @" { @@ -3258,7 +3258,7 @@ .locals init (bool V_0) var diff1 = compilation1.EmitDifference( generation0, - ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, method0, method1, GetSyntaxMapByKind(method0, SyntaxKind.IfStatement), preserveLocalVariables: true))); + ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, method0, method1, GetSyntaxMapByKind(method0, SyntaxKind.IfStatement)))); diff1.VerifyIL("C.M", @" { @@ -3367,7 +3367,7 @@ .locals init (bool V_0) var diff1 = compilation1.EmitDifference( generation0, - ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, method0, method1, GetSyntaxMapByKind(method0, SyntaxKind.WhileStatement), preserveLocalVariables: true))); + ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, method0, method1, GetSyntaxMapByKind(method0, SyntaxKind.WhileStatement)))); diff1.VerifyIL("C.M", @" { @@ -3477,7 +3477,7 @@ .locals init (bool V_0) var diff1 = compilation1.EmitDifference( generation0, - ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, method0, method1, GetSyntaxMapByKind(method0, SyntaxKind.DoStatement), preserveLocalVariables: true))); + ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, method0, method1, GetSyntaxMapByKind(method0, SyntaxKind.DoStatement)))); diff1.VerifyIL("C.M", @" { @@ -3568,7 +3568,7 @@ .locals init (int V_0, //i var diff1 = compilation1.EmitDifference( generation0, - ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, method0, method1, GetSyntaxMapByKind(method0, SyntaxKind.ForStatement, SyntaxKind.VariableDeclarator), preserveLocalVariables: true))); + ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, method0, method1, GetSyntaxMapByKind(method0, SyntaxKind.ForStatement, SyntaxKind.VariableDeclarator)))); diff1.VerifyIL("C.M", @" { @@ -3667,7 +3667,7 @@ .locals init (object V_0, var method1 = compilation1.GetMember("C.b__0"); var diff1 = compilation1.EmitDifference( generation0, - ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, method0, method1, GetEquivalentNodesMap(method1, method0), preserveLocalVariables: true))); + ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, method0, method1, GetEquivalentNodesMap(method1, method0)))); diff1.VerifyIL("C.b__0", @" ", methodToken: diff1.EmitResult.UpdatedMethods.Single()); @@ -3772,11 +3772,11 @@ static void M() 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)))); var diff2 = compilation2.EmitDifference( diff1.NextGeneration, - ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, m1, m2, GetSyntaxMapFromMarkers(source1, source2), preserveLocalVariables: true))); + ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, m1, m2, GetSyntaxMapFromMarkers(source1, source2)))); diff1.VerifySynthesizedMembers( "C: {<>c}", @@ -3926,7 +3926,7 @@ .locals init (int V_0) var method1 = compilation1.GetMember("?"); var diff1 = compilation1.EmitDifference( generation0, - ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, method0, method1, GetEquivalentNodesMap(method1, method0), preserveLocalVariables: true))); + ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, method0, method1, GetEquivalentNodesMap(method1, method0)))); diff1.VerifyIL("?", @" {", methodToken: diff1.EmitResult.UpdatedMethods.Single()); @@ -4086,7 +4086,7 @@ .locals init (int V_0, var method1 = compilation1.GetMember("?"); var diff1 = compilation1.EmitDifference( generation0, - ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, method0, method1, GetEquivalentNodesMap(method1, method0), preserveLocalVariables: true))); + ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, method0, method1, GetEquivalentNodesMap(method1, method0)))); diff1.VerifyIL("?", @" {", methodToken: diff1.EmitResult.UpdatedMethods.Single()); @@ -4115,7 +4115,7 @@ class C var method1 = compilation1.GetMember("C.G"); var diff1 = compilation1.EmitDifference( generation0, - ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, method0, method1, GetEquivalentNodesMap(method1, method0), preserveLocalVariables: true))); + ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, method0, method1, GetEquivalentNodesMap(method1, method0)))); diff1.VerifyIL("C.G", @" { @@ -4162,7 +4162,7 @@ class C var method1 = compilation1.GetMember("C.F"); var diff1 = compilation1.EmitDifference( generation0, - ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, method0, method1, GetEquivalentNodesMap(method1, method0), preserveLocalVariables: true))); + ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, method0, method1, GetEquivalentNodesMap(method1, method0)))); diff1.VerifyIL("C.F", @" { @@ -4218,7 +4218,7 @@ class C var method1 = compilation1.GetMember("C.F"); var diff1 = compilation1.EmitDifference( generation0, - ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, method0, method1, GetEquivalentNodesMap(method1, method0), preserveLocalVariables: true))); + ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, method0, method1, GetEquivalentNodesMap(method1, method0)))); diff1.VerifyIL("C.F", @" { @@ -4273,7 +4273,7 @@ class C var method1 = compilation1.GetMember("C.F"); var diff1 = compilation1.EmitDifference( generation0, - ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, method0, method1, GetEquivalentNodesMap(method1, method0), preserveLocalVariables: true))); + ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, method0, method1, GetEquivalentNodesMap(method1, method0)))); diff1.VerifyIL("C.F", @" { @@ -4325,7 +4325,7 @@ class C var method1 = compilation1.GetMember("C.F"); var diff1 = compilation1.EmitDifference( generation0, - ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, method0, method1, GetEquivalentNodesMap(method1, method0), preserveLocalVariables: true))); + ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, method0, method1, GetEquivalentNodesMap(method1, method0)))); diff1.VerifyIL("C.F", @" { @@ -4381,7 +4381,7 @@ class C var method1 = compilation1.GetMember("C.F"); var diff1 = compilation1.EmitDifference( generation0, - ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, method0, method1, GetEquivalentNodesMap(method1, method0), preserveLocalVariables: true))); + ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, method0, method1, GetEquivalentNodesMap(method1, method0)))); diff1.VerifyIL("C.F", @" { @@ -4450,7 +4450,7 @@ static object G(object o1, object o2) var method1 = compilation1.GetMember("C.G"); var diff1 = compilation1.EmitDifference( generation0, - ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, method0, method1, GetEquivalentNodesMap(method1, method0), preserveLocalVariables: true))); + ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, method0, method1, GetEquivalentNodesMap(method1, method0)))); diff1.VerifyIL("C.G", @" { @@ -4530,7 +4530,7 @@ static object G(object o) var method1 = compilation1.GetMember("C.G"); var diff1 = compilation1.EmitDifference( generation0, - ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, method0, method1, GetEquivalentNodesMap(method1, method0), preserveLocalVariables: true))); + ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, method0, method1, GetEquivalentNodesMap(method1, method0)))); diff1.VerifyIL("C.G", @" { @@ -4624,7 +4624,7 @@ static async Task G(object o) var diff1 = compilation1.EmitDifference( generation0, - ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, g0, g1, GetEquivalentNodesMap(g1, g0), preserveLocalVariables: true))); + ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, g0, g1, GetEquivalentNodesMap(g1, g0)))); diff1.VerifyIL("C.G", @" { @@ -4684,7 +4684,7 @@ static async Task G(Task o) var method1 = compilation1.GetMember("C.G"); var diff1 = compilation1.EmitDifference( generation0, - ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, method0, method1, GetEquivalentNodesMap(method1, method0), preserveLocalVariables: true))); + ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, method0, method1, GetEquivalentNodesMap(method1, method0)))); diff1.VerifyIL("C.G", @" { @@ -4744,7 +4744,7 @@ static object G() var method1 = compilation1.GetMember("C.G"); var diff1 = compilation1.EmitDifference( generation0, - ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, method0, method1, GetEquivalentNodesMap(method1, method0), preserveLocalVariables: true))); + ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, method0, method1, GetEquivalentNodesMap(method1, method0)))); diff1.VerifyIL("C.G", @" { @@ -4833,7 +4833,7 @@ public static void G() var method1 = compilation1.GetMember("C.G"); var diff1 = compilation1.EmitDifference( generation0, - ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, method0, method1, GetEquivalentNodesMap(method1, method0), preserveLocalVariables: true))); + ImmutableArray.Create(SemanticEdit.Create(SemanticEditKind.Update, method0, method1, GetEquivalentNodesMap(method1, method0)))); diff1.VerifyIL("C.G", @" { @@ -4988,7 +4988,7 @@ .locals init (<>f__AnonymousType0f__AnonymousType0 GetMappedMethod // to a class that has field/property initializers with lambdas. These lambdas get "copied" into the constructor // (assuming it doesn't have "this" constructor initializer) and thus their generated names need to be preserved. - if (edit.Kind == SemanticEditKind.Update && edit.PreserveLocalVariables) + if (edit.Kind == SemanticEditKind.Update && edit.SyntaxMap != null) { RoslynDebug.AssertNotNull(edit.NewSymbol); RoslynDebug.AssertNotNull(edit.OldSymbol); diff --git a/src/Compilers/Core/Portable/Emit/SemanticEdit.cs b/src/Compilers/Core/Portable/Emit/SemanticEdit.cs index 47fad96276d26..0c772ce0b7e54 100644 --- a/src/Compilers/Core/Portable/Emit/SemanticEdit.cs +++ b/src/Compilers/Core/Portable/Emit/SemanticEdit.cs @@ -6,6 +6,7 @@ using System.Collections.Immutable; using System.ComponentModel; using System.Diagnostics; +using System.Diagnostics.CodeAnalysis; using Microsoft.CodeAnalysis.Symbols; using Roslyn.Utilities; @@ -45,12 +46,6 @@ namespace Microsoft.CodeAnalysis.Emit /// public Func? SyntaxMap { get; } - /// - /// True if the edit is an update of the active method and local values - /// should be preserved; false otherwise. - /// - public bool PreserveLocalVariables { get; } - /// /// Instrumentation update to be applied to a method. /// If not empty, and must be non-null s, and @@ -59,12 +54,23 @@ namespace Microsoft.CodeAnalysis.Emit public MethodInstrumentation Instrumentation { get; } // 4.6 BACKCOMPAT OVERLOAD -- DO NOT TOUCH + [Obsolete("Use other overload")] [EditorBrowsable(EditorBrowsableState.Never)] public SemanticEdit(SemanticEditKind kind, ISymbol? oldSymbol, ISymbol? newSymbol, Func? syntaxMap, bool preserveLocalVariables) : this(kind, oldSymbol, newSymbol, syntaxMap, preserveLocalVariables, MethodInstrumentation.Empty) { } + // 4.8 BACKCOMPAT OVERLOAD -- DO NOT TOUCH +#pragma warning disable IDE0060 // Remove unused parameter + [Obsolete("Use other overload")] + [EditorBrowsable(EditorBrowsableState.Never)] + public SemanticEdit(SemanticEditKind kind, ISymbol? oldSymbol, ISymbol? newSymbol, Func? syntaxMap, bool preserveLocalVariables, MethodInstrumentation instrumentation) + : this(kind, oldSymbol, newSymbol, syntaxMap, MethodInstrumentation.Empty) + { + } +#pragma warning restore + /// /// Initializes an instance of . /// @@ -77,12 +83,8 @@ public SemanticEdit(SemanticEditKind kind, ISymbol? oldSymbol, ISymbol? newSymbo /// from the later compilation if is . /// /// - /// A map from syntax node in the later compilation to syntax node in the previous compilation, - /// or null if is false and the map is not needed or - /// the source of the current method is the same as the source of the previous method. - /// - /// - /// True if the edit is an update of an active method and local values should be preserved; false otherwise. + /// A map from syntax node in the later compilation to syntax node in the previous compilation, + /// or null if the method state (locals, closures, etc.) doesn't need to be preserved. /// /// /// Instrumentation update to be applied to a method. @@ -93,7 +95,7 @@ public SemanticEdit(SemanticEditKind kind, ISymbol? oldSymbol, ISymbol? newSymbo /// /// is not a valid kind. /// - public SemanticEdit(SemanticEditKind kind, ISymbol? oldSymbol, ISymbol? newSymbol, Func? syntaxMap = null, bool preserveLocalVariables = false, MethodInstrumentation instrumentation = default) + public SemanticEdit(SemanticEditKind kind, ISymbol? oldSymbol, ISymbol? newSymbol, Func? syntaxMap = null, MethodInstrumentation instrumentation = default) { if (kind <= SemanticEditKind.None || kind > SemanticEditKind.Replace) { @@ -110,15 +112,38 @@ public SemanticEdit(SemanticEditKind kind, ISymbol? oldSymbol, ISymbol? newSymbo throw new ArgumentNullException(nameof(newSymbol)); } - // Syntax map is only meaningful for update edits that preserve local variables. - Debug.Assert(syntaxMap == null || (kind == SemanticEditKind.Update && preserveLocalVariables)); + if (syntaxMap != null) + { + if (kind != SemanticEditKind.Update) + { + throw new ArgumentException("Syntax map can only be specified for updates", nameof(syntaxMap)); + } - // Partial methods should be implementations, not definitions. - Debug.Assert(oldSymbol is not IMethodSymbol { PartialImplementationPart: not null }); - Debug.Assert(newSymbol is not IMethodSymbol { PartialImplementationPart: not null }); + if (oldSymbol is not IMethodSymbol) + { + throw new ArgumentException(CodeAnalysisResources.MethodSymbolExpected, nameof(oldSymbol)); + } - // Check symbol kinds that can be deleted: - Debug.Assert(kind != SemanticEditKind.Delete || oldSymbol is IMethodSymbol or IPropertySymbol or IEventSymbol); + if (newSymbol is not IMethodSymbol) + { + throw new ArgumentException(CodeAnalysisResources.MethodSymbolExpected, nameof(newSymbol)); + } + } + + if (oldSymbol is IMethodSymbol { PartialImplementationPart: not null }) + { + throw new ArgumentException("Partial method implementation required", nameof(oldSymbol)); + } + + if (newSymbol is IMethodSymbol { PartialImplementationPart: not null }) + { + throw new ArgumentException("Partial method implementation required", nameof(newSymbol)); + } + + if (kind == SemanticEditKind.Delete && oldSymbol is not (IMethodSymbol or IPropertySymbol or IEventSymbol)) + { + throw new ArgumentException("Deleted symbol must be a method, property or an event", nameof(oldSymbol)); + } if (instrumentation.IsDefault) { @@ -154,11 +179,16 @@ public SemanticEdit(SemanticEditKind kind, ISymbol? oldSymbol, ISymbol? newSymbo Kind = kind; OldSymbol = oldSymbol; NewSymbol = newSymbol; - PreserveLocalVariables = preserveLocalVariables; SyntaxMap = syntaxMap; Instrumentation = instrumentation; } + /// + /// True if is not null. + /// + [MemberNotNullWhen(returnValue: true, nameof(SyntaxMap))] + public bool PreserveLocalVariables => SyntaxMap != null; + // for testing non-public instrumentation kinds internal SemanticEdit(IMethodSymbol oldSymbol, IMethodSymbol newSymbol, ImmutableArray instrumentationKinds) { @@ -169,8 +199,8 @@ internal SemanticEdit(IMethodSymbol oldSymbol, IMethodSymbol newSymbol, Immutabl } // for testing: - internal static SemanticEdit Create(SemanticEditKind kind, ISymbolInternal oldSymbol, ISymbolInternal newSymbol, Func? syntaxMap = null, bool preserveLocalVariables = false) - => new SemanticEdit(kind, oldSymbol?.GetISymbol(), newSymbol?.GetISymbol(), syntaxMap, preserveLocalVariables, instrumentation: default); + internal static SemanticEdit Create(SemanticEditKind kind, ISymbolInternal oldSymbol, ISymbolInternal newSymbol, Func? syntaxMap = null) + => new SemanticEdit(kind, oldSymbol?.GetISymbol(), newSymbol?.GetISymbol(), syntaxMap, instrumentation: default); public override int GetHashCode() => Hash.Combine(OldSymbol, Hash.Combine(NewSymbol, (int)Kind)); diff --git a/src/Compilers/Core/Portable/PublicAPI.Unshipped.txt b/src/Compilers/Core/Portable/PublicAPI.Unshipped.txt index 5ec679225ee7e..9c708d411c057 100644 --- a/src/Compilers/Core/Portable/PublicAPI.Unshipped.txt +++ b/src/Compilers/Core/Portable/PublicAPI.Unshipped.txt @@ -6,6 +6,9 @@ Microsoft.CodeAnalysis.Diagnostics.CompilationWithAnalyzers.CompilationWithAnalyzers(Microsoft.CodeAnalysis.Compilation! compilation, System.Collections.Immutable.ImmutableArray analyzers, Microsoft.CodeAnalysis.Diagnostics.AnalyzerOptions? options) -> void Microsoft.CodeAnalysis.Diagnostics.CompilationWithAnalyzers.GetAllDiagnosticsAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Threading.Tasks.Task>! Microsoft.CodeAnalysis.Diagnostics.CompilationWithAnalyzers.GetAnalyzerDiagnosticsAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Threading.Tasks.Task>! +*REMOVED*Microsoft.CodeAnalysis.Emit.SemanticEdit.SemanticEdit(Microsoft.CodeAnalysis.Emit.SemanticEditKind kind, Microsoft.CodeAnalysis.ISymbol? oldSymbol, Microsoft.CodeAnalysis.ISymbol? newSymbol, System.Func? syntaxMap = null, bool preserveLocalVariables = false, Microsoft.CodeAnalysis.Emit.MethodInstrumentation instrumentation = default(Microsoft.CodeAnalysis.Emit.MethodInstrumentation)) -> void +Microsoft.CodeAnalysis.Emit.SemanticEdit.SemanticEdit(Microsoft.CodeAnalysis.Emit.SemanticEditKind kind, Microsoft.CodeAnalysis.ISymbol? oldSymbol, Microsoft.CodeAnalysis.ISymbol? newSymbol, System.Func? syntaxMap, bool preserveLocalVariables, Microsoft.CodeAnalysis.Emit.MethodInstrumentation instrumentation) -> void +Microsoft.CodeAnalysis.Emit.SemanticEdit.SemanticEdit(Microsoft.CodeAnalysis.Emit.SemanticEditKind kind, Microsoft.CodeAnalysis.ISymbol? oldSymbol, Microsoft.CodeAnalysis.ISymbol? newSymbol, System.Func? syntaxMap = null, Microsoft.CodeAnalysis.Emit.MethodInstrumentation instrumentation = default(Microsoft.CodeAnalysis.Emit.MethodInstrumentation)) -> void static Microsoft.CodeAnalysis.Diagnostics.DiagnosticAnalyzerExtensions.WithAnalyzers(this Microsoft.CodeAnalysis.Compilation! compilation, System.Collections.Immutable.ImmutableArray analyzers, Microsoft.CodeAnalysis.Diagnostics.AnalyzerOptions? options = null) -> Microsoft.CodeAnalysis.Diagnostics.CompilationWithAnalyzers! static Microsoft.CodeAnalysis.Diagnostics.DiagnosticAnalyzerExtensions.WithAnalyzers(this Microsoft.CodeAnalysis.Compilation! compilation, System.Collections.Immutable.ImmutableArray analyzers, Microsoft.CodeAnalysis.Diagnostics.AnalyzerOptions? options, System.Threading.CancellationToken cancellationToken) -> Microsoft.CodeAnalysis.Diagnostics.CompilationWithAnalyzers! Microsoft.CodeAnalysis.RefKind.RefReadOnlyParameter = 4 -> Microsoft.CodeAnalysis.RefKind diff --git a/src/Compilers/VisualBasic/Test/Emit/Emit/EditAndContinue/AssemblyReferencesTests.vb b/src/Compilers/VisualBasic/Test/Emit/Emit/EditAndContinue/AssemblyReferencesTests.vb index 6ccf42cc29992..bea8476785320 100644 --- a/src/Compilers/VisualBasic/Test/Emit/Emit/EditAndContinue/AssemblyReferencesTests.vb +++ b/src/Compilers/VisualBasic/Test/Emit/Emit/EditAndContinue/AssemblyReferencesTests.vb @@ -466,7 +466,7 @@ End Class") ' First update adds some new synthesized members (lambda related) Dim diff1 = compilation1.EmitDifference( generation0, - ImmutableArray.Create(New SemanticEdit(SemanticEditKind.Update, m0, m1, GetSyntaxMapFromMarkers(source0, source1), preserveLocalVariables:=True))) + ImmutableArray.Create(New SemanticEdit(SemanticEditKind.Update, m0, m1, GetSyntaxMapFromMarkers(source0, source1)))) diff1.VerifySynthesizedMembers( "C: {_Closure$__}", @@ -475,7 +475,7 @@ End Class") ' Second update is to a method that doesn't produce any synthesized members Dim diff2 = compilation2.EmitDifference( diff1.NextGeneration, - ImmutableArray.Create(New SemanticEdit(SemanticEditKind.Update, f1, f2, GetSyntaxMapFromMarkers(source1, source2), preserveLocalVariables:=True))) + ImmutableArray.Create(New SemanticEdit(SemanticEditKind.Update, f1, f2, GetSyntaxMapFromMarkers(source1, source2)))) diff2.VerifySynthesizedMembers( "C: {_Closure$__}", @@ -487,7 +487,7 @@ End Class") ' hence we need to account for wildcards when comparing the versions. Dim diff3 = compilation3.EmitDifference( diff2.NextGeneration, - ImmutableArray.Create(New SemanticEdit(SemanticEditKind.Update, m2, m3, GetSyntaxMapFromMarkers(source2, source3), preserveLocalVariables:=True))) + ImmutableArray.Create(New SemanticEdit(SemanticEditKind.Update, m2, m3, GetSyntaxMapFromMarkers(source2, source3)))) diff3.VerifySynthesizedMembers( "C: {_Closure$__}", diff --git a/src/Compilers/VisualBasic/Test/Emit/Emit/EditAndContinue/EditAndContinueClosureTests.vb b/src/Compilers/VisualBasic/Test/Emit/Emit/EditAndContinue/EditAndContinueClosureTests.vb index 8adae4dd60223..849c4cd5d13ab 100644 --- a/src/Compilers/VisualBasic/Test/Emit/Emit/EditAndContinue/EditAndContinueClosureTests.vb +++ b/src/Compilers/VisualBasic/Test/Emit/Emit/EditAndContinue/EditAndContinueClosureTests.vb @@ -105,7 +105,7 @@ End Class Dim diff1 = compilation1.EmitDifference( generation0, - ImmutableArray.Create(New SemanticEdit(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1), preserveLocalVariables:=True))) + ImmutableArray.Create(New SemanticEdit(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1)))) ' no new synthesized members generated (with #1 in names): diff1.VerifySynthesizedMembers( @@ -156,7 +156,7 @@ End Class Dim diff1 = compilation1.EmitDifference( generation0, - ImmutableArray.Create(New SemanticEdit(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1), preserveLocalVariables:=True))) + ImmutableArray.Create(New SemanticEdit(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1)))) ' no new synthesized members generated (with #1 in names) diff1.VerifySynthesizedMembers( @@ -208,7 +208,7 @@ End Class Dim diff1 = compilation1.EmitDifference( generation0, - ImmutableArray.Create(New SemanticEdit(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1), preserveLocalVariables:=True))) + ImmutableArray.Create(New SemanticEdit(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1)))) ' no new synthesized members generated (with #1 in names) diff1.VerifySynthesizedMembers( @@ -261,7 +261,7 @@ End Class Dim diff1 = compilation1.EmitDifference( generation0, - ImmutableArray.Create(New SemanticEdit(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1), preserveLocalVariables:=True))) + ImmutableArray.Create(New SemanticEdit(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1)))) ' no new synthesized members generated (with #1 in names) diff1.VerifySynthesizedMembers( @@ -340,7 +340,7 @@ End Class Dim diff1 = compilation1.EmitDifference( generation0, - ImmutableArray.Create(New SemanticEdit(SemanticEditKind.Update, ctor0, ctor1, GetSyntaxMapFromMarkers(source0, source1), preserveLocalVariables:=True))) + ImmutableArray.Create(New SemanticEdit(SemanticEditKind.Update, ctor0, ctor1, GetSyntaxMapFromMarkers(source0, source1)))) ' no new synthesized members generated (with #1 in names) diff1.VerifySynthesizedMembers( @@ -424,7 +424,7 @@ End Module Dim diff1 = compilation1.EmitDifference( generation0, - ImmutableArray.Create(New SemanticEdit(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1), preserveLocalVariables:=True))) + ImmutableArray.Create(New SemanticEdit(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1)))) ' no new synthesized members generated (with #1 in names) diff1.VerifySynthesizedMembers( @@ -527,7 +527,7 @@ End Class Dim diff1 = compilation1.EmitDifference( generation0, - ImmutableArray.Create(New SemanticEdit(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1), preserveLocalVariables:=True))) + ImmutableArray.Create(New SemanticEdit(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1)))) Dim md1 = diff1.GetMetadata() Dim reader1 = md1.Reader @@ -621,7 +621,7 @@ End Class Dim diff1 = compilation1.EmitDifference( generation0, - ImmutableArray.Create(New SemanticEdit(SemanticEditKind.Update, ctor0, ctor1, GetSyntaxMapFromMarkers(source0, source1), preserveLocalVariables:=True))) + ImmutableArray.Create(New SemanticEdit(SemanticEditKind.Update, ctor0, ctor1, GetSyntaxMapFromMarkers(source0, source1)))) ' no new synthesized members generated (with #1 in names): diff1.VerifySynthesizedMembers( @@ -690,7 +690,7 @@ End Class Dim diff1 = compilation1.EmitDifference( generation0, - ImmutableArray.Create(New SemanticEdit(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1), preserveLocalVariables:=True))) + ImmutableArray.Create(New SemanticEdit(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1)))) ' no new synthesized members generated (with #1 in names) diff1.VerifySynthesizedMembers( @@ -763,7 +763,7 @@ End Class Dim diff1 = compilation1.EmitDifference( generation0, - ImmutableArray.Create(New SemanticEdit(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1), preserveLocalVariables:=True))) + ImmutableArray.Create(New SemanticEdit(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1)))) ' no new synthesized members generated (with #1 in names) diff1.VerifySynthesizedMembers( @@ -827,7 +827,7 @@ End Class Dim diff1 = compilation1.EmitDifference( generation0, - ImmutableArray.Create(New SemanticEdit(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1), preserveLocalVariables:=True))) + ImmutableArray.Create(New SemanticEdit(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1)))) ' no new synthesized members generated (with #1 in names) diff1.VerifySynthesizedMembers( @@ -893,7 +893,7 @@ End Class Dim diff1 = compilation1.EmitDifference( generation0, - ImmutableArray.Create(New SemanticEdit(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1), preserveLocalVariables:=True))) + ImmutableArray.Create(New SemanticEdit(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1)))) ' no new synthesized members generated (with #1 in names) diff1.VerifySynthesizedMembers( @@ -975,7 +975,7 @@ End Class Dim diff1 = compilation1.EmitDifference(generation0, ImmutableArray.Create( - New SemanticEdit(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1), preserveLocalVariables:=True))) + New SemanticEdit(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1)))) Dim md1 = diff1.GetMetadata() Dim reader1 = md1.Reader @@ -1001,7 +1001,7 @@ End Class ") Dim diff2 = compilation2.EmitDifference(diff1.NextGeneration, ImmutableArray.Create( - New SemanticEdit(SemanticEditKind.Update, f1, f2, GetSyntaxMapFromMarkers(source1, source2), preserveLocalVariables:=True))) + New SemanticEdit(SemanticEditKind.Update, f1, f2, GetSyntaxMapFromMarkers(source1, source2)))) diff2.VerifySynthesizedMembers( "C: {_Closure$__}", @@ -1090,7 +1090,7 @@ End Class Dim diff1 = compilation1.EmitDifference( generation0, - ImmutableArray.Create(New SemanticEdit(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1), preserveLocalVariables:=True))) + ImmutableArray.Create(New SemanticEdit(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1)))) Dim md1 = diff1.GetMetadata() Dim reader1 = md1.Reader @@ -1134,7 +1134,7 @@ End Class ") Dim diff2 = compilation2.EmitDifference( diff1.NextGeneration, - ImmutableArray.Create(New SemanticEdit(SemanticEditKind.Update, f1, f2, GetSyntaxMapFromMarkers(source1, source2), preserveLocalVariables:=True))) + ImmutableArray.Create(New SemanticEdit(SemanticEditKind.Update, f1, f2, GetSyntaxMapFromMarkers(source1, source2)))) diff2.VerifySynthesizedMembers( "C: {_Closure$__}", @@ -1190,7 +1190,7 @@ End Class ") Dim diff3 = compilation3.EmitDifference( diff2.NextGeneration, - ImmutableArray.Create(New SemanticEdit(SemanticEditKind.Update, f2, f3, GetSyntaxMapFromMarkers(source2, source3), preserveLocalVariables:=True))) + ImmutableArray.Create(New SemanticEdit(SemanticEditKind.Update, f2, f3, GetSyntaxMapFromMarkers(source2, source3)))) diff3.VerifySynthesizedMembers( "C: {_Closure$__}", @@ -1333,7 +1333,7 @@ End Class") Dim diff1 = compilation1.EmitDifference( generation0, - ImmutableArray.Create(New SemanticEdit(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1), preserveLocalVariables:=True))) + ImmutableArray.Create(New SemanticEdit(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1)))) Dim md1 = diff1.GetMetadata() Dim reader1 = md1.Reader @@ -1357,7 +1357,7 @@ End Class") Dim diff2 = compilation2.EmitDifference( diff1.NextGeneration, - ImmutableArray.Create(New SemanticEdit(SemanticEditKind.Update, f1, f2, GetSyntaxMapFromMarkers(source1, source2), preserveLocalVariables:=True))) + ImmutableArray.Create(New SemanticEdit(SemanticEditKind.Update, f1, f2, GetSyntaxMapFromMarkers(source1, source2)))) ' no new members diff2.VerifySynthesizedMembers( @@ -1545,8 +1545,8 @@ End Class Dim generation0 = CreateInitialBaseline(compilation0, md0, AddressOf v0.CreateSymReader().GetEncMethodDebugInfo) Dim diff1 = compilation1.EmitDifference(generation0, ImmutableArray.Create( - New SemanticEdit(SemanticEditKind.Update, ctor00, ctor01, GetSyntaxMapFromMarkers(source0, source1), preserveLocalVariables:=True), - New SemanticEdit(SemanticEditKind.Update, ctor10, ctor11, GetSyntaxMapFromMarkers(source0, source1), preserveLocalVariables:=True))) + New SemanticEdit(SemanticEditKind.Update, ctor00, ctor01, GetSyntaxMapFromMarkers(source0, source1)), + New SemanticEdit(SemanticEditKind.Update, ctor10, ctor11, GetSyntaxMapFromMarkers(source0, source1)))) Dim md1 = diff1.GetMetadata() @@ -1662,7 +1662,7 @@ End Class generation0, ImmutableArray.Create( New SemanticEdit(SemanticEditKind.Insert, Nothing, b1), - New SemanticEdit(SemanticEditKind.Update, ctor0, ctor1, GetSyntaxMapFromMarkers(source0, source1), preserveLocalVariables:=True))) + New SemanticEdit(SemanticEditKind.Update, ctor0, ctor1, GetSyntaxMapFromMarkers(source0, source1)))) diff1.VerifySynthesizedMembers( "C: {_Closure$__}", @@ -1847,7 +1847,7 @@ End Class Dim diff1 = compilation1.EmitDifference(generation0, ImmutableArray.Create( - New SemanticEdit(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1), preserveLocalVariables:=True))) + New SemanticEdit(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1)))) diff1.VerifySynthesizedMembers( "C: {_Closure$__, _Closure$__1-0}", @@ -1888,7 +1888,7 @@ End Class Dim diff2 = compilation2.EmitDifference(diff1.NextGeneration, ImmutableArray.Create( - New SemanticEdit(SemanticEditKind.Update, f1, f2, GetSyntaxMapFromMarkers(source1, source2), preserveLocalVariables:=True))) + New SemanticEdit(SemanticEditKind.Update, f1, f2, GetSyntaxMapFromMarkers(source1, source2)))) diff2.VerifySynthesizedMembers( "C: {_Closure$__, _Closure$__1-0}", @@ -2001,7 +2001,7 @@ End Class Dim diff1 = compilation1.EmitDifference(generation0, ImmutableArray.Create( - New SemanticEdit(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1), preserveLocalVariables:=True))) + New SemanticEdit(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1)))) diff1.VerifySynthesizedMembers( "C: {_Closure$__1-0}", @@ -2033,7 +2033,7 @@ End Class Dim diff2 = compilation2.EmitDifference(diff1.NextGeneration, ImmutableArray.Create( - New SemanticEdit(SemanticEditKind.Update, f1, f2, GetSyntaxMapFromMarkers(source1, source2), preserveLocalVariables:=True))) + New SemanticEdit(SemanticEditKind.Update, f1, f2, GetSyntaxMapFromMarkers(source1, source2)))) diff2.VerifySynthesizedMembers( "C: {_Closure$__1-0}", @@ -2122,7 +2122,7 @@ End Class Dim diff1 = compilation1.EmitDifference( generation0, ImmutableArray.Create( - New SemanticEdit(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1), preserveLocalVariables:=True))) + New SemanticEdit(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1)))) diff1.VerifySynthesizedMembers( "C: {_Closure$__1-0}", @@ -2133,7 +2133,7 @@ End Class Dim diff2 = compilation2.EmitDifference( diff1.NextGeneration, ImmutableArray.Create( - New SemanticEdit(SemanticEditKind.Update, f1, f2, GetSyntaxMapFromMarkers(source1, source2), preserveLocalVariables:=True))) + New SemanticEdit(SemanticEditKind.Update, f1, f2, GetSyntaxMapFromMarkers(source1, source2)))) diff2.VerifySynthesizedMembers( "C: {_Closure$__1-0}", @@ -2200,7 +2200,7 @@ End Class Dim diff1 = compilation1.EmitDifference( generation0, ImmutableArray.Create( - New SemanticEdit(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1), preserveLocalVariables:=True))) + New SemanticEdit(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1)))) diff1.VerifySynthesizedMembers( "C: {_Closure$__1-0}", @@ -2211,7 +2211,7 @@ End Class Dim diff2 = compilation2.EmitDifference( diff1.NextGeneration, ImmutableArray.Create( - New SemanticEdit(SemanticEditKind.Update, f1, f2, GetSyntaxMapFromMarkers(source1, source2), preserveLocalVariables:=True))) + New SemanticEdit(SemanticEditKind.Update, f1, f2, GetSyntaxMapFromMarkers(source1, source2)))) diff2.VerifySynthesizedMembers( "C: {_Closure$__1-0}", diff --git a/src/Compilers/VisualBasic/Test/Emit/Emit/EditAndContinue/EditAndContinuePdbTests.vb b/src/Compilers/VisualBasic/Test/Emit/Emit/EditAndContinue/EditAndContinuePdbTests.vb index f71f4f10d5b80..1ff1a442e99b8 100644 --- a/src/Compilers/VisualBasic/Test/Emit/Emit/EditAndContinue/EditAndContinuePdbTests.vb +++ b/src/Compilers/VisualBasic/Test/Emit/Emit/EditAndContinue/EditAndContinuePdbTests.vb @@ -151,8 +151,8 @@ End Class", fileName:="C:\Enc1.vb") Dim syntaxMap1 = GetSyntaxMapFromMarkers(source0, source1) Dim diff1 = compilation1.EmitDifference(generation0, - ImmutableArray.Create(New SemanticEdit(SemanticEditKind.Update, f0, f1, syntaxMap1, preserveLocalVariables:=True), - New SemanticEdit(SemanticEditKind.Update, g0, g1, syntaxMap1, preserveLocalVariables:=True))) + ImmutableArray.Create(New SemanticEdit(SemanticEditKind.Update, f0, f1, syntaxMap1), + New SemanticEdit(SemanticEditKind.Update, g0, g1, syntaxMap1))) diff1.VerifySynthesizedMembers( "C: {_Closure$__}", "C._Closure$__: {$I4-0, $I4-2, $I4-3#1, $I4-1, _Lambda$__4-0, _Lambda$__4-1, _Lambda$__4-2, _Lambda$__4-3#1}") @@ -251,9 +251,9 @@ End Class", fileName:="C:\Enc1.vb") Dim syntaxMap2 = GetSyntaxMapFromMarkers(source1, source2) Dim diff2 = compilation2.EmitDifference(diff1.NextGeneration, - ImmutableArray.Create(New SemanticEdit(SemanticEditKind.Update, f1, f2, syntaxMap2, preserveLocalVariables:=True), - New SemanticEdit(SemanticEditKind.Update, g1, g2, syntaxMap2, preserveLocalVariables:=True), - New SemanticEdit(SemanticEditKind.Update, a1, a2, syntaxMap2, preserveLocalVariables:=True), + ImmutableArray.Create(New SemanticEdit(SemanticEditKind.Update, f1, f2, syntaxMap2), + New SemanticEdit(SemanticEditKind.Update, g1, g2, syntaxMap2), + New SemanticEdit(SemanticEditKind.Update, a1, a2, syntaxMap2), New SemanticEdit(SemanticEditKind.Insert, Nothing, b2))) diff2.VerifySynthesizedMembers( diff --git a/src/Compilers/VisualBasic/Test/Emit/Emit/EditAndContinue/EditAndContinueStateMachineTests.vb b/src/Compilers/VisualBasic/Test/Emit/Emit/EditAndContinue/EditAndContinueStateMachineTests.vb index ce79766ca8690..121c12b2f7dd1 100644 --- a/src/Compilers/VisualBasic/Test/Emit/Emit/EditAndContinue/EditAndContinueStateMachineTests.vb +++ b/src/Compilers/VisualBasic/Test/Emit/Emit/EditAndContinue/EditAndContinueStateMachineTests.vb @@ -6,6 +6,7 @@ Imports System.Collections.Immutable Imports System.Reflection.Metadata.Ecma335 Imports Microsoft.CodeAnalysis.Emit Imports Microsoft.CodeAnalysis.Test.Utilities +Imports Microsoft.CodeAnalysis.VisualBasic.EditAndContinue.UnitTests Imports Microsoft.CodeAnalysis.VisualBasic.Symbols Imports Roslyn.Test.Utilities @@ -976,9 +977,9 @@ End Class Public Sub AsyncMethodOverloads() - Dim source0 = - - + Using New EditAndContinueTest(). + AddBaseline( + source:=" Imports System.Threading.Tasks Class C Async Function F(a As Integer) As Task(Of Integer) @@ -991,11 +992,12 @@ Class C Return Await Task.FromResult(1) End Function End Class - - - Dim source1 = - - +", + validator:= + Sub(g) + End Sub). + AddGeneration( + source:=" Imports System.Threading.Tasks Class C Async Function F(a As Long) As Task(Of Integer) @@ -1008,119 +1010,62 @@ Class C Return Await Task.FromResult(4) End Function End Class - - - - Dim compilation0 = CompilationUtils.CreateEmptyCompilationWithReferences(source0, references:=LatestVbReferences, options:=TestOptions.DebugDll) - Dim compilation1 = compilation0.WithSource(source1) - - Dim v0 = CompileAndVerify(compilation:=compilation0) - - Using md0 = ModuleMetadata.CreateFromImage(v0.EmittedAssemblyData) - Dim methodShort0 = compilation0.GetMembers("C.F").Single(Function(m) m.ToTestDisplayString() = "Function C.F(a As System.Int16) As System.Threading.Tasks.Task(Of System.Int32)") - Dim methodShort1 = compilation1.GetMembers("C.F").Single(Function(m) m.ToTestDisplayString() = "Function C.F(a As System.Int16) As System.Threading.Tasks.Task(Of System.Int32)") - - Dim methodInt0 = compilation0.GetMembers("C.F").Single(Function(m) m.ToTestDisplayString() = "Function C.F(a As System.Int32) As System.Threading.Tasks.Task(Of System.Int32)") - Dim methodInt1 = compilation1.GetMembers("C.F").Single(Function(m) m.ToTestDisplayString() = "Function C.F(a As System.Int32) As System.Threading.Tasks.Task(Of System.Int32)") - - Dim methodLong0 = compilation0.GetMembers("C.F").Single(Function(m) m.ToTestDisplayString() = "Function C.F(a As System.Int64) As System.Threading.Tasks.Task(Of System.Int32)") - Dim methodLong1 = compilation1.GetMembers("C.F").Single(Function(m) m.ToTestDisplayString() = "Function C.F(a As System.Int64) As System.Threading.Tasks.Task(Of System.Int32)") - - Dim generation0 = CreateInitialBaseline(compilation0, md0, AddressOf v0.CreateSymReader().GetEncMethodDebugInfo) - Dim diff1 = compilation1.EmitDifference( - generation0, - ImmutableArray.Create( - New SemanticEdit(SemanticEditKind.Update, methodShort0, methodShort1, preserveLocalVariables:=True), - New SemanticEdit(SemanticEditKind.Update, methodInt0, methodInt1, preserveLocalVariables:=True), - New SemanticEdit(SemanticEditKind.Update, methodLong0, methodLong1, preserveLocalVariables:=True))) - - Using md1 = diff1.GetMetadata() - ' notice no TypeDefs, FieldDefs - CheckEncLogDefinitions(md1.Reader, - Row(7, TableIndex.StandAloneSig, EditAndContinueOperation.Default), - Row(8, TableIndex.StandAloneSig, EditAndContinueOperation.Default), - Row(9, TableIndex.StandAloneSig, EditAndContinueOperation.Default), - Row(10, TableIndex.StandAloneSig, EditAndContinueOperation.Default), - Row(11, TableIndex.StandAloneSig, EditAndContinueOperation.Default), - Row(12, TableIndex.StandAloneSig, EditAndContinueOperation.Default), - Row(2, TableIndex.MethodDef, EditAndContinueOperation.Default), - Row(3, TableIndex.MethodDef, EditAndContinueOperation.Default), - Row(4, TableIndex.MethodDef, EditAndContinueOperation.Default), - Row(6, TableIndex.MethodDef, EditAndContinueOperation.Default), - Row(9, TableIndex.MethodDef, EditAndContinueOperation.Default), - Row(12, TableIndex.MethodDef, EditAndContinueOperation.Default), - Row(1, TableIndex.Param, EditAndContinueOperation.Default), - Row(2, TableIndex.Param, EditAndContinueOperation.Default), - Row(3, TableIndex.Param, EditAndContinueOperation.Default), - Row(4, TableIndex.CustomAttribute, EditAndContinueOperation.Default), - Row(5, TableIndex.CustomAttribute, EditAndContinueOperation.Default), - Row(6, TableIndex.CustomAttribute, EditAndContinueOperation.Default), - Row(7, TableIndex.CustomAttribute, EditAndContinueOperation.Default), - Row(9, TableIndex.CustomAttribute, EditAndContinueOperation.Default), - Row(10, TableIndex.CustomAttribute, EditAndContinueOperation.Default), - Row(13, TableIndex.CustomAttribute, EditAndContinueOperation.Default), - Row(15, TableIndex.CustomAttribute, EditAndContinueOperation.Default), - Row(17, TableIndex.CustomAttribute, EditAndContinueOperation.Default)) - End Using +", + edits:= + { + Edit(SemanticEditKind.Update, Function(c) c.GetMembers("C.F").Single(Function(m) m.ToTestDisplayString() = "Function C.F(a As System.Int16) As System.Threading.Tasks.Task(Of System.Int32)"), preserveLocalVariables:=True), + Edit(SemanticEditKind.Update, Function(c) c.GetMembers("C.F").Single(Function(m) m.ToTestDisplayString() = "Function C.F(a As System.Int32) As System.Threading.Tasks.Task(Of System.Int32)"), preserveLocalVariables:=True), + Edit(SemanticEditKind.Update, Function(c) c.GetMembers("C.F").Single(Function(m) m.ToTestDisplayString() = "Function C.F(a As System.Int64) As System.Threading.Tasks.Task(Of System.Int32)"), preserveLocalVariables:=True) + }, + validator:= + Sub(g) + ' notice no TypeDefs, FieldDefs + g.VerifyEncLogDefinitions( + { + Row(7, TableIndex.StandAloneSig, EditAndContinueOperation.Default), + Row(8, TableIndex.StandAloneSig, EditAndContinueOperation.Default), + Row(9, TableIndex.StandAloneSig, EditAndContinueOperation.Default), + Row(10, TableIndex.StandAloneSig, EditAndContinueOperation.Default), + Row(11, TableIndex.StandAloneSig, EditAndContinueOperation.Default), + Row(12, TableIndex.StandAloneSig, EditAndContinueOperation.Default), + Row(2, TableIndex.MethodDef, EditAndContinueOperation.Default), + Row(3, TableIndex.MethodDef, EditAndContinueOperation.Default), + Row(4, TableIndex.MethodDef, EditAndContinueOperation.Default), + Row(6, TableIndex.MethodDef, EditAndContinueOperation.Default), + Row(9, TableIndex.MethodDef, EditAndContinueOperation.Default), + Row(12, TableIndex.MethodDef, EditAndContinueOperation.Default), + Row(1, TableIndex.Param, EditAndContinueOperation.Default), + Row(2, TableIndex.Param, EditAndContinueOperation.Default), + Row(3, TableIndex.Param, EditAndContinueOperation.Default), + Row(4, TableIndex.CustomAttribute, EditAndContinueOperation.Default), + Row(5, TableIndex.CustomAttribute, EditAndContinueOperation.Default), + Row(6, TableIndex.CustomAttribute, EditAndContinueOperation.Default), + Row(7, TableIndex.CustomAttribute, EditAndContinueOperation.Default), + Row(9, TableIndex.CustomAttribute, EditAndContinueOperation.Default), + Row(10, TableIndex.CustomAttribute, EditAndContinueOperation.Default), + Row(13, TableIndex.CustomAttribute, EditAndContinueOperation.Default), + Row(15, TableIndex.CustomAttribute, EditAndContinueOperation.Default), + Row(17, TableIndex.CustomAttribute, EditAndContinueOperation.Default) + }) + End Sub). + Verify() End Using End Sub Public Sub UpdateIterator_NoVariables() - Dim source0 = - - -Imports System.Collections.Generic -Class C - Iterator Function F() As IEnumerable(Of Integer) - Yield 1 - End Function -End Class - - - Dim source1 = - - + Using New EditAndContinueTest(). + AddBaseline( + source:=" Imports System.Collections.Generic Class C Iterator Function F() As IEnumerable(Of Integer) - Yield 2 + Yield 1 End Function -End Class - - - - Dim compilation0 = CompilationUtils.CreateEmptyCompilationWithReferences(source0, references:=LatestVbReferences, options:=TestOptions.DebugDll) - Dim compilation1 = CompilationUtils.CreateEmptyCompilationWithReferences(source1, references:=LatestVbReferences, options:=TestOptions.DebugDll) - - Dim v0 = CompileAndVerify(compilation:=compilation0) - - Using md0 = ModuleMetadata.CreateFromImage(v0.EmittedAssemblyData) - Dim method0 = compilation0.GetMember(Of MethodSymbol)("C.F") - Dim method1 = compilation1.GetMember(Of MethodSymbol)("C.F") - - Dim generation0 = CreateInitialBaseline(compilation0, md0, EmptyLocalsProvider) - Dim diff1 = compilation1.EmitDifference( - generation0, - ImmutableArray.Create(New SemanticEdit(SemanticEditKind.Update, method0, method1, preserveLocalVariables:=True))) - - ' only methods with sequence points should be listed in UpdatedMethods: - diff1.VerifyUpdatedMethods("0x06000005") - - ' verify delta metadata contains expected rows - Using md1 = diff1.GetMetadata() - CheckEncLogDefinitions(md1.Reader, - Row(3, TableIndex.StandAloneSig, EditAndContinueOperation.Default), - Row(4, TableIndex.StandAloneSig, EditAndContinueOperation.Default), - Row(2, TableIndex.MethodDef, EditAndContinueOperation.Default), - Row(4, TableIndex.MethodDef, EditAndContinueOperation.Default), - Row(5, TableIndex.MethodDef, EditAndContinueOperation.Default), - Row(4, TableIndex.CustomAttribute, EditAndContinueOperation.Default), - Row(6, TableIndex.CustomAttribute, EditAndContinueOperation.Default), - Row(7, TableIndex.CustomAttribute, EditAndContinueOperation.Default)) - End Using - - diff1.VerifyIL("C.VB$StateMachine_1_F.MoveNext()", " +End Class", + validator:= + Sub(g) + g.VerifyIL("C.VB$StateMachine_1_F.MoveNext()", " { // Code size 63 (0x3f) .maxstack 3 @@ -1147,7 +1092,7 @@ End Class IL_001c: stfld ""C.VB$StateMachine_1_F.$State As Integer"" IL_0021: nop IL_0022: ldarg.0 - IL_0023: ldc.i4.2 + IL_0023: ldc.i4.1 IL_0024: stfld ""C.VB$StateMachine_1_F.$Current As Integer"" IL_0029: ldarg.0 IL_002a: ldc.i4.1 @@ -1165,7 +1110,33 @@ End Class IL_003e: ret } ") - v0.VerifyIL("C.VB$StateMachine_1_F.MoveNext()", " + End Sub). + AddGeneration( + source:=" +Imports System.Collections.Generic +Class C + Iterator Function F() As IEnumerable(Of Integer) + Yield 2 + End Function +End Class", + edits:={Edit(SemanticEditKind.Update, Function(c) c.GetMember("C.F"), preserveLocalVariables:=True)}, + validator:= + Sub(g) + g.VerifyUpdatedMethodNames("MoveNext") + + g.VerifyEncLogDefinitions( + { + Row(3, TableIndex.StandAloneSig, EditAndContinueOperation.Default), + Row(4, TableIndex.StandAloneSig, EditAndContinueOperation.Default), + Row(2, TableIndex.MethodDef, EditAndContinueOperation.Default), + Row(4, TableIndex.MethodDef, EditAndContinueOperation.Default), + Row(5, TableIndex.MethodDef, EditAndContinueOperation.Default), + Row(4, TableIndex.CustomAttribute, EditAndContinueOperation.Default), + Row(6, TableIndex.CustomAttribute, EditAndContinueOperation.Default), + Row(7, TableIndex.CustomAttribute, EditAndContinueOperation.Default) + }) + + g.VerifyIL("C.VB$StateMachine_1_F.MoveNext()", " { // Code size 63 (0x3f) .maxstack 3 @@ -1192,7 +1163,7 @@ End Class IL_001c: stfld ""C.VB$StateMachine_1_F.$State As Integer"" IL_0021: nop IL_0022: ldarg.0 - IL_0023: ldc.i4.1 + IL_0023: ldc.i4.2 IL_0024: stfld ""C.VB$StateMachine_1_F.$Current As Integer"" IL_0029: ldarg.0 IL_002a: ldc.i4.1 @@ -1210,66 +1181,147 @@ End Class IL_003e: ret } ") + End Sub). + Verify() End Using End Sub Public Sub UpdateAsync_NoVariables() - Dim source0 = - - + Using New EditAndContinueTest(). + AddBaseline( + source:=" Imports System.Threading.Tasks Class C Async Function F() As Task(Of Integer) - Await Task.FromResult(1) + Await Task.FromResult(1) Return 2 End Function -End Class - - - Dim source1 = - - +End Class", + validator:= + Sub(g) + g.VerifyIL("C.VB$StateMachine_1_F.MoveNext()", " +{ + // Code size 184 (0xb8) + .maxstack 3 + .locals init (Integer V_0, + Integer V_1, + System.Threading.Tasks.Task(Of Integer) V_2, + System.Runtime.CompilerServices.TaskAwaiter(Of Integer) V_3, + C.VB$StateMachine_1_F V_4, + System.Exception V_5) + IL_0000: ldarg.0 + IL_0001: ldfld ""C.VB$StateMachine_1_F.$State As Integer"" + IL_0006: stloc.1 + .try + { + IL_0007: ldloc.1 + IL_0008: brfalse.s IL_000c + IL_000a: br.s IL_000e + IL_000c: br.s IL_0049 + IL_000e: nop + IL_000f: ldc.i4.1 + IL_0010: call ""Function System.Threading.Tasks.Task.FromResult(Of Integer)(Integer) As System.Threading.Tasks.Task(Of Integer)"" + IL_0015: callvirt ""Function System.Threading.Tasks.Task(Of Integer).GetAwaiter() As System.Runtime.CompilerServices.TaskAwaiter(Of Integer)"" + IL_001a: stloc.3 + IL_001b: ldloca.s V_3 + IL_001d: call ""Function System.Runtime.CompilerServices.TaskAwaiter(Of Integer).get_IsCompleted() As Boolean"" + IL_0022: brtrue.s IL_0067 + IL_0024: ldarg.0 + IL_0025: ldc.i4.0 + IL_0026: dup + IL_0027: stloc.1 + IL_0028: stfld ""C.VB$StateMachine_1_F.$State As Integer"" + IL_002d: ldarg.0 + IL_002e: ldloc.3 + IL_002f: stfld ""C.VB$StateMachine_1_F.$A0 As System.Runtime.CompilerServices.TaskAwaiter(Of Integer)"" + IL_0034: ldarg.0 + IL_0035: ldflda ""C.VB$StateMachine_1_F.$Builder As System.Runtime.CompilerServices.AsyncTaskMethodBuilder(Of Integer)"" + IL_003a: ldloca.s V_3 + IL_003c: ldarg.0 + IL_003d: stloc.s V_4 + IL_003f: ldloca.s V_4 + IL_0041: call ""Sub System.Runtime.CompilerServices.AsyncTaskMethodBuilder(Of Integer).AwaitUnsafeOnCompleted(Of System.Runtime.CompilerServices.TaskAwaiter(Of Integer), C.VB$StateMachine_1_F)(ByRef System.Runtime.CompilerServices.TaskAwaiter(Of Integer), ByRef C.VB$StateMachine_1_F)"" + IL_0046: nop + IL_0047: leave.s IL_00b7 + IL_0049: ldarg.0 + IL_004a: ldc.i4.m1 + IL_004b: dup + IL_004c: stloc.1 + IL_004d: stfld ""C.VB$StateMachine_1_F.$State As Integer"" + IL_0052: ldarg.0 + IL_0053: ldfld ""C.VB$StateMachine_1_F.$A0 As System.Runtime.CompilerServices.TaskAwaiter(Of Integer)"" + IL_0058: stloc.3 + IL_0059: ldarg.0 + IL_005a: ldflda ""C.VB$StateMachine_1_F.$A0 As System.Runtime.CompilerServices.TaskAwaiter(Of Integer)"" + IL_005f: initobj ""System.Runtime.CompilerServices.TaskAwaiter(Of Integer)"" + IL_0065: br.s IL_0067 + IL_0067: ldloca.s V_3 + IL_0069: call ""Function System.Runtime.CompilerServices.TaskAwaiter(Of Integer).GetResult() As Integer"" + IL_006e: pop + IL_006f: ldloca.s V_3 + IL_0071: initobj ""System.Runtime.CompilerServices.TaskAwaiter(Of Integer)"" + IL_0077: ldc.i4.2 + IL_0078: stloc.0 + IL_0079: leave.s IL_00a0 + } + catch System.Exception + { + IL_007b: dup + IL_007c: call ""Sub Microsoft.VisualBasic.CompilerServices.ProjectData.SetProjectError(System.Exception)"" + IL_0081: stloc.s V_5 + IL_0083: ldarg.0 + IL_0084: ldc.i4.s -2 + IL_0086: stfld ""C.VB$StateMachine_1_F.$State As Integer"" + IL_008b: ldarg.0 + IL_008c: ldflda ""C.VB$StateMachine_1_F.$Builder As System.Runtime.CompilerServices.AsyncTaskMethodBuilder(Of Integer)"" + IL_0091: ldloc.s V_5 + IL_0093: call ""Sub System.Runtime.CompilerServices.AsyncTaskMethodBuilder(Of Integer).SetException(System.Exception)"" + IL_0098: nop + IL_0099: call ""Sub Microsoft.VisualBasic.CompilerServices.ProjectData.ClearProjectError()"" + IL_009e: leave.s IL_00b7 + } + IL_00a0: ldarg.0 + IL_00a1: ldc.i4.s -2 + IL_00a3: dup + IL_00a4: stloc.1 + IL_00a5: stfld ""C.VB$StateMachine_1_F.$State As Integer"" + IL_00aa: ldarg.0 + IL_00ab: ldflda ""C.VB$StateMachine_1_F.$Builder As System.Runtime.CompilerServices.AsyncTaskMethodBuilder(Of Integer)"" + IL_00b0: ldloc.0 + IL_00b1: call ""Sub System.Runtime.CompilerServices.AsyncTaskMethodBuilder(Of Integer).SetResult(Integer)"" + IL_00b6: nop + IL_00b7: ret +} +") + End Sub). + AddGeneration( + source:=" Imports System.Threading.Tasks Class C Async Function F() As Task(Of Integer) - Await Task.FromResult(10) + Await Task.FromResult(10) Return 20 End Function -End Class - - - - Dim compilation0 = CompilationUtils.CreateEmptyCompilationWithReferences(source0, references:=LatestVbReferences, options:=TestOptions.DebugDll) - Dim compilation1 = CompilationUtils.CreateEmptyCompilationWithReferences(source1, references:=LatestVbReferences, options:=TestOptions.DebugDll) - - Dim v0 = CompileAndVerify(compilation:=compilation0) - - Using md0 = ModuleMetadata.CreateFromImage(v0.EmittedAssemblyData) - Dim method0 = compilation0.GetMember(Of MethodSymbol)("C.F") - Dim method1 = compilation1.GetMember(Of MethodSymbol)("C.F") +End Class", + edits:={Edit(SemanticEditKind.Update, Function(c) c.GetMember("C.F"), preserveLocalVariables:=True)}, + validator:= + Sub(g) + ' only methods with sequence points should be listed in UpdatedMethods: + g.VerifyUpdatedMethodNames("MoveNext") - Dim generation0 = CreateInitialBaseline(compilation0, md0, EmptyLocalsProvider) - Dim diff1 = compilation1.EmitDifference( - generation0, - ImmutableArray.Create(New SemanticEdit(SemanticEditKind.Update, method0, method1, preserveLocalVariables:=True))) - - ' only methods with sequence points should be listed in UpdatedMethods: - diff1.VerifyUpdatedMethods("0x06000004") - - ' verify delta metadata contains expected rows - Using md1 = diff1.GetMetadata() - CheckEncLogDefinitions(md1.Reader, - Row(3, TableIndex.StandAloneSig, EditAndContinueOperation.Default), - Row(4, TableIndex.StandAloneSig, EditAndContinueOperation.Default), - Row(2, TableIndex.MethodDef, EditAndContinueOperation.Default), - Row(4, TableIndex.MethodDef, EditAndContinueOperation.Default), - Row(4, TableIndex.CustomAttribute, EditAndContinueOperation.Default), - Row(5, TableIndex.CustomAttribute, EditAndContinueOperation.Default), - Row(7, TableIndex.CustomAttribute, EditAndContinueOperation.Default)) - End Using + g.VerifyEncLogDefinitions( + { + Row(3, TableIndex.StandAloneSig, EditAndContinueOperation.Default), + Row(4, TableIndex.StandAloneSig, EditAndContinueOperation.Default), + Row(2, TableIndex.MethodDef, EditAndContinueOperation.Default), + Row(4, TableIndex.MethodDef, EditAndContinueOperation.Default), + Row(4, TableIndex.CustomAttribute, EditAndContinueOperation.Default), + Row(5, TableIndex.CustomAttribute, EditAndContinueOperation.Default), + Row(7, TableIndex.CustomAttribute, EditAndContinueOperation.Default) + }) - diff1.VerifyIL("C.VB$StateMachine_1_F.MoveNext()", " + g.VerifyIL("C.VB$StateMachine_1_F.MoveNext()", " { // Code size 186 (0xba) .maxstack 3 @@ -1363,100 +1415,8 @@ End Class IL_00b9: ret } ") - v0.VerifyIL("C.VB$StateMachine_1_F.MoveNext()", " -{ - // Code size 184 (0xb8) - .maxstack 3 - .locals init (Integer V_0, - Integer V_1, - System.Threading.Tasks.Task(Of Integer) V_2, - System.Runtime.CompilerServices.TaskAwaiter(Of Integer) V_3, - C.VB$StateMachine_1_F V_4, - System.Exception V_5) - IL_0000: ldarg.0 - IL_0001: ldfld ""C.VB$StateMachine_1_F.$State As Integer"" - IL_0006: stloc.1 - .try - { - IL_0007: ldloc.1 - IL_0008: brfalse.s IL_000c - IL_000a: br.s IL_000e - IL_000c: br.s IL_0049 - IL_000e: nop - IL_000f: ldc.i4.1 - IL_0010: call ""Function System.Threading.Tasks.Task.FromResult(Of Integer)(Integer) As System.Threading.Tasks.Task(Of Integer)"" - IL_0015: callvirt ""Function System.Threading.Tasks.Task(Of Integer).GetAwaiter() As System.Runtime.CompilerServices.TaskAwaiter(Of Integer)"" - IL_001a: stloc.3 - IL_001b: ldloca.s V_3 - IL_001d: call ""Function System.Runtime.CompilerServices.TaskAwaiter(Of Integer).get_IsCompleted() As Boolean"" - IL_0022: brtrue.s IL_0067 - IL_0024: ldarg.0 - IL_0025: ldc.i4.0 - IL_0026: dup - IL_0027: stloc.1 - IL_0028: stfld ""C.VB$StateMachine_1_F.$State As Integer"" - IL_002d: ldarg.0 - IL_002e: ldloc.3 - IL_002f: stfld ""C.VB$StateMachine_1_F.$A0 As System.Runtime.CompilerServices.TaskAwaiter(Of Integer)"" - IL_0034: ldarg.0 - IL_0035: ldflda ""C.VB$StateMachine_1_F.$Builder As System.Runtime.CompilerServices.AsyncTaskMethodBuilder(Of Integer)"" - IL_003a: ldloca.s V_3 - IL_003c: ldarg.0 - IL_003d: stloc.s V_4 - IL_003f: ldloca.s V_4 - IL_0041: call ""Sub System.Runtime.CompilerServices.AsyncTaskMethodBuilder(Of Integer).AwaitUnsafeOnCompleted(Of System.Runtime.CompilerServices.TaskAwaiter(Of Integer), C.VB$StateMachine_1_F)(ByRef System.Runtime.CompilerServices.TaskAwaiter(Of Integer), ByRef C.VB$StateMachine_1_F)"" - IL_0046: nop - IL_0047: leave.s IL_00b7 - IL_0049: ldarg.0 - IL_004a: ldc.i4.m1 - IL_004b: dup - IL_004c: stloc.1 - IL_004d: stfld ""C.VB$StateMachine_1_F.$State As Integer"" - IL_0052: ldarg.0 - IL_0053: ldfld ""C.VB$StateMachine_1_F.$A0 As System.Runtime.CompilerServices.TaskAwaiter(Of Integer)"" - IL_0058: stloc.3 - IL_0059: ldarg.0 - IL_005a: ldflda ""C.VB$StateMachine_1_F.$A0 As System.Runtime.CompilerServices.TaskAwaiter(Of Integer)"" - IL_005f: initobj ""System.Runtime.CompilerServices.TaskAwaiter(Of Integer)"" - IL_0065: br.s IL_0067 - IL_0067: ldloca.s V_3 - IL_0069: call ""Function System.Runtime.CompilerServices.TaskAwaiter(Of Integer).GetResult() As Integer"" - IL_006e: pop - IL_006f: ldloca.s V_3 - IL_0071: initobj ""System.Runtime.CompilerServices.TaskAwaiter(Of Integer)"" - IL_0077: ldc.i4.2 - IL_0078: stloc.0 - IL_0079: leave.s IL_00a0 - } - catch System.Exception - { - IL_007b: dup - IL_007c: call ""Sub Microsoft.VisualBasic.CompilerServices.ProjectData.SetProjectError(System.Exception)"" - IL_0081: stloc.s V_5 - IL_0083: ldarg.0 - IL_0084: ldc.i4.s -2 - IL_0086: stfld ""C.VB$StateMachine_1_F.$State As Integer"" - IL_008b: ldarg.0 - IL_008c: ldflda ""C.VB$StateMachine_1_F.$Builder As System.Runtime.CompilerServices.AsyncTaskMethodBuilder(Of Integer)"" - IL_0091: ldloc.s V_5 - IL_0093: call ""Sub System.Runtime.CompilerServices.AsyncTaskMethodBuilder(Of Integer).SetException(System.Exception)"" - IL_0098: nop - IL_0099: call ""Sub Microsoft.VisualBasic.CompilerServices.ProjectData.ClearProjectError()"" - IL_009e: leave.s IL_00b7 - } - IL_00a0: ldarg.0 - IL_00a1: ldc.i4.s -2 - IL_00a3: dup - IL_00a4: stloc.1 - IL_00a5: stfld ""C.VB$StateMachine_1_F.$State As Integer"" - IL_00aa: ldarg.0 - IL_00ab: ldflda ""C.VB$StateMachine_1_F.$Builder As System.Runtime.CompilerServices.AsyncTaskMethodBuilder(Of Integer)"" - IL_00b0: ldloc.0 - IL_00b1: call ""Sub System.Runtime.CompilerServices.AsyncTaskMethodBuilder(Of Integer).SetResult(Integer)"" - IL_00b6: nop - IL_00b7: ret -} -") + End Sub). + Verify() End Using End Sub @@ -1524,7 +1484,7 @@ End Class") Dim generation0 = CreateInitialBaseline(compilation0, md0, Function(handle) v0.CreateSymReader().GetEncMethodDebugInfo(handle)) Dim diff1 = compilation1.EmitDifference( generation0, - ImmutableArray.Create(New SemanticEdit(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1), preserveLocalVariables:=True))) + ImmutableArray.Create(New SemanticEdit(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1)))) v0.VerifyPdb("C.F", " @@ -1973,11 +1933,11 @@ End Class") Dim generation0 = CreateInitialBaseline(compilation0, md0, Function(handle) v0.CreateSymReader().GetEncMethodDebugInfo(handle)) Dim diff1 = compilation1.EmitDifference( generation0, - ImmutableArray.Create(New SemanticEdit(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1), preserveLocalVariables:=True))) + ImmutableArray.Create(New SemanticEdit(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1)))) Dim diff2 = compilation2.EmitDifference( diff1.NextGeneration, - ImmutableArray.Create(New SemanticEdit(SemanticEditKind.Update, f1, f2, GetSyntaxMapFromMarkers(source1, source2), preserveLocalVariables:=True))) + ImmutableArray.Create(New SemanticEdit(SemanticEditKind.Update, f1, f2, GetSyntaxMapFromMarkers(source1, source2)))) v0.VerifyPdb("C.F", " @@ -2571,7 +2531,7 @@ End Class") Dim diff1 = compilation1.EmitDifference( generation0, ImmutableArray.Create( - SemanticEdit.Create(SemanticEditKind.Update, ctor0, ctor1, GetSyntaxMapFromMarkers(source0, source1), preserveLocalVariables:=True))) + SemanticEdit.Create(SemanticEditKind.Update, ctor0, ctor1, GetSyntaxMapFromMarkers(source0, source1)))) v0.VerifyPdb("C..ctor", @@ -3031,7 +2991,7 @@ End Class") Dim generation0 = CreateInitialBaseline(compilation0, md0, Function(handle) v0.CreateSymReader().GetEncMethodDebugInfo(handle)) Dim diff1 = compilation1.EmitDifference( generation0, - ImmutableArray.Create(New SemanticEdit(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1), preserveLocalVariables:=True))) + ImmutableArray.Create(New SemanticEdit(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1)))) diff1.VerifyIL("C.VB$StateMachine_5_F.MoveNext", " { @@ -3200,7 +3160,7 @@ End Try Dim generation0 = CreateInitialBaseline(compilation0, md0, Function(handle) v0.CreateSymReader().GetEncMethodDebugInfo(handle)) Dim diff1 = compilation1.EmitDifference( generation0, - ImmutableArray.Create(New SemanticEdit(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1), preserveLocalVariables:=True))) + ImmutableArray.Create(New SemanticEdit(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1)))) v0.VerifyIL("C.VB$StateMachine_8_F.MoveNext", " { @@ -3588,7 +3548,7 @@ End Class") Dim generation0 = CreateInitialBaseline(compilation0, md0, Function(handle) symReader.GetEncMethodDebugInfo(handle)) Dim diff1 = compilation1.EmitDifference( generation0, - ImmutableArray.Create(New SemanticEdit(SemanticEditKind.Update, method0, method1, GetSyntaxMapFromMarkers(source0, source1), preserveLocalVariables:=True))) + ImmutableArray.Create(New SemanticEdit(SemanticEditKind.Update, method0, method1, GetSyntaxMapFromMarkers(source0, source1)))) ' only methods with sequence points should be listed in UpdatedMethods: diff1.VerifyUpdatedMethods("0x06000005") @@ -3693,7 +3653,7 @@ End Class") Dim generation0 = CreateInitialBaseline(compilation0, md0, Function(handle) symReader.GetEncMethodDebugInfo(handle)) Dim diff1 = compilation1.EmitDifference( generation0, - ImmutableArray.Create(New SemanticEdit(SemanticEditKind.Update, method0, method1, GetSyntaxMapFromMarkers(source0, source1), preserveLocalVariables:=True))) + ImmutableArray.Create(New SemanticEdit(SemanticEditKind.Update, method0, method1, GetSyntaxMapFromMarkers(source0, source1)))) ' only methods with sequence points should be listed in UpdatedMethods: diff1.VerifyUpdatedMethods("0x06000005") @@ -3803,7 +3763,7 @@ End Class") Dim generation0 = CreateInitialBaseline(compilation0, md0, Function(handle) symReader.GetEncMethodDebugInfo(handle)) Dim diff1 = compilation1.EmitDifference( generation0, - ImmutableArray.Create(New SemanticEdit(SemanticEditKind.Update, method0, method1, GetSyntaxMapFromMarkers(source0, source1), preserveLocalVariables:=True))) + ImmutableArray.Create(New SemanticEdit(SemanticEditKind.Update, method0, method1, GetSyntaxMapFromMarkers(source0, source1)))) ' only methods with sequence points should be listed in UpdatedMethods: diff1.VerifyUpdatedMethods("0x06000005") @@ -3909,7 +3869,7 @@ End Class") Dim generation0 = CreateInitialBaseline(compilation0, md0, Function(handle) symReader.GetEncMethodDebugInfo(handle)) Dim diff1 = compilation1.EmitDifference( generation0, - ImmutableArray.Create(New SemanticEdit(SemanticEditKind.Update, method0, method1, GetSyntaxMapFromMarkers(source0, source1), preserveLocalVariables:=True))) + ImmutableArray.Create(New SemanticEdit(SemanticEditKind.Update, method0, method1, GetSyntaxMapFromMarkers(source0, source1)))) ' only methods with sequence points should be listed in UpdatedMethods: diff1.VerifyUpdatedMethods("0x06000005") @@ -4042,7 +4002,7 @@ End Class") Dim generation0 = CreateInitialBaseline(compilation0, md0, Function(handle) symReader.GetEncMethodDebugInfo(handle)) Dim diff1 = compilation1.EmitDifference( generation0, - ImmutableArray.Create(New SemanticEdit(SemanticEditKind.Update, method0, method1, GetSyntaxMapFromMarkers(source0, source1), preserveLocalVariables:=True))) + ImmutableArray.Create(New SemanticEdit(SemanticEditKind.Update, method0, method1, GetSyntaxMapFromMarkers(source0, source1)))) ' only methods with sequence points should be listed in UpdatedMethods: diff1.VerifyUpdatedMethods("0x06000005") @@ -4209,7 +4169,7 @@ End Class" Dim generation0 = CreateInitialBaseline(compilation0, md0, Function(handle) v0.CreateSymReader().GetEncMethodDebugInfo(handle)) Dim diff1 = compilation1.EmitDifference( generation0, - ImmutableArray.Create(New SemanticEdit(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1), preserveLocalVariables:=True))) + ImmutableArray.Create(New SemanticEdit(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1)))) v0.VerifyPdb("C.F", " @@ -4470,7 +4430,7 @@ End Class" Dim generation0 = CreateInitialBaseline(compilation0, md0, Function(handle) v0.CreateSymReader().GetEncMethodDebugInfo(handle)) Dim diff1 = compilation1.EmitDifference( generation0, - ImmutableArray.Create(New SemanticEdit(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1), preserveLocalVariables:=True))) + ImmutableArray.Create(New SemanticEdit(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1)))) diff1.VerifyIL("C.VB$StateMachine_6_F.MoveNext", " { @@ -4636,7 +4596,7 @@ End Class") Dim diff1 = compilation1.EmitDifference( generation0, ImmutableArray.Create( - SemanticEdit.Create(SemanticEditKind.Update, ctor0, ctor1, GetSyntaxMapFromMarkers(source0, source1), preserveLocalVariables:=True))) + SemanticEdit.Create(SemanticEditKind.Update, ctor0, ctor1, GetSyntaxMapFromMarkers(source0, source1)))) v0.VerifyPdb("C..ctor", @@ -4963,7 +4923,7 @@ End Try Dim generation0 = CreateInitialBaseline(compilation0, md0, Function(handle) v0.CreateSymReader().GetEncMethodDebugInfo(handle)) Dim diff1 = compilation1.EmitDifference( generation0, - ImmutableArray.Create(New SemanticEdit(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1), preserveLocalVariables:=True))) + ImmutableArray.Create(New SemanticEdit(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1)))) v0.VerifyPdb("C.F", " @@ -5465,7 +5425,7 @@ End Using Dim generation0 = CreateInitialBaseline(compilation0, md0, Function(handle) v0.CreateSymReader().GetEncMethodDebugInfo(handle)) Dim diff1 = compilation1.EmitDifference( generation0, - ImmutableArray.Create(New SemanticEdit(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1), preserveLocalVariables:=True))) + ImmutableArray.Create(New SemanticEdit(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1)))) v0.VerifyPdb("C.F", " @@ -5904,7 +5864,7 @@ End SyncLock Dim generation0 = CreateInitialBaseline(compilation0, md0, Function(handle) v0.CreateSymReader().GetEncMethodDebugInfo(handle)) Dim diff1 = compilation1.EmitDifference( generation0, - ImmutableArray.Create(New SemanticEdit(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1), preserveLocalVariables:=True))) + ImmutableArray.Create(New SemanticEdit(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1)))) v0.VerifyPdb("C.F", " @@ -6361,7 +6321,7 @@ End Class") Dim generation0 = CreateInitialBaseline(compilation0, md0, Function(handle) symReader.GetEncMethodDebugInfo(handle)) Dim diff1 = compilation1.EmitDifference( generation0, - ImmutableArray.Create(New SemanticEdit(SemanticEditKind.Update, method0, method1, GetSyntaxMapFromMarkers(source0, source1), preserveLocalVariables:=True))) + ImmutableArray.Create(New SemanticEdit(SemanticEditKind.Update, method0, method1, GetSyntaxMapFromMarkers(source0, source1)))) ' only methods with sequence points should be listed in UpdatedMethods: diff1.VerifyUpdatedMethods("0x06000004") @@ -6514,7 +6474,7 @@ End Class") Dim generation0 = CreateInitialBaseline(compilation0, md0, Function(handle) symReader.GetEncMethodDebugInfo(handle)) Dim diff1 = compilation1.EmitDifference( generation0, - ImmutableArray.Create(New SemanticEdit(SemanticEditKind.Update, method0, method1, GetSyntaxMapFromMarkers(source0, source1), preserveLocalVariables:=True))) + ImmutableArray.Create(New SemanticEdit(SemanticEditKind.Update, method0, method1, GetSyntaxMapFromMarkers(source0, source1)))) ' only methods with sequence points should be listed in UpdatedMethods: diff1.VerifyUpdatedMethods("0x06000004") @@ -6672,7 +6632,7 @@ End Class") Dim generation0 = CreateInitialBaseline(compilation0, md0, Function(handle) symReader.GetEncMethodDebugInfo(handle)) Dim diff1 = compilation1.EmitDifference( generation0, - ImmutableArray.Create(New SemanticEdit(SemanticEditKind.Update, method0, method1, GetSyntaxMapFromMarkers(source0, source1), preserveLocalVariables:=True))) + ImmutableArray.Create(New SemanticEdit(SemanticEditKind.Update, method0, method1, GetSyntaxMapFromMarkers(source0, source1)))) ' only methods with sequence points should be listed in UpdatedMethods: diff1.VerifyUpdatedMethods("0x06000004") @@ -6826,7 +6786,7 @@ End Class") Dim generation0 = CreateInitialBaseline(compilation0, md0, Function(handle) symReader.GetEncMethodDebugInfo(handle)) Dim diff1 = compilation1.EmitDifference( generation0, - ImmutableArray.Create(New SemanticEdit(SemanticEditKind.Update, method0, method1, GetSyntaxMapFromMarkers(source0, source1), preserveLocalVariables:=True))) + ImmutableArray.Create(New SemanticEdit(SemanticEditKind.Update, method0, method1, GetSyntaxMapFromMarkers(source0, source1)))) ' only methods with sequence points should be listed in UpdatedMethods: diff1.VerifyUpdatedMethods("0x06000004") @@ -7085,8 +7045,8 @@ End Class") Dim diff1 = compilation1.EmitDifference( generation0, ImmutableArray.Create( - New SemanticEdit(SemanticEditKind.Update, f0, f1, syntaxMap1, preserveLocalVariables:=True), - New SemanticEdit(SemanticEditKind.Update, g0, g1, syntaxMap1, preserveLocalVariables:=True))) + New SemanticEdit(SemanticEditKind.Update, f0, f1, syntaxMap1), + New SemanticEdit(SemanticEditKind.Update, g0, g1, syntaxMap1))) diff1.VerifySynthesizedMembers( "C: {VB$StateMachine_1_F, VB$StateMachine_2_G}", @@ -7097,7 +7057,7 @@ End Class") Dim diff2 = compilation2.EmitDifference( diff1.NextGeneration, ImmutableArray.Create( - New SemanticEdit(SemanticEditKind.Update, f1, f2, syntaxMap2, preserveLocalVariables:=True))) + New SemanticEdit(SemanticEditKind.Update, f1, f2, syntaxMap2))) diff2.VerifySynthesizedMembers( "C: {VB$StateMachine_1_F, VB$StateMachine_2_G}", @@ -7108,8 +7068,8 @@ End Class") Dim diff3 = compilation3.EmitDifference( diff2.NextGeneration, ImmutableArray.Create( - New SemanticEdit(SemanticEditKind.Update, g2, g3, syntaxMap3, preserveLocalVariables:=True), - New SemanticEdit(SemanticEditKind.Update, h2, h3, syntaxMap3, preserveLocalVariables:=True))) + New SemanticEdit(SemanticEditKind.Update, g2, g3, syntaxMap3), + New SemanticEdit(SemanticEditKind.Update, h2, h3, syntaxMap3))) diff3.VerifySynthesizedMembers( "C: {VB$StateMachine_2_G, VB$StateMachine_3_H, VB$StateMachine_1_F}", @@ -7586,8 +7546,8 @@ End Class") Dim diff1 = compilation1.EmitDifference( generation0, ImmutableArray.Create( - New SemanticEdit(SemanticEditKind.Update, f0, f1, syntaxMap1, preserveLocalVariables:=True), - New SemanticEdit(SemanticEditKind.Update, g0, g1, syntaxMap1, preserveLocalVariables:=True))) + New SemanticEdit(SemanticEditKind.Update, f0, f1, syntaxMap1), + New SemanticEdit(SemanticEditKind.Update, g0, g1, syntaxMap1))) diff1.VerifySynthesizedMembers( "C: {VB$StateMachine_4_F, VB$StateMachine_5_G}", @@ -7598,7 +7558,7 @@ End Class") Dim diff2 = compilation2.EmitDifference( diff1.NextGeneration, ImmutableArray.Create( - New SemanticEdit(SemanticEditKind.Update, f1, f2, syntaxMap2, preserveLocalVariables:=True))) + New SemanticEdit(SemanticEditKind.Update, f1, f2, syntaxMap2))) diff2.VerifySynthesizedMembers( "C: {VB$StateMachine_4_F, VB$StateMachine_5_G}", @@ -7609,8 +7569,8 @@ End Class") Dim diff3 = compilation3.EmitDifference( diff2.NextGeneration, ImmutableArray.Create( - New SemanticEdit(SemanticEditKind.Update, g2, g3, syntaxMap3, preserveLocalVariables:=True), - New SemanticEdit(SemanticEditKind.Update, h2, h3, syntaxMap3, preserveLocalVariables:=True))) + New SemanticEdit(SemanticEditKind.Update, g2, g3, syntaxMap3), + New SemanticEdit(SemanticEditKind.Update, h2, h3, syntaxMap3))) diff3.VerifySynthesizedMembers( "C: {VB$StateMachine_5_G, VB$StateMachine_6_H, VB$StateMachine_4_F}", @@ -8063,7 +8023,7 @@ End Class Dim diff2 = compilation2.EmitDifference( diff1.NextGeneration, ImmutableArray.Create( - New SemanticEdit(SemanticEditKind.Update, f1, f2, GetSyntaxMapByKind(f1, SyntaxKind.FunctionBlock), preserveLocalVariables:=True))) + New SemanticEdit(SemanticEditKind.Update, f1, f2, GetSyntaxMapByKind(f1, SyntaxKind.FunctionBlock)))) diff2.VerifySynthesizedMembers( "C: {VB$StateMachine_1#1_F}", @@ -8192,7 +8152,7 @@ End Class") Dim diff1 = compilation1.EmitDifference( generation0, ImmutableArray.Create( - New SemanticEdit(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1), preserveLocalVariables:=True))) + New SemanticEdit(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1)))) ' note that the types of the awaiter fields $A0, $A1 are the same as in the previous generation diff1.VerifySynthesizedFields("C._Closure$__.VB$StateMachine___Lambda$__1-0", @@ -8205,7 +8165,7 @@ End Class") Dim diff2 = compilation2.EmitDifference( diff1.NextGeneration, ImmutableArray.Create( - New SemanticEdit(SemanticEditKind.Update, f1, f2, GetSyntaxMapFromMarkers(source1, source2), preserveLocalVariables:=True))) + New SemanticEdit(SemanticEditKind.Update, f1, f2, GetSyntaxMapFromMarkers(source1, source2)))) ' note that the types of the awaiter fields $A0, $A1 are the same as in the previous generation diff2.VerifySynthesizedFields("C._Closure$__.VB$StateMachine___Lambda$__1-0", @@ -8319,7 +8279,7 @@ End Class") Dim diff1 = compilation1.EmitDifference( generation0, ImmutableArray.Create( - SemanticEdit.Create(SemanticEditKind.Update, m0, m1, GetSyntaxMapFromMarkers(source0, source1), preserveLocalVariables:=True))) + SemanticEdit.Create(SemanticEditKind.Update, m0, m1, GetSyntaxMapFromMarkers(source0, source1)))) ' Notice that we reused field "$VB$ResumableLocal_$VB$Closure_$0" (there is no "$VB$ResumableLocal_$VB$Closure_$1"), which stores the closure pointer. diff1.VerifySynthesizedMembers( @@ -8429,7 +8389,7 @@ End Class") Dim diff1 = compilation1.EmitDifference( generation0, ImmutableArray.Create( - SemanticEdit.Create(SemanticEditKind.Update, m0, m1, GetSyntaxMapFromMarkers(source0, source1), preserveLocalVariables:=True))) + SemanticEdit.Create(SemanticEditKind.Update, m0, m1, GetSyntaxMapFromMarkers(source0, source1)))) ' Notice that we reused field "$W0" (there is no "$W1"), which stores the closure pointer. diff1.VerifySynthesizedMembers( @@ -8550,7 +8510,7 @@ End Class Dim diff1 = compilation1.EmitDifference( generation0, ImmutableArray.Create( - New SemanticEdit(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1), preserveLocalVariables:=True))) + New SemanticEdit(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1)))) diff1.VerifySynthesizedMembers( "C: {VB$StateMachine_1_F}", @@ -8561,7 +8521,7 @@ End Class Dim diff2 = compilation2.EmitDifference( diff1.NextGeneration, ImmutableArray.Create( - New SemanticEdit(SemanticEditKind.Update, f1, f2, GetSyntaxMapFromMarkers(source1, source2), preserveLocalVariables:=True))) + New SemanticEdit(SemanticEditKind.Update, f1, f2, GetSyntaxMapFromMarkers(source1, source2)))) diff2.VerifySynthesizedMembers( "C: {VB$StateMachine_1_F}", @@ -8691,7 +8651,7 @@ End Class Dim diff1 = compilation1.EmitDifference( generation0, ImmutableArray.Create( - New SemanticEdit(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1), preserveLocalVariables:=True))) + New SemanticEdit(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1)))) diff1.VerifySynthesizedMembers( "C: {VB$StateMachine_1_F}", @@ -8702,7 +8662,7 @@ End Class Dim diff2 = compilation2.EmitDifference( diff1.NextGeneration, ImmutableArray.Create( - New SemanticEdit(SemanticEditKind.Update, f1, f2, GetSyntaxMapFromMarkers(source1, source2), preserveLocalVariables:=True))) + New SemanticEdit(SemanticEditKind.Update, f1, f2, GetSyntaxMapFromMarkers(source1, source2)))) diff2.VerifySynthesizedMembers( "C: {VB$StateMachine_1_F}", @@ -8764,7 +8724,7 @@ End Class Dim diff1 = compilation1.EmitDifference( generation0, ImmutableArray.Create( - New SemanticEdit(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1), preserveLocalVariables:=True))) + New SemanticEdit(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1)))) diff1.VerifySynthesizedMembers( "C: {VB$StateMachine_1_F, _Closure$__}", @@ -8775,7 +8735,7 @@ End Class Dim diff2 = compilation2.EmitDifference( diff1.NextGeneration, ImmutableArray.Create( - New SemanticEdit(SemanticEditKind.Update, f1, f2, GetSyntaxMapFromMarkers(source1, source2), preserveLocalVariables:=True))) + New SemanticEdit(SemanticEditKind.Update, f1, f2, GetSyntaxMapFromMarkers(source1, source2)))) ' Synthesized members collection still includes y field since members are only added to it and never deleted. ' The corresponding CLR field is also present. @@ -8788,7 +8748,7 @@ End Class Dim diff3 = compilation3.EmitDifference( diff2.NextGeneration, ImmutableArray.Create( - New SemanticEdit(SemanticEditKind.Update, f2, f3, GetSyntaxMapFromMarkers(source2, source3), preserveLocalVariables:=True))) + New SemanticEdit(SemanticEditKind.Update, f2, f3, GetSyntaxMapFromMarkers(source2, source3)))) diff3.VerifySynthesizedMembers( "C: {VB$StateMachine_1_F, _Closure$__}", @@ -8799,7 +8759,7 @@ End Class Dim diff4 = compilation4.EmitDifference( diff3.NextGeneration, ImmutableArray.Create( - New SemanticEdit(SemanticEditKind.Update, f3, f4, GetSyntaxMapFromMarkers(source3, source4), preserveLocalVariables:=True))) + New SemanticEdit(SemanticEditKind.Update, f3, f4, GetSyntaxMapFromMarkers(source3, source4)))) diff4.VerifySynthesizedMembers( "C: {VB$StateMachine_1_F, _Closure$__}", @@ -8810,7 +8770,7 @@ End Class Dim diff5 = compilation5.EmitDifference( diff4.NextGeneration, ImmutableArray.Create( - New SemanticEdit(SemanticEditKind.Update, f4, f5, GetSyntaxMapFromMarkers(source4, source5), preserveLocalVariables:=True))) + New SemanticEdit(SemanticEditKind.Update, f4, f5, GetSyntaxMapFromMarkers(source4, source5)))) diff5.VerifySynthesizedMembers( "C: {VB$StateMachine_1_F, _Closure$__}", @@ -8859,7 +8819,7 @@ End Class Dim generation0 = CreateInitialBaseline(compilation0, md0, AddressOf v0.CreateSymReader().GetEncMethodDebugInfo) Dim diff1 = compilation1.EmitDifference( generation0, - ImmutableArray.Create(New SemanticEdit(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1), preserveLocalVariables:=True))) + ImmutableArray.Create(New SemanticEdit(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1)))) diff1.EmitResult.Diagnostics.Verify( Diagnostic(ERRID.ERR_EncUpdateFailedMissingAttribute, "F").WithArguments("Public Function F() As IEnumerable(Of Integer)", "System.Runtime.CompilerServices.IteratorStateMachineAttribute").WithLocation(6, 30)) @@ -8917,7 +8877,7 @@ End Class Dim generation0 = CreateInitialBaseline(compilation0, md0, AddressOf v0.CreateSymReader().GetEncMethodDebugInfo) Dim diff1 = compilation1.EmitDifference( generation0, - ImmutableArray.Create(New SemanticEdit(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1), preserveLocalVariables:=True))) + ImmutableArray.Create(New SemanticEdit(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1)))) diff1.EmitResult.Diagnostics.Verify( Diagnostic(ERRID.ERR_EncUpdateFailedMissingAttribute, "F").WithArguments("Public Function F() As IEnumerable(Of Integer)", "System.Runtime.CompilerServices.IteratorStateMachineAttribute").WithLocation(12, 30)) @@ -8975,7 +8935,7 @@ End Class generation0, ImmutableArray.Create( New SemanticEdit(SemanticEditKind.Insert, Nothing, ism1), - New SemanticEdit(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1), preserveLocalVariables:=True))) + New SemanticEdit(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1)))) diff1.EmitResult.Diagnostics.Verify() End Sub @@ -9035,7 +8995,7 @@ End Class Dim generation0 = CreateInitialBaseline(compilation0, md0, AddressOf v0.CreateSymReader().GetEncMethodDebugInfo) Dim diff1 = compilation1.EmitDifference( generation0, - ImmutableArray.Create(New SemanticEdit(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1), preserveLocalVariables:=True))) + ImmutableArray.Create(New SemanticEdit(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1)))) diff1.EmitResult.Diagnostics.Verify() End Sub @@ -9088,7 +9048,7 @@ End Class Dim generation0 = CreateInitialBaseline(compilation0, md0, AddressOf v0.CreateSymReader().GetEncMethodDebugInfo) Dim diff1 = compilation1.EmitDifference( generation0, - ImmutableArray.Create(New SemanticEdit(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1), preserveLocalVariables:=True))) + ImmutableArray.Create(New SemanticEdit(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1)))) diff1.EmitResult.Diagnostics.Verify( Diagnostic(ERRID.ERR_EncUpdateFailedMissingAttribute, "F").WithArguments("Public Function F() As Task(Of Integer)", "System.Runtime.CompilerServices.AsyncStateMachineAttribute").WithLocation(15, 27)) @@ -9126,7 +9086,7 @@ End Class Dim generation0 = CreateInitialBaseline(compilation0, md0, AddressOf v0.CreateSymReader().GetEncMethodDebugInfo) Dim diff1 = compilation1.EmitDifference( generation0, - ImmutableArray.Create(New SemanticEdit(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1), preserveLocalVariables:=True))) + ImmutableArray.Create(New SemanticEdit(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1)))) diff1.EmitResult.Diagnostics.Verify() End Sub @@ -9165,7 +9125,7 @@ End Class Dim generation0 = CreateInitialBaseline(compilation0, md0, AddressOf v0.CreateSymReader().GetEncMethodDebugInfo) Dim diff1 = compilation1.EmitDifference( generation0, - ImmutableArray.Create(New SemanticEdit(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1), preserveLocalVariables:=True))) + ImmutableArray.Create(New SemanticEdit(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1)))) diff1.EmitResult.Diagnostics.Verify( Diagnostic(ERRID.ERR_EncUpdateFailedMissingAttribute, "F").WithArguments("Public Function F() As Task(Of Integer)", "System.Runtime.CompilerServices.AsyncStateMachineAttribute").WithLocation(15, 27)) @@ -9204,7 +9164,7 @@ End Class Dim generation0 = CreateInitialBaseline(compilation0, md0, AddressOf v0.CreateSymReader().GetEncMethodDebugInfo) Dim diff1 = compilation1.EmitDifference( generation0, - ImmutableArray.Create(New SemanticEdit(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1), preserveLocalVariables:=True))) + ImmutableArray.Create(New SemanticEdit(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1)))) diff1.EmitResult.Diagnostics.Verify( Diagnostic(ERRID.ERR_EncUpdateFailedMissingAttribute, "F").WithArguments("Public Function F() As IEnumerable(Of Integer)", "System.Runtime.CompilerServices.IteratorStateMachineAttribute").WithLocation(5, 30)) diff --git a/src/Compilers/VisualBasic/Test/Emit/Emit/EditAndContinue/EditAndContinueTest.vb b/src/Compilers/VisualBasic/Test/Emit/Emit/EditAndContinue/EditAndContinueTest.vb index 5f4f649e95544..c6baeca616c75 100644 --- a/src/Compilers/VisualBasic/Test/Emit/Emit/EditAndContinue/EditAndContinueTest.vb +++ b/src/Compilers/VisualBasic/Test/Emit/Emit/EditAndContinue/EditAndContinueTest.vb @@ -16,10 +16,12 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.EditAndContinue.UnitTests Private ReadOnly _options As VisualBasicCompilationOptions Private ReadOnly _parseOptions As VisualBasicParseOptions Private ReadOnly _targetFramework As TargetFramework + Private ReadOnly _references As IEnumerable(Of MetadataReference) Sub New(Optional options As VisualBasicCompilationOptions = Nothing, Optional parseOptions As VisualBasicParseOptions = Nothing, Optional targetFramework As TargetFramework = TargetFramework.StandardAndVBRuntime, + Optional references As IEnumerable(Of MetadataReference) = Nothing, Optional verification As Verification? = Nothing) MyBase.New(verification) @@ -27,10 +29,11 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.EditAndContinue.UnitTests _options = If(options, TestOptions.DebugDll).WithConcurrentBuild(False) _parseOptions = If(parseOptions, TestOptions.Regular) _targetFramework = targetFramework + _references = references End Sub Protected Overrides Function CreateCompilation(tree As SyntaxTree) As Compilation - Return CompilationUtils.CreateCompilation(tree, options:=_options, targetFramework:=_targetFramework) + Return CompilationUtils.CreateCompilation(tree, _references, options:=_options, targetFramework:=_targetFramework) End Function Protected Overrides Function CreateSourceWithMarkedNodes(source As String) As SourceWithMarkedNodes diff --git a/src/Compilers/VisualBasic/Test/Emit/Emit/EditAndContinue/EditAndContinueTests.vb b/src/Compilers/VisualBasic/Test/Emit/Emit/EditAndContinue/EditAndContinueTests.vb index 6c3eb7852cb36..42d674d001463 100644 --- a/src/Compilers/VisualBasic/Test/Emit/Emit/EditAndContinue/EditAndContinueTests.vb +++ b/src/Compilers/VisualBasic/Test/Emit/Emit/EditAndContinue/EditAndContinueTests.vb @@ -11,9 +11,7 @@ Imports Microsoft.CodeAnalysis.CodeGen Imports Microsoft.CodeAnalysis.Emit Imports Microsoft.CodeAnalysis.Test.Utilities Imports Microsoft.CodeAnalysis.VisualBasic.EditAndContinue.UnitTests -Imports Microsoft.CodeAnalysis.VisualBasic.Emit Imports Microsoft.CodeAnalysis.VisualBasic.Symbols -Imports Roslyn.Test.MetadataUtilities Imports Roslyn.Test.Utilities Namespace Microsoft.CodeAnalysis.VisualBasic.UnitTests @@ -62,14 +60,14 @@ End Class ' Semantic errors are reported only for the bodies of members being emitted. Dim diffError = compilation1.EmitDifference( generation0, - ImmutableArray.Create(New SemanticEdit(SemanticEditKind.Update, e0, e1, GetSyntaxMapFromMarkers(source0, source1), preserveLocalVariables:=True))) + ImmutableArray.Create(New SemanticEdit(SemanticEditKind.Update, e0, e1, GetSyntaxMapFromMarkers(source0, source1)))) diffError.EmitResult.Diagnostics.Verify( Diagnostic(ERRID.ERR_NameNotDeclared1, "Unknown").WithArguments("Unknown").WithLocation(4, 17)) Dim diffGood = compilation1.EmitDifference( generation0, - ImmutableArray.Create(New SemanticEdit(SemanticEditKind.Update, g0, g1, GetSyntaxMapFromMarkers(source0, source1), preserveLocalVariables:=True))) + ImmutableArray.Create(New SemanticEdit(SemanticEditKind.Update, g0, g1, GetSyntaxMapFromMarkers(source0, source1)))) diffGood.EmitResult.Diagnostics.Verify() diffGood.VerifyIL("C.G", " @@ -116,7 +114,7 @@ End Class Dim diff = compilation1.EmitDifference( generation0, - ImmutableArray.Create(New SemanticEdit(SemanticEditKind.Update, g0, g1, GetSyntaxMapFromMarkers(source0, source1), preserveLocalVariables:=True))) + ImmutableArray.Create(New SemanticEdit(SemanticEditKind.Update, g0, g1, GetSyntaxMapFromMarkers(source0, source1)))) diff.EmitResult.Diagnostics.Verify( Diagnostic(ERRID.ERR_TypeInItsInheritsClause1, "Bad").WithArguments("Bad").WithLocation(9, 12)) @@ -802,7 +800,7 @@ End Class Dim diff1 = compilation1.EmitDifference( generation0, ImmutableArray.Create( - New SemanticEdit(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1), preserveLocalVariables:=True))) + New SemanticEdit(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1)))) diff1.VerifyIL("C.F", " { @@ -1114,7 +1112,7 @@ End Class Dim method1 = compilation1.GetMember(Of MethodSymbol)("C.M") Dim diff1 = compilation1.EmitDifference( generation0, - ImmutableArray.Create(New SemanticEdit(SemanticEditKind.Update, method0, method1, GetEquivalentNodesMap(method1, method0), preserveLocalVariables:=True))) + ImmutableArray.Create(New SemanticEdit(SemanticEditKind.Update, method0, method1, GetEquivalentNodesMap(method1, method0)))) diff1.VerifyIL("C.M", Public Sub EventFields() - Dim source0 = MarkedSource(" + Using New EditAndContinueTest(). + AddBaseline( + source:=" Imports System Class C @@ -1330,8 +1330,13 @@ Class C Return 1 End Function End Class -") - Dim source1 = MarkedSource(" +", + validator:= + Sub() + + End Sub). + AddGeneration( + source:=" Imports System Class C @@ -1342,26 +1347,11 @@ Class C Return 10 End Function End Class -") - Dim compilation0 = CreateCompilationWithMscorlib40(source0.Tree, options:=ComSafeDebugDll) - - compilation0.AssertNoDiagnostics() - - Dim compilation1 = compilation0.WithSource(source1.Tree) - - Dim f0 = compilation0.GetMember(Of MethodSymbol)("C.F") - Dim f1 = compilation1.GetMember(Of MethodSymbol)("C.F") - - Dim v0 = CompileAndVerify(compilation0) - Dim md0 = ModuleMetadata.CreateFromImage(v0.EmittedAssemblyData) - - Dim generation0 = CreateInitialBaseline(compilation0, md0, AddressOf v0.CreateSymReader().GetEncMethodDebugInfo) - Dim diff1 = compilation1.EmitDifference( - generation0, - ImmutableArray.Create( - New SemanticEdit(SemanticEditKind.Update, f0, f1, preserveLocalVariables:=True))) - - diff1.VerifyIL("C.F", " +", + edits:={Edit(SemanticEditKind.Update, Function(c) c.GetMember("C.F"), preserveLocalVariables:=True)}, + validator:= + Sub(g) + g.VerifyIL("C.F", " { // Code size 26 (0x1a) .maxstack 3 @@ -1385,6 +1375,9 @@ End Class IL_0019: ret } ") + End Sub). + Verify() + End Using End Sub @@ -2013,7 +2006,7 @@ End Class Dim method1 = compilation1.GetMember(Of MethodSymbol)("C.M") Dim diff1 = compilation1.EmitDifference( generation0, - ImmutableArray.Create(New SemanticEdit(SemanticEditKind.Update, method0, method1, syntaxMap:=Function(s) Nothing, preserveLocalVariables:=True))) + ImmutableArray.Create(New SemanticEdit(SemanticEditKind.Update, method0, method1, syntaxMap:=Function(s) Nothing))) Using md1 = diff1.GetMetadata() Dim reader1 = md1.Reader Dim readers = {reader0, reader1} @@ -2102,7 +2095,7 @@ End Module Dim diff1 = compilation1.EmitDifference( generation0, - ImmutableArray.Create(New SemanticEdit(SemanticEditKind.Insert, Nothing, method1, preserveLocalVariables:=True))) + ImmutableArray.Create(New SemanticEdit(SemanticEditKind.Insert, Nothing, method1))) Using md1 = diff1.GetMetadata() Dim reader1 = md1.Reader @@ -2162,7 +2155,7 @@ End Module Dim diff1 = compilation1.EmitDifference( generation0, - ImmutableArray.Create(New SemanticEdit(SemanticEditKind.Update, getter0, getter1, preserveLocalVariables:=True))) + ImmutableArray.Create(New SemanticEdit(SemanticEditKind.Update, getter0, getter1))) diff1.VerifyIL("Module1.get_P", " { @@ -2634,7 +2627,7 @@ End Class Dim diff1 = compilation1.EmitDifference( generation0, - ImmutableArray.Create(New SemanticEdit(SemanticEditKind.Update, method0, method1, preserveLocalVariables:=True))) + ImmutableArray.Create(New SemanticEdit(SemanticEditKind.Update, method0, method1))) diff1.VerifyIL("C.M", " { @@ -2799,7 +2792,7 @@ End Class Dim diff1 = compilation1.EmitDifference( generation0, - ImmutableArray.Create(New SemanticEdit(SemanticEditKind.Update, method0, method1, GetEquivalentNodesMap(method1, method0), preserveLocalVariables:=True))) + ImmutableArray.Create(New SemanticEdit(SemanticEditKind.Update, method0, method1, GetEquivalentNodesMap(method1, method0)))) diff1.VerifyIL(" { @@ -2853,7 +2846,7 @@ End Class Dim diff2 = compilation2.EmitDifference( diff1.NextGeneration, - ImmutableArray.Create(New SemanticEdit(SemanticEditKind.Update, method1, method2, GetEquivalentNodesMap(method2, method1), preserveLocalVariables:=True))) + ImmutableArray.Create(New SemanticEdit(SemanticEditKind.Update, method1, method2, GetEquivalentNodesMap(method2, method1)))) diff2.VerifyIL(" { @@ -2910,7 +2903,7 @@ End Class Dim diff3 = compilation3.EmitDifference( diff2.NextGeneration, - ImmutableArray.Create(New SemanticEdit(SemanticEditKind.Update, method2, method3, GetEquivalentNodesMap(method3, method2), preserveLocalVariables:=True))) + ImmutableArray.Create(New SemanticEdit(SemanticEditKind.Update, method2, method3, GetEquivalentNodesMap(method3, method2)))) diff3.VerifyIL(" { @@ -3001,12 +2994,12 @@ End Class Dim method1 = compilation1.GetMember(Of MethodSymbol)("C.M") Dim diff1 = compilation1.EmitDifference( generation0, - ImmutableArray.Create(New SemanticEdit(SemanticEditKind.Insert, Nothing, method1, Nothing, preserveLocalVariables:=True))) + ImmutableArray.Create(New SemanticEdit(SemanticEditKind.Insert, Nothing, method1, Nothing))) Dim method2 = compilation2.GetMember(Of MethodSymbol)("C.M") Dim diff2 = compilation2.EmitDifference( diff1.NextGeneration, - ImmutableArray.Create(New SemanticEdit(SemanticEditKind.Update, method1, method2, GetEquivalentNodesMap(method2, method1), preserveLocalVariables:=True))) + ImmutableArray.Create(New SemanticEdit(SemanticEditKind.Update, method1, method2, GetEquivalentNodesMap(method2, method1)))) diff2.VerifyIL("C.M", Public Sub PreserveLocalSlotsImplicitNamedArgXml() - Dim sources0 = - ) 'does not declare qq - qq = 5 - Dim aa = qq + Shared Sub M(o As Object) + F(qq:=) 'does not declare qq + qq = 5 + Dim aa = qq End Sub -End Class -]]> - - - Dim compilation0 = CreateCompilationWithMscorlib40AndVBRuntimeAndReferences(sources0, XmlReferences, TestOptions.DebugDll) - Dim compilation1 = compilation0.Clone() - - Dim testData0 = New CompilationTestData() - Dim bytes0 = compilation0.EmitToArray(testData:=testData0) +End Class" - Dim actualIL0 = testData0.GetMethodData("C.M").GetMethodIL() - Dim expectedIL0 = - .Value - - AssertEx.AssertEqualToleratingWhitespaceDifferences(expectedIL0, actualIL0) - - Dim method0 = compilation0.GetMember(Of MethodSymbol)("C.M") - Dim method1 = compilation1.GetMember(Of MethodSymbol)("C.M") - - Dim generation0 = CreateInitialBaseline(compilation0, ModuleMetadata.CreateFromImage(bytes0), testData0.GetMethodData("C.M").EncDebugInfoProvider) - - Dim edit = New SemanticEdit(SemanticEditKind.Update, method0, method1, preserveLocalVariables:=True) - Dim diff1 = compilation1.EmitDifference( - generation0, - ImmutableArray.Create(edit)) - - diff1.VerifyIL("C.M", .Value) +") + End Sub). + Verify() + End Using End Sub @@ -4680,7 +4663,7 @@ End Class ") Dim diff1 = compilation1.EmitDifference(generation0, ImmutableArray.Create( - New SemanticEdit(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1), preserveLocalVariables:=True))) + New SemanticEdit(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1)))) diff1.VerifyIL("C.F", " { @@ -4700,7 +4683,7 @@ End Class Dim diff2 = compilation2.EmitDifference(diff1.NextGeneration, ImmutableArray.Create( - New SemanticEdit(SemanticEditKind.Update, f1, f2, GetSyntaxMapFromMarkers(source1, source2), preserveLocalVariables:=True))) + New SemanticEdit(SemanticEditKind.Update, f1, f2, GetSyntaxMapFromMarkers(source1, source2)))) diff2.VerifyIL("C.F", " { @@ -4756,7 +4739,7 @@ End Class Dim diff1 = compilation1.EmitDifference(generation0, ImmutableArray.Create( - New SemanticEdit(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1), preserveLocalVariables:=True))) + New SemanticEdit(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1)))) diff1.VerifyIL("C.F", " { @@ -4772,7 +4755,7 @@ End Class ") Dim diff2 = compilation2.EmitDifference(diff1.NextGeneration, ImmutableArray.Create( - New SemanticEdit(SemanticEditKind.Update, f1, f2, GetSyntaxMapFromMarkers(source1, source2), preserveLocalVariables:=True))) + New SemanticEdit(SemanticEditKind.Update, f1, f2, GetSyntaxMapFromMarkers(source1, source2)))) diff2.VerifyIL("C.F", " { @@ -4856,7 +4839,7 @@ End Namespace Dim method1 = compilation1.GetMember(Of MethodSymbol)("M.B.M") Dim diff1 = compilation1.EmitDifference( generation0, - ImmutableArray.Create(New SemanticEdit(SemanticEditKind.Update, method0, method1, GetEquivalentNodesMap(method1, method0), preserveLocalVariables:=True))) + ImmutableArray.Create(New SemanticEdit(SemanticEditKind.Update, method0, method1, GetEquivalentNodesMap(method1, method0)))) Using md1 = diff1.GetMetadata() Dim reader1 = md1.Reader @@ -4978,7 +4961,7 @@ End Class Dim diff1 = compilation1.EmitDifference( generation0, - ImmutableArray.Create(New SemanticEdit(SemanticEditKind.Update, method0, method1, GetSyntaxMapFromMarkers(source0, source1), preserveLocalVariables:=True))) + ImmutableArray.Create(New SemanticEdit(SemanticEditKind.Update, method0, method1, GetSyntaxMapFromMarkers(source0, source1)))) Dim md1 = diff1.GetMetadata() Dim reader1 = md1.Reader @@ -5005,7 +4988,7 @@ End Class ") Dim diff2 = compilation2.EmitDifference( diff1.NextGeneration, - ImmutableArray.Create(New SemanticEdit(SemanticEditKind.Update, method1, method2, GetSyntaxMapFromMarkers(source1, source2), preserveLocalVariables:=True))) + ImmutableArray.Create(New SemanticEdit(SemanticEditKind.Update, method1, method2, GetSyntaxMapFromMarkers(source1, source2)))) Dim md2 = diff2.GetMetadata() Dim reader2 = md2.Reader @@ -5037,7 +5020,7 @@ End Class Dim diff3 = compilation3.EmitDifference( diff2.NextGeneration, - ImmutableArray.Create(New SemanticEdit(SemanticEditKind.Update, method2, method3, GetSyntaxMapFromMarkers(source2, source3), preserveLocalVariables:=True))) + ImmutableArray.Create(New SemanticEdit(SemanticEditKind.Update, method2, method3, GetSyntaxMapFromMarkers(source2, source3)))) Dim md3 = diff3.GetMetadata() Dim reader3 = md3.Reader @@ -5157,7 +5140,7 @@ End Class Dim method1G = compilation1.GetMember(Of MethodSymbol)("C.G") Dim diff1 = compilation1.EmitDifference( generation0, - ImmutableArray.Create(New SemanticEdit(SemanticEditKind.Update, method0F, method1F, GetEquivalentNodesMap(method1F, method0F), preserveLocalVariables:=True))) + ImmutableArray.Create(New SemanticEdit(SemanticEditKind.Update, method0F, method1F, GetEquivalentNodesMap(method1F, method0F)))) Using md1 = diff1.GetMetadata() Dim reader1 = md1.Reader CheckNames({reader0, reader1}, reader1.GetTypeDefNames(), "VB$AnonymousType_1`2") ' one additional type @@ -5165,7 +5148,7 @@ End Class Dim method2G = compilation2.GetMember(Of MethodSymbol)("C.G") Dim diff2 = compilation2.EmitDifference( diff1.NextGeneration, - ImmutableArray.Create(New SemanticEdit(SemanticEditKind.Update, method1G, method2G, GetEquivalentNodesMap(method2G, method1G), preserveLocalVariables:=True))) + ImmutableArray.Create(New SemanticEdit(SemanticEditKind.Update, method1G, method2G, GetEquivalentNodesMap(method2G, method1G)))) Using md2 = diff2.GetMetadata() Dim reader2 = md2.Reader CheckNames({reader0, reader1, reader2}, reader2.GetTypeDefNames()) ' no additional types @@ -5173,7 +5156,7 @@ End Class Dim method3G = compilation3.GetMember(Of MethodSymbol)("C.G") Dim diff3 = compilation3.EmitDifference( diff2.NextGeneration, - ImmutableArray.Create(New SemanticEdit(SemanticEditKind.Update, method2G, method3G, GetEquivalentNodesMap(method3G, method2G), preserveLocalVariables:=True))) + ImmutableArray.Create(New SemanticEdit(SemanticEditKind.Update, method2G, method3G, GetEquivalentNodesMap(method3G, method2G)))) Using md3 = diff3.GetMetadata() Dim reader3 = md3.Reader CheckNames({reader0, reader1, reader2, reader3}, reader3.GetTypeDefNames()) ' no additional types @@ -5226,7 +5209,7 @@ End Class Dim method1 = compilation1.GetMember(Of MethodSymbol)("C.M") Dim diff1 = compilation1.EmitDifference( generation0, - ImmutableArray.Create(New SemanticEdit(SemanticEditKind.Update, method0, method1, GetEquivalentNodesMap(method1, method0), preserveLocalVariables:=True))) + ImmutableArray.Create(New SemanticEdit(SemanticEditKind.Update, method0, method1, GetEquivalentNodesMap(method1, method0)))) Using md1 = diff1.GetMetadata() Dim reader1 = md1.Reader CheckNames({reader0, reader1}, reader1.GetTypeDefNames(), "VB$AnonymousType_3`2") @@ -5308,7 +5291,7 @@ End Class Dim method1 = compilation1.GetMember(Of MethodSymbol)("C.M") Dim diff1 = compilation1.EmitDifference( generation0, - ImmutableArray.Create(New SemanticEdit(SemanticEditKind.Update, method0, method1, GetEquivalentNodesMap(method1, method0), preserveLocalVariables:=True))) + ImmutableArray.Create(New SemanticEdit(SemanticEditKind.Update, method0, method1, GetEquivalentNodesMap(method1, method0)))) Using md1 = diff1.GetMetadata() Dim reader1 = md1.Reader CheckNames({reader0, reader1}, reader1.GetTypeDefNames(), "VB$AnonymousType_1`1") @@ -5337,7 +5320,7 @@ End Class Dim method2 = compilation2.GetMember(Of MethodSymbol)("C.M") Dim diff2 = compilation2.EmitDifference( diff1.NextGeneration, - ImmutableArray.Create(New SemanticEdit(SemanticEditKind.Update, method1, method2, GetEquivalentNodesMap(method2, method1), preserveLocalVariables:=True))) + ImmutableArray.Create(New SemanticEdit(SemanticEditKind.Update, method1, method2, GetEquivalentNodesMap(method2, method1)))) Using md2 = diff2.GetMetadata() Dim reader2 = md2.Reader CheckNames({reader0, reader1, reader2}, reader2.GetTypeDefNames()) @@ -5461,7 +5444,7 @@ End Class Dim diff1 = compilation1.EmitDifference( generation0, ImmutableArray.Create( - New SemanticEdit(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1), preserveLocalVariables:=True))) + New SemanticEdit(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1)))) diff1.VerifySynthesizedMembers( "C: {_Closure$__}", @@ -5472,7 +5455,7 @@ End Class Dim diff2 = compilation2.EmitDifference( diff1.NextGeneration, ImmutableArray.Create( - New SemanticEdit(SemanticEditKind.Update, f1, f2, GetSyntaxMapFromMarkers(source1, source2), preserveLocalVariables:=True))) + New SemanticEdit(SemanticEditKind.Update, f1, f2, GetSyntaxMapFromMarkers(source1, source2)))) diff2.VerifySynthesizedMembers( "C: {_Closure$__}", @@ -5543,7 +5526,7 @@ End Class Dim diff1 = compilation1.EmitDifference( generation0, - ImmutableArray.Create(New SemanticEdit(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1), preserveLocalVariables:=True))) + ImmutableArray.Create(New SemanticEdit(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1)))) diff1.VerifyIL("C.F", " { @@ -5569,7 +5552,7 @@ End Class ") Dim diff2 = compilation2.EmitDifference( diff1.NextGeneration, - ImmutableArray.Create(New SemanticEdit(SemanticEditKind.Update, f1, f2, GetSyntaxMapFromMarkers(source1, source2), preserveLocalVariables:=True))) + ImmutableArray.Create(New SemanticEdit(SemanticEditKind.Update, f1, f2, GetSyntaxMapFromMarkers(source1, source2)))) diff2.VerifyIL("C.F", " { @@ -5652,7 +5635,7 @@ End Class Function(m) Nothing) Dim testData1 = New CompilationTestData() Dim method1 = compilation1.GetMember(Of MethodSymbol)("C.F") - Dim edit = New SemanticEdit(SemanticEditKind.Update, method0, method1, GetEquivalentNodesMap(method1, method0), preserveLocalVariables:=True) + Dim edit = New SemanticEdit(SemanticEditKind.Update, method0, method1, GetEquivalentNodesMap(method1, method0)) Dim diff1 = compilation1.EmitDifference( generation0, ImmutableArray.Create(edit)) @@ -5773,7 +5756,7 @@ End Module Dim diff0 = compilation1.EmitDifference( generation0, - ImmutableArray.Create(New SemanticEdit(SemanticEditKind.Update, method0, method1, GetEquivalentNodesMap(method1, method0), preserveLocalVariables:=True))) + ImmutableArray.Create(New SemanticEdit(SemanticEditKind.Update, method0, method1, GetEquivalentNodesMap(method1, method0)))) diff0.VerifyIL(" { @@ -6595,7 +6578,7 @@ End Class" Dim diffB1 = compilationB1.EmitDifference( generationB0, - ImmutableArray.Create(New SemanticEdit(SemanticEditKind.Update, f0, f1, GetEquivalentNodesMap(f1, f0), preserveLocalVariables:=True))) + ImmutableArray.Create(New SemanticEdit(SemanticEditKind.Update, f0, f1, GetEquivalentNodesMap(f1, f0)))) diffB1.VerifyIL("B.F", " { @@ -6614,7 +6597,7 @@ End Class" Dim diffB2 = compilationB2.EmitDifference( diffB1.NextGeneration, - ImmutableArray.Create(New SemanticEdit(SemanticEditKind.Update, f1, f2, GetEquivalentNodesMap(f2, f1), preserveLocalVariables:=True))) + ImmutableArray.Create(New SemanticEdit(SemanticEditKind.Update, f1, f2, GetEquivalentNodesMap(f2, f1)))) diffB2.VerifyIL("B.F", " { @@ -6676,7 +6659,7 @@ End Class Dim diff1 = compilation1.EmitDifference( generation0, - ImmutableArray.Create(New SemanticEdit(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1), preserveLocalVariables:=True))) + ImmutableArray.Create(New SemanticEdit(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1)))) Dim md1 = diff1.GetMetadata() Dim reader1 = md1.Reader @@ -6819,7 +6802,7 @@ End Class") Dim diff1 = compilation1.EmitDifference( generation0, - ImmutableArray.Create(New SemanticEdit(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1), preserveLocalVariables:=True))) + ImmutableArray.Create(New SemanticEdit(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1)))) Dim md1 = diff1.GetMetadata() Dim reader1 = md1.Reader @@ -6964,7 +6947,7 @@ End Class Dim diffError = compilation1.EmitDifference( generation0, - ImmutableArray.Create(New SemanticEdit(SemanticEditKind.Update, e0, e1, GetSyntaxMapFromMarkers(source0, source1), preserveLocalVariables:=True))) + ImmutableArray.Create(New SemanticEdit(SemanticEditKind.Update, e0, e1, GetSyntaxMapFromMarkers(source0, source1)))) diffError.EmitResult.Diagnostics.Verify( Diagnostic(ERRID.ERR_AmbiguousInImports2, "Timer").WithArguments("Timer", "System.Threading, System.Timers").WithLocation(7, 21)) diff --git a/src/Compilers/VisualBasic/Test/Emit/Emit/EditAndContinue/LocalSlotMappingTests.vb b/src/Compilers/VisualBasic/Test/Emit/Emit/EditAndContinue/LocalSlotMappingTests.vb index b16f357198d68..cb96208a605de 100644 --- a/src/Compilers/VisualBasic/Test/Emit/Emit/EditAndContinue/LocalSlotMappingTests.vb +++ b/src/Compilers/VisualBasic/Test/Emit/Emit/EditAndContinue/LocalSlotMappingTests.vb @@ -118,7 +118,7 @@ End Class Dim method1 = compilation1.GetMember(Of MethodSymbol)("C.M") Dim diff1 = compilation1.EmitDifference( generation0, - ImmutableArray.Create(New SemanticEdit(SemanticEditKind.Update, method0, method1, GetSyntaxMapFromMarkers(source, source), preserveLocalVariables:=True))) + ImmutableArray.Create(New SemanticEdit(SemanticEditKind.Update, method0, method1, GetSyntaxMapFromMarkers(source, source)))) ' check that all user-defined and long-lived synthesized local slots are reused diff1.VerifyIL("C.M", " @@ -284,7 +284,7 @@ End Class Dim method1 = compilation1.GetMember(Of MethodSymbol)("C.M") Dim diff1 = compilation1.EmitDifference( generation0, - ImmutableArray.Create(New SemanticEdit(SemanticEditKind.Update, method0, method1, GetSyntaxMapFromMarkers(source, source), preserveLocalVariables:=True))) + ImmutableArray.Create(New SemanticEdit(SemanticEditKind.Update, method0, method1, GetSyntaxMapFromMarkers(source, source)))) diff1.VerifyIL("C.M", " { @@ -554,7 +554,7 @@ End Class Dim method1 = compilation1.GetMember(Of MethodSymbol)("C.M") Dim diff1 = compilation1.EmitDifference( generation0, - ImmutableArray.Create(New SemanticEdit(SemanticEditKind.Update, method0, method1, GetEquivalentNodesMap(method1, method0), preserveLocalVariables:=True))) + ImmutableArray.Create(New SemanticEdit(SemanticEditKind.Update, method0, method1, GetEquivalentNodesMap(method1, method0)))) ' check that all user-defined and long-lived synthesized local slots are reused diff1.VerifyIL("C._Lambda$__1", " @@ -992,7 +992,7 @@ End Class Dim generation0 = CreateInitialBaseline(compilation0, md0, AddressOf v0.CreateSymReader().GetEncMethodDebugInfo) Dim diff1 = compilation1.EmitDifference( generation0, - ImmutableArray.Create(New SemanticEdit(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1), preserveLocalVariables:=True))) + ImmutableArray.Create(New SemanticEdit(SemanticEditKind.Update, f0, f1, GetSyntaxMapFromMarkers(source0, source1)))) diff1.VerifyIL("C.G", " { @@ -1023,7 +1023,7 @@ End Class Dim diff2 = compilation2.EmitDifference( diff1.NextGeneration, - ImmutableArray.Create(New SemanticEdit(SemanticEditKind.Update, f1, f2, GetSyntaxMapFromMarkers(source1, source2), preserveLocalVariables:=True))) + ImmutableArray.Create(New SemanticEdit(SemanticEditKind.Update, f1, f2, GetSyntaxMapFromMarkers(source1, source2)))) diff2.VerifyIL("C.G", " { diff --git a/src/EditorFeatures/CSharpTest/EditAndContinue/TopLevelEditingTests.cs b/src/EditorFeatures/CSharpTest/EditAndContinue/TopLevelEditingTests.cs index a1729c3b6e729..077dd9d31b85d 100644 --- a/src/EditorFeatures/CSharpTest/EditAndContinue/TopLevelEditingTests.cs +++ b/src/EditorFeatures/CSharpTest/EditAndContinue/TopLevelEditingTests.cs @@ -17080,7 +17080,7 @@ class C ActiveStatementsDescription.Empty, new[] { - SemanticEdit(SemanticEditKind.Update, c => c.GetMember("C.a"), preserveLocalVariables: true), + SemanticEdit(SemanticEditKind.Update, c => c.GetMember("C.a")), SemanticEdit(SemanticEditKind.Update, c => c.GetParameterlessConstructor("C"), preserveLocalVariables: true), }, capabilities: EditAndContinueCapabilities.ChangeCustomAttributes); @@ -17102,7 +17102,7 @@ public void Field_Attribute_DeleteInsertUpdate_WithInitializer() DocumentResults( semanticEdits: new[] { - SemanticEdit(SemanticEditKind.Update, c => c.GetMember("C.a"), preserveLocalVariables: true), + SemanticEdit(SemanticEditKind.Update, c => c.GetMember("C.a")), SemanticEdit(SemanticEditKind.Update, c => c.GetParameterlessConstructor("C"), partialType: "C", preserveLocalVariables: true) }), ], diff --git a/src/Features/Core/Portable/EditAndContinue/AbstractEditAndContinueAnalyzer.cs b/src/Features/Core/Portable/EditAndContinue/AbstractEditAndContinueAnalyzer.cs index 92224480d0dfb..aeab41986341b 100644 --- a/src/Features/Core/Portable/EditAndContinue/AbstractEditAndContinueAnalyzer.cs +++ b/src/Features/Core/Portable/EditAndContinue/AbstractEditAndContinueAnalyzer.cs @@ -3118,6 +3118,10 @@ void ReportDeletedMemberActiveStatementsRudeEdits() { DeferConstructorEdit(oldSymbol.ContainingType, newSymbol.ContainingType, newDeclaration, syntaxMap, newSymbol.IsStatic, isMemberWithDeletedInitializer: isOldDeclarationWithInitializer && !isNewDeclarationWithInitializer); + + // Syntax map will be aggregated into one created for the constructor edit. + // It should not be set on the edit of the member with an initializer. + syntaxMap = null; } if (isConstructorWithMemberInitializers) diff --git a/src/Features/Core/Portable/EditAndContinue/EditSession.cs b/src/Features/Core/Portable/EditAndContinue/EditSession.cs index 703a0bb810296..526274eb9abbc 100644 --- a/src/Features/Core/Portable/EditAndContinue/EditSession.cs +++ b/src/Features/Core/Portable/EditAndContinue/EditSession.cs @@ -723,8 +723,7 @@ internal static void MergePartialEdits( edit.Kind, oldSymbol: oldSymbol, newSymbol: newSymbol, - syntaxMap: edit.SyntaxMap, - preserveLocalVariables: edit.SyntaxMap != null)); + syntaxMap: edit.SyntaxMap)); } } @@ -778,7 +777,7 @@ internal static void MergePartialEdits( if (visitedSymbols.Add(newSymbol ?? oldSymbol!)) { var syntaxMap = (edit.Kind == SemanticEditKind.Update) ? mergedUpdateEditSyntaxMaps[edit.PartialType.Value] : null; - mergedEditsBuilder.Add(new SemanticEdit(edit.Kind, oldSymbol, newSymbol, syntaxMap, preserveLocalVariables: syntaxMap != null)); + mergedEditsBuilder.Add(new SemanticEdit(edit.Kind, oldSymbol, newSymbol, syntaxMap)); } } } diff --git a/src/Test/PdbUtilities/EditAndContinue/EditAndContinueTest.GenerationVerifier.cs b/src/Test/PdbUtilities/EditAndContinue/EditAndContinueTest.GenerationVerifier.cs index 2d2affbf8706f..be39361a87d06 100644 --- a/src/Test/PdbUtilities/EditAndContinue/EditAndContinueTest.GenerationVerifier.cs +++ b/src/Test/PdbUtilities/EditAndContinue/EditAndContinueTest.GenerationVerifier.cs @@ -4,6 +4,8 @@ using System; using System.Collections.Generic; +using System.Collections.Immutable; +using System.Diagnostics; using System.Linq; using System.Reflection.Metadata; using System.Reflection.Metadata.Ecma335; @@ -21,10 +23,10 @@ internal sealed class GenerationVerifier { private readonly int _ordinal; private readonly MetadataReader _metadataReader; - private readonly IEnumerable _readers; + private readonly ImmutableArray _readers; private readonly GenerationInfo _generationInfo; - public GenerationVerifier(int ordinal, GenerationInfo generationInfo, IEnumerable readers) + public GenerationVerifier(int ordinal, GenerationInfo generationInfo, ImmutableArray readers) { _ordinal = ordinal; _metadataReader = generationInfo.MetadataReader; @@ -137,17 +139,45 @@ public void VerifySynthesizedFields(string typeName, params string[] expectedSyn AssertEx.SetEqual(expectedSynthesizedTypesAndMemberCounts, actual, itemSeparator: "\r\n"); } + public void VerifyUpdatedMethodNames(params string[] expectedMethodNames) + { + Debug.Assert(_generationInfo.CompilationDifference != null); + CheckNames(_readers, _generationInfo.CompilationDifference.EmitResult.UpdatedMethods, expectedMethodNames); + } + + public void VerifyChangedTypeNames(params string[] expectedTypeNames) + { + Debug.Assert(_generationInfo.CompilationDifference != null); + CheckNames(_readers, _generationInfo.CompilationDifference.EmitResult.ChangedTypes, expectedTypeNames); + } + internal void VerifyMethodBody(string qualifiedMemberName, string expectedILWithSequencePoints) => _generationInfo.CompilationVerifier!.VerifyMethodBody(qualifiedMemberName, expectedILWithSequencePoints); internal void VerifyPdb(IEnumerable methodTokens, string expectedPdb) => _generationInfo.CompilationDifference!.VerifyPdb(methodTokens, expectedPdb); + internal void VerifyPdb(string qualifiedMemberName, string expectedPdb, PdbValidationOptions options = default) + => _generationInfo.CompilationVerifier!.VerifyPdb(qualifiedMemberName, expectedPdb, options: options); + internal void VerifyIL(string expectedIL) - => _generationInfo.CompilationDifference!.VerifyIL(expectedIL); + { + Debug.Assert(_generationInfo.CompilationDifference != null); + _generationInfo.CompilationDifference.VerifyIL(expectedIL); + } internal void VerifyIL(string qualifiedMemberName, string expectedIL) - => _generationInfo.CompilationDifference!.VerifyIL(qualifiedMemberName, expectedIL); + { + if (_generationInfo.CompilationVerifier != null) + { + _generationInfo.CompilationVerifier.VerifyIL(qualifiedMemberName, expectedIL); + } + else + { + Debug.Assert(_generationInfo.CompilationDifference != null); + _generationInfo.CompilationDifference.VerifyIL(qualifiedMemberName, expectedIL); + } + } } } } diff --git a/src/Test/PdbUtilities/EditAndContinue/EditAndContinueTest.cs b/src/Test/PdbUtilities/EditAndContinue/EditAndContinueTest.cs index 920888a3e7f79..22c649e801f54 100644 --- a/src/Test/PdbUtilities/EditAndContinue/EditAndContinueTest.cs +++ b/src/Test/PdbUtilities/EditAndContinue/EditAndContinueTest.cs @@ -32,7 +32,7 @@ internal abstract partial class EditAndContinueTest(Verification? verific private TSelf This => (TSelf)this; - internal TSelf AddBaseline(string source, Action validator) + internal TSelf AddBaseline(string source, Action? validator = null) { _hasVerified = false; @@ -59,7 +59,7 @@ internal TSelf AddBaseline(string source, Action validator) var baseline = EditAndContinueTestUtilities.CreateInitialBaseline(compilation, md, verifier.CreateSymReader().GetEncMethodDebugInfo); - _generations.Add(new GenerationInfo(compilation, md.MetadataReader, diff: null, verifier, baseline, validator)); + _generations.Add(new GenerationInfo(compilation, md.MetadataReader, diff: null, verifier, baseline, validator ?? new(x => { }))); _sources.Add(markedSource); return This; @@ -113,7 +113,7 @@ internal TSelf Verify() } readers.Add(generation.MetadataReader); - var verifier = new GenerationVerifier(index, generation, readers); + var verifier = new GenerationVerifier(index, generation, readers.ToImmutableArray()); generation.Verifier(verifier); index++; @@ -153,7 +153,7 @@ private ImmutableArray GetSemanticEdits( syntaxMap = null; } - return new SemanticEdit(e.Kind, oldSymbol, newSymbol, syntaxMap, e.PreserveLocalVariables); + return new SemanticEdit(e.Kind, oldSymbol, newSymbol, syntaxMap); })); } diff --git a/src/Test/PdbUtilities/EditAndContinue/EditAndContinueTestUtilities.cs b/src/Test/PdbUtilities/EditAndContinue/EditAndContinueTestUtilities.cs index 57ea57f8d7211..bdc442ff14bf1 100644 --- a/src/Test/PdbUtilities/EditAndContinue/EditAndContinueTestUtilities.cs +++ b/src/Test/PdbUtilities/EditAndContinue/EditAndContinueTestUtilities.cs @@ -4,6 +4,8 @@ using System; using System.IO; +using System.Collections.Generic; +using System.Collections.Immutable; using System.Linq; using System.Reflection.Metadata; using System.Reflection.Metadata.Ecma335; @@ -33,7 +35,7 @@ public static EmitBaseline CreateInitialBaseline(Compilation compilation, Module return EmitBaseline.CreateInitialBaseline(compilation, module, debugInformationProvider, localSignatureProvider, hasPortableDebugInformation); } - internal static string EncLogRowToString(EditAndContinueLogEntry row) + public static string EncLogRowToString(EditAndContinueLogEntry row) { TableIndex tableIndex; MetadataTokens.TryGetTableIndex(row.Handle.Kind, out tableIndex); @@ -45,7 +47,7 @@ internal static string EncLogRowToString(EditAndContinueLogEntry row) row.Operation); } - internal static string EncMapRowToString(EntityHandle handle) + public static string EncMapRowToString(EntityHandle handle) { TableIndex tableIndex; MetadataTokens.TryGetTableIndex(handle.Kind, out tableIndex); @@ -56,7 +58,7 @@ internal static string EncMapRowToString(EntityHandle handle) tableIndex); } - internal static string AttributeRowToString(CustomAttributeRow row) + public static string AttributeRowToString(CustomAttributeRow row) { TableIndex parentTableIndex, constructorTableIndex; MetadataTokens.TryGetTableIndex(row.ParentToken.Kind, out parentTableIndex); @@ -70,6 +72,51 @@ internal static string AttributeRowToString(CustomAttributeRow row) constructorTableIndex); } - internal static bool IsDefinition(HandleKind kind) + public static bool IsDefinition(HandleKind kind) => kind is not (HandleKind.AssemblyReference or HandleKind.ModuleReference or HandleKind.TypeReference or HandleKind.MemberReference or HandleKind.TypeSpecification or HandleKind.MethodSpecification); + + public static void CheckNames(MetadataReader reader, IEnumerable handles, params string[] expectedNames) + { + CheckNames(new[] { reader }, handles, expectedNames); + } + + public static void CheckNames(IEnumerable readers, IEnumerable handles, params string[] expectedNames) + { + var actualNames = readers.GetStrings(handles); + AssertEx.Equal(expectedNames, actualNames); + } + + public static void CheckNames(IReadOnlyList readers, IEnumerable<(StringHandle Namespace, StringHandle Name)> handles, params string[] expectedNames) + { + var actualNames = handles.Select(handlePair => string.Join(".", readers.GetString(handlePair.Namespace), readers.GetString(handlePair.Name))).ToArray(); + AssertEx.Equal(expectedNames, actualNames); + } + + public static void CheckNames(IReadOnlyList readers, ImmutableArray typeHandles, params string[] expectedNames) + => CheckNames(readers, typeHandles, (reader, handle) => reader.GetTypeDefinition((TypeDefinitionHandle)handle).Name, handle => handle, expectedNames); + + public static void CheckNames(IReadOnlyList readers, ImmutableArray methodHandles, params string[] expectedNames) + => CheckNames(readers, methodHandles, (reader, handle) => reader.GetMethodDefinition((MethodDefinitionHandle)handle).Name, handle => handle, expectedNames); + + private static void CheckNames( + IReadOnlyList readers, + ImmutableArray entityHandles, + Func getName, + Func toHandle, + string[] expectedNames) + { + var aggregator = GetAggregator(readers); + + AssertEx.Equal(expectedNames, entityHandles.Select(handle => + { + var genEntityHandle = aggregator.GetGenerationHandle(toHandle(handle), out int typeGeneration); + var nameHandle = getName(readers[typeGeneration], genEntityHandle); + + var genNameHandle = (StringHandle)aggregator.GetGenerationHandle(nameHandle, out int nameGeneration); + return readers[nameGeneration].GetString(genNameHandle); + })); + } + + public static MetadataAggregator GetAggregator(IReadOnlyList readers) + => new MetadataAggregator(readers[0], readers.Skip(1).ToArray()); }