Open roji opened 1 year ago
Assigned to @333fred as owner of IOperation APIs to triage and propose a concrete API. Thanks
As discussed offline, what we proposed the compiler could do is similar to this, but not this. We proposed that the compiler could have an API to return an IOperation tree that represents the actual Expression
calls that will be emitted by the compiler. It's not possible to actually turn it into an expression tree, as the types involved don't exist (yet).
As part of the effort to make EF Core NativeAOT-compatible, LINQ queries need to be pre-compiled at design time; this entails analyzing the project source code, identifying EF LINQ queries, and passing them through EF's query pipeline, ultimately producing SQL etc. Since EF's query pipeline is a regular LINQ provider, it accepts a LINQ expression tree (with Expressions); this means that the analyzed Roslyn syntax tree (or IOperation tree) must be first be transformed into a LINQ expression tree.
There is a prototype component which would do this for EF; however, given that the compiler already has this functionality, it would be better to expose that for consumption by applications such as EF. There's a usage potential beyond EF, since other LINQ providers which need to be made to work at source-generation time would require this as well.
@jaredpar we discussed this in our meeting; I'm no longer sure who it was in the Roslyn team who suggested I open this issue...
/cc @ajcvickers