-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
Conversation
@@ -8187,5 +8187,294 @@ .maxstack 3 | |||
} | |||
", sequencePoints: "Program+<Test>d__0.MoveNext", source: source); | |||
} | |||
|
|||
[Fact] | |||
public void ExpressionVariable_InFieldInitializer() |
There was a problem hiding this comment.
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
Hold on, some tests are failing. I'll investigate. #Closed |
@tmat Could you please review EnC tests? Are they sufficient to declare that EnC works as expected for the feature? #Resolved |
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. - <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()", @" |
There was a problem hiding this comment.
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
Done with review pass (iteration 2) #Resolved |
@tmat Could you please review EnC tests? Are they sufficient to declare that EnC works as expected for the feature? #Resolved |
} | ||
|
||
[Fact] | ||
public void ExpressionVariable_InConstructorInitializer() |
There was a problem hiding this comment.
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, |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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] |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tmat for another look. Thanks |
Aleksey's feedback doesn't seem to be addressed yet. |
On another PR, @tmat also recommended to
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}"); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this 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!
Cool |
@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}"); |
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
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.
Thanks! |
Tagging @ivanbasov @tmat @AlekseyTs