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

Region analysis of nameof #55724

Merged
merged 1 commit into from
Aug 21, 2021
Merged

Region analysis of nameof #55724

merged 1 commit into from
Aug 21, 2021

Conversation

jcouv
Copy link
Member

@jcouv jcouv commented Aug 19, 2021

Fixes #53591

@jcouv jcouv reopened this Aug 19, 2021
@jcouv jcouv self-assigned this Aug 19, 2021
@jcouv jcouv marked this pull request as ready for review August 19, 2021 20:13
@jcouv jcouv requested a review from a team as a code owner August 19, 2021 20:13
@@ -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]);
Copy link
Contributor

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?

Copy link
Member Author

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));
                }
            }

@RikkiGibson
Copy link
Contributor

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.

@jcouv jcouv requested a review from RikkiGibson August 20, 2021 17:51
@jcouv
Copy link
Member Author

jcouv commented Aug 20, 2021

@dotnet/roslyn-compiler for review. Small fix. Thanks

@333fred
Copy link
Member

333fred commented Aug 20, 2021

@jcouv I assume we have tests that cover the examples you put in #53591 (comment)?

@jcouv
Copy link
Member Author

jcouv commented Aug 20, 2021

I assume we have tests that cover the examples you put in #53591 (comment)?

Yes. Those tests existed already in various shapes.

@jcouv
Copy link
Member Author

jcouv commented Aug 20, 2021

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 3 pipeline(s).

Copy link
Member

@333fred 333fred left a comment

Choose a reason for hiding this comment

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

LGTM (commit 1)

@jcouv jcouv merged commit 5e54d3c into dotnet:main Aug 21, 2021
@jcouv jcouv deleted the nameof-lambda branch August 21, 2021 02:45
@ghost ghost added this to the Next milestone Aug 21, 2021
@dibarbet dibarbet modified the milestones: Next, 17.0.P4 Aug 31, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

BUG: closure is created for (this) when nameof() is referencing a member
4 participants