Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question: Is there any way to debug mappings using logging or TraceSource #76

Closed
centur opened this issue Aug 4, 2016 · 2 comments
Closed

Comments

@centur
Copy link
Contributor

centur commented Aug 4, 2016

Hi, the issues we are hitting with using mapster is that error messages are not very descriptive and it's hard to understand which map is missing or which one is set up incorrectly.

Is there any way to enable logging which can produce human-readable or more detailed output when mapster has an error in mapping. Mapster errors are very generic and don't have any information about what exact type mapping is missing or throwing error. Having a detailed log output like this:
var mappingErrors = TypeAdapterConfig.GlobalSettings.Compile(); would be very helpful.

Or maybe let us to pass some simple logger interface implementation which will be used internally to write detailed information about what's exactly goes wrong:

IMapsterLogger logger = new MyMapsterLogger();
TypeAdapterConfig.GlobalSettings.Compile(logger);

Another option is to have mapster specific TraceSource (which is platform dependent but very performant way to log info on Windows) where we can hook and see some extra details about which types are being checked with which settings, in compile phase, and whether they failed or not.

Errors like these are is the same as "Well, some error happened"

System.TypeInitializationException
The type initializer for 'Mapster.TypeAdapter`2' threw an exception.
   at lambda_method(Closure , AnnotationCommandData )
   at Utils.Mapping.DTOMap.Map[TSource,TResult](TSource inputSource) in C:\Projects\xxx\DTOMap.cs:line 42
   at UnitTests.Mappings.DTOMapTests.CheckAllMaps() in C:\Projects\xxx\Mappings\DTOMapTests.cs:line 160

System.InvalidOperationException
Instances of abstract classes cannot be created.
   at System.Runtime.CompilerServices.RuntimeHelpers._CompileMethod(IRuntimeMethodInfo method)
   at System.Reflection.Emit.DynamicMethod.CreateDelegate(Type delegateType, Object target)
   at System.Linq.Expressions.Compiler.LambdaCompiler.Compile(LambdaExpression lambda, DebugInfoGenerator debugInfoGenerator)
   at Mapster.TypeAdapterConfig.CreateMapFunction(TypeTuple tuple)
   at Mapster.TypeAdapterConfig.AddToHash(Hashtable hash, TypeTuple key, Func`2 func)
   at Mapster.TypeAdapterConfig.GetMapFunction[TSource,TDestination]()
   at Mapster.TypeAdapter`2..cctor()
@centur centur changed the title Question: Is there any way to debug mappings using logging or something Question: Is there any way to debug mappings using logging or TraceSource Aug 4, 2016
@chaowlert
Copy link
Collaborator

This is good idea.

@chaowlert
Copy link
Collaborator

Hi, I added debugging feature in Mapster 3.0 (https://github.com/chaowlert/Mapster/wiki/Debugging)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants