Skip to content

Share code between generate constructor and generate type.#48836

Merged
10 commits merged intodotnet:masterfrom
CyrusNajmabadi:shareCode
Oct 23, 2020
Merged

Share code between generate constructor and generate type.#48836
10 commits merged intodotnet:masterfrom
CyrusNajmabadi:shareCode

Conversation

@CyrusNajmabadi
Copy link
Contributor

No description provided.

@CyrusNajmabadi CyrusNajmabadi requested a review from a team as a code owner October 22, 2020 04:30
@Dotnet-GitSync-Bot
Copy link
Collaborator

I couldn't figure out the best area label to add to this PR. If you have write-permissions please help me learn by adding exactly one area label.

}
}
var constructorParameter = constructor.Parameters[i];
var conversion = semanticFacts.ClassifyConversion(semanticModel, expressions[i], constructorParameter.Type);
Copy link
Member

Choose a reason for hiding this comment

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

Is using semanticFacts instead of the Compilation to classify the conversion the fix for the lambda issue? I can't see where else it would be...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

generally use. Compilation can be used to classify between two ITYpeSymbols. However, SemanticModel (which is what semantic facts uses) can classify between an arbitrary expression and an ITypeSymbol.

Consider the case where the expr is x => x.Length and the destination type symbol is Func<string, int>. Technically x => x.Length has no type of it's own. So we can't actually classify between it's type and Func<string, int>. However we can ask if there's a conversion between that untyped expression node and that type symbol.

Copy link
Member

@davidwengier davidwengier left a comment

Choose a reason for hiding this comment

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

This makes sense, but I wouldn't say I deeply understand it, mainly because I'm about to fall asleep though, not because of the code :)

@ghost
Copy link

ghost commented Oct 22, 2020

Hello @CyrusNajmabadi!

Because this pull request has the auto-merge label, I will be glad to assist with helping to merge this pull request once all check-in policies pass.

p.s. you can customize the way I help with merging this pull request, such as holding this pull request until a specific person approves. Simply @mention me (@msftbot) and give me an instruction to get started! Learn more here.

Copy link

@ghost ghost left a comment

Choose a reason for hiding this comment

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

Auto-approval

@ghost ghost merged commit 4e1ea06 into dotnet:master Oct 23, 2020
@ghost ghost added this to the Next milestone Oct 23, 2020
@CyrusNajmabadi CyrusNajmabadi deleted the shareCode branch October 23, 2020 02:28
@allisonchou allisonchou modified the milestones: Next, 16.9.P2 Nov 24, 2020
This pull request was closed.
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.

4 participants