C
Join ServerC#
help
Bridging the gap between Linq expression trees and Roslyn parse
TTheBoxyBear9/18/2022
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.
TTheBoxyBear9/18/2022
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.
TTheBoxyBear9/18/2022
Seems the codedom expressions I was looking at is only foe generating source. Looking into code analysis with Roslyn now.
Tthinker2279/18/2022
Why were you using CodeDom in the first place? It's been deprecated ever since Roslyn came around
Tthinker2279/18/2022
There might be some API for turning System.Linq.Expressions expressions into Roslyn
IOperation
sTTheBoxyBear9/18/2022
Only thing I found at the time for runtime compilation. Just heard about the Roslyn tools