Users Pricing

forum

Home Forums Saving C# Expression Tree to a File – MindStick

Saving C# Expression Tree to a File

marcel ethan 3853 09 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"?


1 Answers

Markdown for AI

A clean, structured version of this page for AI assistants and LLMs.

Open .md