Reputation: 4215
I am writing a tool that, given a (compileable) piece of C# code, generates another source, that using Mono.Cecil
, outputs an assembly that is equivalent to the one produced by compiling the original piece of code. This is achieved by parsing the C# code and visiting the resulting AST and generating calls to the equivalent Mono.Cecil
APIs (I guess this is somewhat similar to what the code generation part of Roslyn does, but generating calls to Mono.Cecil
instead of IL
).
Given that, processing the lowered version of a given AST would make the code easier to implement, more robust, etc but looking into the Roslyn sources it does not look like there's a way to access it.
In the best case my code would need to call into the various types in charge of doing the lowering in https://github.com/dotnet/roslyn/blob/main/src/Compilers/CSharp/Portable/Lowering which, AFAICS, are all internal.
Whence the question: is it really not possible to get the lowered version of a given AST ?
Upvotes: 0
Views: 427
Reputation: 19031
The nearest thing we have that is somewhat "lowered" is our IOperation APIs which are a bit lower level than the syntax/semantic APIs. We don't have an API to give you the fully lowered representation.
Upvotes: 1