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

Dictionary<string,string> map to IDictionary<string,string> failed #225

Closed
zlzforever opened this issue Feb 24, 2020 · 0 comments
Closed

Comments

@zlzforever
Copy link

`

	public class Source
	{
		public Dictionary<string, string> Dict { get; set; } = new Dictionary<string, string> {{"a", "b"}};
	}

	public class Destination
	{
		public IDictionary<string, string> Dict { get; set; }
	}

	public static void Main(string[] args)
	{
		var a = new Source().Adapt<Destination>();
             }

`

Then the exception is:

Unhandled exception. System.TypeInitializationException: The type initializer for 'Mapster.TypeAdapter2' threw an exception. ---> Mapster.CompileException: Error while compiling source=System.Collections.Generic.Dictionary2[System.String,System.String]
destination=System.Collections.Generic.IDictionary2[System.String,System.String] type=Map ---> System.TypeLoadException: Signature of the body and declaration in a method implementation do not match. Type: 'GeneratedType_1'. Assembly: 'Mapster.Dynamic, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'. at System.Reflection.Emit.TypeBuilder.CreateTypeNoLock() at System.Reflection.Emit.TypeBuilder.CreateTypeInfo() at Mapster.Utils.DynamicTypeGenerator.CreateTypeForInterface(Type interfaceType) at System.Collections.Concurrent.ConcurrentDictionary2.GetOrAdd(TKey key, Func2 valueFactory) at Mapster.Utils.DynamicTypeGenerator.GetTypeForInterface(Type interfaceType) at Mapster.Adapters.BaseAdapter.CreateInstantiationExpression(Expression source, Expression destination, CompileArgument arg) at Mapster.Adapters.ClassAdapter.CreateInstantiationExpression(Expression source, Expression destination, CompileArgument arg) at Mapster.Adapters.BaseAdapter.CreateBlockExpressionBody(Expression source, Expression destination, CompileArgument arg) at Mapster.Adapters.BaseAdapter.CreateExpressionBody(Expression source, Expression destination, CompileArgument arg) at Mapster.Adapters.BaseAdapter.CreateAdaptFunc(CompileArgument arg) at Mapster.TypeAdapterConfig.CreateMapExpression(CompileArgument arg) --- End of inner exception stack trace --- at Mapster.TypeAdapterConfig.CreateMapExpression(CompileArgument arg) at Mapster.TypeAdapterConfig.CreateMapExpression(TypeTuple tuple, MapType mapType) at Mapster.TypeAdapterConfig.<GetMapFunction>b__59_0(TypeTuple tuple) at Mapster.TypeAdapterConfig.AddToHash[T](Dictionary2 hash, TypeTuple key, Func2 func) at Mapster.TypeAdapterConfig.GetMapFunction(Type sourceType, Type destinationType) at Mapster.TypeAdapterConfig.GetMapFunction[TSource,TDestination]() at Mapster.TypeAdapter2..cctor()
--- End of inner exception stack trace ---
at lambda_method(Closure , Object )
at Mapster.TypeAdapter.Adapt[TDestination](Object source, TypeAdapterConfig config)
at Mapster.TypeAdapter.Adapt[TDestination](Object source)

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

1 participant