Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 408
Debugging
Atilla Lonny edited this page Aug 13, 2020
·
13 revisions
PM> Install-Package ExpressionDebugger
This plugin allows you to perform step-into debugging using Roslyn!
Then add following code on start up (or anywhere before mapping is compiled)
TypeAdapterConfig.GlobalSettings.Compiler= exp =>exp.CompileWithDebugInfo();Now in your mapping code (only in DEBUG mode).
vardto=poco.Adapt<SimplePoco,SimpleDto>();//<--- you can step-into this function!!
private, protected and internal aren't allowed in debug mode.
We can also see how Mapster generates mapping logic with ToScript method.
var script = poco.BuildAdapter()
.CreateMapExpression<SimpleDto>()
.ToScript();
To step-into debugging, you might need to emit file
varopt=newExpressionCompilationOptions{EmitFile=true};TypeAdapterConfig.GlobalSettings.Compiler= exp =>exp.CompileWithDebugInfo(opt);
...var dto =poco.Adapt<SimplePoco,SimpleDto>();//<-- you can step-into this function!!In RELEASE mode, Roslyn compiler is actually faster than default dynamic compilation by 2x.
Here is the result:
| Method | Mean | StdDev | Error | Gen 0 | Gen 1 | Gen 2 | Allocated |
|---|---|---|---|---|---|---|---|
| 'Mapster 4.1.1' | 115.31 ms | 0.849 ms | 1.426 ms | 31000.0000 | - | - | 124.36 MB |
| 'Mapster 4.1.1 (Roslyn)' | 53.55 ms | 0.342 ms | 0.654 ms | 31100.0000 | - | - | 124.36 MB |