Share code between generate constructor and generate type.#48836
Share code between generate constructor and generate type.#4883610 commits merged intodotnet:masterfrom
Conversation
|
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); |
There was a problem hiding this comment.
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...
There was a problem hiding this comment.
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.
davidwengier
left a comment
There was a problem hiding this comment.
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 :)
|
Hello @CyrusNajmabadi! Because this pull request has the 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 (
|
No description provided.