Bridging the gap between Linq expression trees and Roslyn parse

Trying to make a script generator that converts C# code and so far I'm using Linq expressions for that but unfortunately, it only allows single line lambdas even though the expression model seems to support full on methods with locals and loops etc. I've been looking into using actual methods compiled with CodeDom instead but ideally I want to support both so the user can define simple expressions without having to export anything to be read with CodeDom. Is there any bult-in way of converting between a Linq expression tree and a CodeDom expression? If not, that would mean I have to parse both types to generate scripts.
3 Replies
TheBoxyBear
TheBoxyBear2y ago
The scripts in questions are officially supported by the software through an api, it's just a bit of a pain to write manually. The idea is I would recreate the api definitions as reference so you can simulate calling it in your c# code to be converted. Seems the codedom expressions I was looking at is only foe generating source. Looking into code analysis with Roslyn now.
Thinker
Thinker2y ago
Why were you using CodeDom in the first place? It's been deprecated ever since Roslyn came around There might be some API for turning System.Linq.Expressions expressions into Roslyn IOperations
TheBoxyBear
TheBoxyBear2y ago
Only thing I found at the time for runtime compilation. Just heard about the Roslyn tools