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

Private mapper do not work when the parent class implement an interface. #606

Closed
SebastianStehle opened this issue Jul 29, 2023 · 9 comments

Comments

@SebastianStehle
Copy link

SebastianStehle commented Jul 29, 2023

Describe the bug

I have the basic setup:

internal sealed class UserWithClaims : IUser
{
   private readonly IdentityUser snapshot;

   public UserWithClaims(IdentityUser user, IReadOnlyList<Claim> claims, IReadOnlySet<string> roles)
   {
       // Clone the user so that we capture the previous values, even when the user is updated.
       snapshot = Mapper.IdentityUserToIdentityUser(user);
   }

   [Mapper(UseDeepCloning = true)]
   private static partial class Mapper
   {
       public static partial IdentityUser IdentityUserToIdentityUser(IdentityUser source);
   }
}

But the generated code does not add the namespace to the IUser interface, which is defined in another namespace. So the follow code is generated:

#nullable enable
namespace Notifo.Identity
{
    internal sealed class UserWithClaims : IUser
    {
        private static partial class Mapper
        {
            public static partial global::Microsoft.AspNetCore.Identity.IdentityUser IdentityUserToIdentityUser(global::Microsoft.AspNetCore.Identity.IdentityUser source)
            {
                var target = new global::Microsoft.AspNetCore.Identity.IdentityUser();
                target.Id = source.Id;
                ...
                return target;
            }
        }
    }
}

Expected behavior
The implementing or base classes do not need to be copied to the generated code. if you want to copy that, add the namespaces.

Environment (please complete the following information):

  • Mapperly Version: 2.8.0
  • .NET Version: 7.0

Additional context
Add any other context about the problem here.

@SebastianStehle
Copy link
Author

Sorry, I just realized that private mappers do not work anyway.

@TimothyMakkison
Copy link
Collaborator

TimothyMakkison commented Jul 29, 2023

Hey, thanks for the bug report. I think I can fix this issue

Sorry, I just realized that private mappers do not work anyway.

Private mappers should be supported, just make the containing class partial.
You didn't mean something like #599 did you?

@TimothyMakkison
Copy link
Collaborator

TimothyMakkison commented Jul 29, 2023

This bug has been fixed in 2.9.0-next.4

See #548 for details.

@juanyacovino77

This comment was marked as off-topic.

@TimothyMakkison

This comment was marked as off-topic.

@juanyacovino77

This comment was marked as off-topic.

@TimothyMakkison

This comment was marked as off-topic.

@latonz

This comment was marked as resolved.

@latonz
Copy link
Contributor

latonz commented Aug 1, 2023

@SebastianStehle can you reproduce your issue with 2.9.0-next.4?

@latonz latonz closed this as not planned Won't fix, can't repro, duplicate, stale Aug 1, 2023
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

4 participants