Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Test EnC on expression variables in initializers and queries #25438

Merged
merged 9 commits into from
Mar 21, 2018

Conversation

jcouv
Copy link
Member

@jcouv jcouv commented Mar 13, 2018

@jcouv jcouv added this to the 15.7 milestone Mar 13, 2018
@jcouv jcouv self-assigned this Mar 13, 2018
@jcouv jcouv requested a review from a team as a code owner March 13, 2018 04:40
@@ -8187,5 +8187,294 @@ .maxstack 3
}
", sequencePoints: "Program+<Test>d__0.MoveNext", source: source);
}

[Fact]
public void ExpressionVariable_InFieldInitializer()
Copy link
Contributor

@AlekseyTs AlekseyTs Mar 13, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ExpressionVariable_InFieldInitializer [](start = 20, length = 37)

This change is likely to be affected by the change in #25441. Also, that PR probably covers all the scenarios covered by the new tests here. #Resolved

@jcouv
Copy link
Member Author

jcouv commented Mar 13, 2018

Hold on, some tests are failing. I'll investigate. #Closed

@AlekseyTs
Copy link
Contributor

AlekseyTs commented Mar 13, 2018

@tmat Could you please review EnC tests? Are they sufficient to declare that EnC works as expected for the feature? #Resolved

@jcouv
Copy link
Member Author

jcouv commented Mar 13, 2018

Adjusted the tests. It possible that I didn't restore properly on my home machine, so was using an older dependency for pdb->xml translation.
Although this is now consistent with neighboring tests, this still feels like a regression to me (the previous format seems better). But that's unrelated to this PR.

-    <file id=""1"" name="""" language=""C#"" />
+    <file id=""1"" name="""" language=""3f5162f8-07c6-11d3-9053-00c04fa302a1"" languageVendor=""994b45c4-e6e9-11d2-903f-00c04fa302a1"" documentType=""5a869d0b-6611-11d3-bd2a-0000f80849bd"" />

var n2 = compilation2.GetMember<MethodSymbol>("Program.N");

var v0 = CompileAndVerify(compilation0);
v0.VerifyIL("Program.N()", @"
Copy link
Contributor

@AlekseyTs AlekseyTs Mar 13, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Program.N() [](start = 25, length = 11)

I think we should also examine IL for the selector lambda that was modified. #Closed

@AlekseyTs
Copy link
Contributor

AlekseyTs commented Mar 13, 2018

Done with review pass (iteration 2) #Resolved

@AlekseyTs
Copy link
Contributor

AlekseyTs commented Mar 13, 2018

@tmat Could you please review EnC tests? Are they sufficient to declare that EnC works as expected for the feature? #Resolved

@jcouv jcouv added the Test Test failures in roslyn-CI label Mar 14, 2018
@gafter gafter self-assigned this Mar 14, 2018
}

[Fact]
public void ExpressionVariable_InConstructorInitializer()
Copy link
Member

@tmat tmat Mar 14, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ExpressionVariable_InConstructorInitializer [](start = 20, length = 43)

There is already test public void OutVar() that's similar. Could you rename it to ExpressionVariable_InStatement or something like that and move these tests close together? #Pending

{
// Code size 53 (0x35)
.maxstack 4
.locals init ([unchanged] V_0,
Copy link
Member

@tmat tmat Mar 14, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[unchanged] V_0, [](start = 16, length = 16)

This indicates that the query variable was not reused. This is likely just because you're missing the markers <N:#> around the expression in var query = ... declaration.
Also, as Aleksey points out we should test how the lambda was updated. You'll need more markers to map the clauses of the query.
See http://source.roslyn.io/#Roslyn.Compilers.CSharp.Emit.UnitTests/Emit/EditAndContinue/EditAndContinueTests.cs,5338 for another LINQ EnC test. #Pending

select M(a, out int <N:0>x</N:0>) + x;
}
}");
var compilation0 = CreateCompilation(source0.Tree, options: ComSafeDebugDll);
Copy link
Member

