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

Compile doesn't throw exceptions while configuring with attributes #666

Open
bugurshik opened this issue Nov 30, 2023 · 0 comments
Open

Comments

@bugurshik
Copy link

While im configuring with attributes

[AdaptFrom(typeof(Foo))]
public record Bar(string Title);
public record Foo(string Name);

These records are supposed to throw an error during Compile(), but it doesn't happen

TypeAdapterConfig.GlobalSettings.RequireDestinationMemberSource= true;
TypeAdapterConfig.GlobalSettings.Compile(); // successfull?? why??
var foo= new Foo("Name");
var bar= foo.Adapt<Bar>(); // Exception: corresponding source member mapped or ignored:Title

On the other hand, if I configure using an interface:
IMapFrom<Foo>
or utilize the method:
TypeAdapterConfig.GlobalSettings.ForType<Bar, Foo>();

In this scenario, everything works fine

TypeAdapterConfig.GlobalSettings.RequireDestinationMemberSource= true;
TypeAdapterConfig.GlobalSettings.Compile(); // Exception: corresponding source member mapped or ignored:Title

Why is this happening?
(lib: Mapster v7.4.0)

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