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

RuntimeBinderException if TSource is a non public class #109

Closed
eric-b opened this issue Apr 22, 2017 · 2 comments
Closed

RuntimeBinderException if TSource is a non public class #109

eric-b opened this issue Apr 22, 2017 · 2 comments

Comments

@eric-b
Copy link

eric-b commented Apr 22, 2017

Hi,

FYI this use case is not supported:

void Main()
{
	var sourceOptions = new SourceOptions();

	// RuntimeBinderException thrown here ("Cannot invoke a non-delegate type")
	sourceOptions.Adapt<DestinationOptions>(); 
}

internal class SourceOptions
{
	public string Value { get; set; }
}

internal class DestinationOptions
{
	public string Value { get; set; }
}

Alternative 1:

void Main()
{
	var sourceOptions = new SourceOptions();
	sourceOptions.Adapt<DestinationOptions>();
}

public class SourceOptions
{
	public string Value { get; set; }
}

internal class DestinationOptions
{
	public string Value { get; set; }
}

Alternative 2:

void Main()
{
	var sourceOptions = new SourceOptions();
	sourceOptions.Adapt<SourceOptions, DestinationOptions>(new DestinationOptions());
}

internal class SourceOptions
{
	public string Value { get; set; }
}

internal class DestinationOptions
{
	public string Value { get; set; }
}
@chaowlert
Copy link
Collaborator

Hi, this problem should be fixed in Mapster 3.0. Thx for reporting.

@eric-b
Copy link
Author

eric-b commented Jul 26, 2017

Thanks, I tested on v3 :-)

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