@tmat tmat Mar 14, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[](start = 12, length = 1)

Nit: extra space #Pending

");
}

[Fact]
Copy link
Member

@tmat tmat Mar 14, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[Fact] [](start = 7, length = 7)

Are patterns in initializers implemented in a different branch? If they are in this branch we should add similar tests for patterns as well here. See PatternVariable_* tests above. #Pending

Copy link
Member

@gafter gafter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:shipit:

@gafter gafter removed their assignment Mar 14, 2018
@jcouv
Copy link
Member Author

jcouv commented Mar 14, 2018

@tmat for another look. Thanks

@tmat
Copy link
Member

tmat commented Mar 15, 2018

Aleksey's feedback doesn't seem to be addressed yet.

@AlekseyTs
Copy link
Contributor

On another PR, @tmat also recommended to

Also https://github.com/dotnet/roslyn/blob/master/src/Compilers/CSharp/Test/Emit/Emit/EditAndContinue/EditAndContinueClosureTests.cs#L2356 verify that the members generated for the lambda and closures are correctly reused when edited.

I think he was talking about scenarios when declared Expression Variables are captured in lambdas.

ImmutableArray.Create(
new SemanticEdit(SemanticEditKind.Update, ctor1, ctor2, GetSyntaxMapFromMarkers(source1, source0), preserveLocalVariables: true)));

diff2.VerifySynthesizedMembers("C.<>c__DisplayClass0_0#1: {x, <.ctor>b__0}", "C.<>c__DisplayClass0_0#2: {x, <.ctor>b__0}", "C: {<>c__DisplayClass0_0#2, <>c__DisplayClass0_0#1}");
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@AlekseyTs I'll add the other two variants of this test (in field and in query) tonight.

I don't fully understand the test helpers, but I feel like this is not what we expect: new synthesized types and members get added with new edits... I'll let @tmat confirm what's expected.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but I feel like this is not what we expect

Make sure to use latest from the feature branch, just in case. My latest changes affect PDB


In reply to: 174964965 [](ancestors = 174964965)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I'll rebase the PR to latest branch bits.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've rebased, but the tests were not affected.

@gafter gafter mentioned this pull request Mar 16, 2018
44 tasks
@jcouv jcouv changed the base branch from features/ExpressionVariables to dev15.7.x March 17, 2018 19:00
Copy link
Contributor

@AlekseyTs AlekseyTs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM (iteration 7). Thanks!

@jcouv
Copy link
Member Author

jcouv commented Mar 20, 2018

Cool
@tmat for review. Thanks

@jcouv
Copy link
Member Author

jcouv commented Mar 20, 2018

@tmat for review. Thanks

ImmutableArray.Create(
new SemanticEdit(SemanticEditKind.Update, ctor0, ctor1, GetSyntaxMapFromMarkers(source0, source1), preserveLocalVariables: true)));

diff1.VerifySynthesizedMembers("C: {<>c__DisplayClass0_0#1}", "C.<>c__DisplayClass0_0#1: {x, <Method>b__0}");
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tomas said the #1 indicates a new class was generated, which is unexpected.
It might be an issue with the test. I'll investigate (he said to debug EncVariableSlotAllocator.TryGetPreviousClosure to figure this out)

@@ -22,6 +22,9 @@

namespace Microsoft.CodeAnalysis.CSharp.EditAndContinue.UnitTests
{
/// <summary>
/// Tip: debug EncVariableSlotAllocator.TryGetPreviousClosure to figure out missing markers in your test.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TryGetPreviousClosure [](start = 44, length = 21)

... or other TryGet methods depending on what matching is being done.

@jcouv jcouv merged commit 86067f2 into dotnet:dev15.7.x Mar 21, 2018
@jcouv jcouv deleted the exprvar-enc branch March 21, 2018 23:26
@jcouv
Copy link
Member Author

jcouv commented Mar 21, 2018

Thanks!
I went ahead and merged since test-only changes don't need ask-mode approval.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Compilers Test Test failures in roslyn-CI
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants