I am working on a pet project: A programing language in the Javascript/Scheme mindset the project can be found here
I have looked through existing Stackoverflow questions such as Making a CLR/.NET Language Debuggable. However most of these solutions deal with generating assemblies. For numerous reasons I would prefer to avoid creating a new assembly.
class Program
{
public static void ThrowingFunction()
{
throw new Exception("Test Exception");
}
static void Main(string[] args)
{
Action thw = ThrowingFunction;
ParameterExpression param = Expression.Parameter(typeof(int), "arg");
SymbolDocumentInfo info = Expression.SymbolDocument("example-script", new Guid("83c65910-8376-11e2-9e96-0800200c9a66"));
Expression<Func<int,int>> exp = Expression.Lambda<Func<int,int>>(
Expression.Block(
Expression.DebugInfo(info,1,1,1,20),
Expression.Invoke(Expression.Constant(thw, typeof(Action))),
Expression.Add(param,Expression.Constant(1))
),
new List<ParameterExpression> { param }
);
Console.WriteLine(exp);
Func<int,int> Fn = exp.Compile(DebugInfoGenerator.CreatePdbGenerator());
try {
Fn(1);
}
catch (Exception e) {
Console.WriteLine(e);
Console.WriteLine(e.InnerException);
}
}
}
The above code works however the debug info does not contain the line information for the lambda instead referring obliquely to lambda_method with no other information in the stack trace.
How can I get the stack trace to also show line information.