Skip to content

Debugging

chaowlert edited this page Apr 13, 2019 · 10 revisions

Step-into debugging

PM> Install-Package ExpressionDebugger

This plugin allow you to perform step-into debugging!

Usage

Then add following code on start up (or anywhere before mapping is compiled)

var opt = new ExpressionCompilationOptions { IsRelease = !Debugger.IsAttached };
TypeAdapterConfig.GlobalSettings.Compiler = exp => exp.CompileWithDebugInfo(opt);

Now on your mapping code (only in DEBUG mode).

var dto = poco.Adapt<SimplePoco, SimpleDto>(); //<--- you can step-into this function!!

image

Using internal classes or members

private, protected and internal don't allow in debug mode.

Get mapping script

We can also see how Mapster generate mapping logic with ToScript method.

var script = poco.BuildAdapter()
                .CreateMapExpression<SimpleDto>()
                .ToScript();

Visual Studio for Mac

To step-into debugging, you might need to emit file

var opt = new ExpressionCompilationOptions { IsRelease = !Debugger.IsAttached, EmitFile = true };
TypeAdapterConfig.GlobalSettings.Compiler = exp => exp.CompileWithDebugInfo(opt);
...
var dto = poco.Adapt<SimplePoco, SimpleDto>(); //<-- you can step-into this function!!
You can’t perform that action at this time.