forum

Home / DeveloperSection / Forums / Saving C# Expression Tree to a File

Saving C# Expression Tree to a File

marcel ethan327809-Feb-2014

I want to debug an expression and save the expression tree to a file:

 

var generator = DebugInfoGenerator.CreatePdbGenerator();

var document = Expression.SymbolDocument(fileName: "MyDebug.txt");

var debugInfo = Expression.DebugInfo(document, 6, 9, 6, 22);

var expressionBlock = Expression.Block(debugInfo, fooExpression);

var lambda = Expression.Lambda(expressionBlock, parameters);

lambda.CompileToMethod(method, generator);

var bakedType = type.CreateType();

return (type)bakedType.GetMethod(method.Name).Invoke(null, parameters);

How can I find or save "MyDebug.txt"?


Updated on 09-Feb-2014

Can you answer this question?


Answer

1 Answers

Liked By