-
Notifications
You must be signed in to change notification settings - Fork 4k
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
Region analysis of nameof #55724
Region analysis of nameof #55724
Conversation
@@ -35071,7 +35071,7 @@ public static void Main(string[] args) | |||
var decl = GetOutVarDeclaration(tree, name); | |||
var refs = GetReferences(tree, name).ToArray(); | |||
Assert.Equal(2, refs.Length); | |||
VerifyModelForOutVar(model, decl, refs[0]); | |||
VerifyModelForOutVar(model, decl, isDelegateCreation: false, isExecutableCode: false, isShadowed: false, references: refs[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.
Could you please clarify what the significance of this change is?
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.
The isExecutableCode: false
is not the default for overload with fewer parameters. Here's what that drives:
if (isExecutableCode)
{
Assert.True(dataFlow.Succeeded);
Assert.True(dataFlow.VariablesDeclared.Contains(symbol, ReferenceEqualityComparer.Instance));
if (!isDelegateCreation)
{
Assert.True(dataFlow.AlwaysAssigned.Contains(symbol, ReferenceEqualityComparer.Instance));
Assert.True(dataFlow.WrittenInside.Contains(symbol, ReferenceEqualityComparer.Instance));
var flowsIn = FlowsIn(dataFlowParent, decl, references);
Assert.Equal(flowsIn,
dataFlow.DataFlowsIn.Contains(symbol, ReferenceEqualityComparer.Instance));
Assert.Equal(flowsIn,
dataFlow.ReadInside.Contains(symbol, ReferenceEqualityComparer.Instance));
Assert.Equal(FlowsOut(dataFlowParent, decl, references),
dataFlow.DataFlowsOut.Contains(symbol, ReferenceEqualityComparer.Instance));
Assert.Equal(ReadOutside(dataFlowParent, references),
dataFlow.ReadOutside.Contains(symbol, ReferenceEqualityComparer.Instance));
Assert.Equal(WrittenOutside(dataFlowParent, references),
dataFlow.WrittenOutside.Contains(symbol, ReferenceEqualityComparer.Instance));
}
}
This is a situation where the IDE shows a variable as being captured but it isn't actually lowered into a field on a closure class, so it ends up being misleading for users. |
@dotnet/roslyn-compiler for review. Small fix. Thanks |
@jcouv I assume we have tests that cover the examples you put in #53591 (comment)? |
Yes. Those tests existed already in various shapes. |
/azp run |
Azure Pipelines successfully started running 3 pipeline(s). |
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 (commit 1)
Fixes #53591