What am I doing wrong? #515
-
I have the following: public readonly record struct Email
{
public string Address { get; init; }
} [StronglyTypedId(
StronglyTypedIdBackingType.Guid,
converters: StronglyTypedIdConverter.SystemTextJson)]
public partial struct ProfileId
{
}
public class Profile
{
public ProfileId Id { get; init; }
public Email Email { get; init; }
} public class UpdateProfileRequest
{
public Guid ProfileId { get; set; }
public string Email { get; set; } = string.Empty;
} Mapperly does not seem to like the next level of nesting with E.g. public static partial class Mapper
{
[MapProperty(nameof(UpdateProfileRequest.ProfileId), nameof(Profile.Id))]
[MapProperty(nameof(UpdateProfileRequest.Email), nameof(Profile.Email.Address))]
internal static partial Profile UpdateProfileRequestToProfile(UpdateProfileRequest req); This outputs
|
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 5 replies
-
The second error is due to Mapperly attempting to automatically resolve the mapping of Use the following instead: [MapProperty(nameof(UpdateProfileRequest.Email), "Email.Address")] |
Beta Was this translation helpful? Give feedback.
-
Please do, I have a couple ideas of how to resolve this in the future. It would be handy to have something to point to. I also found a bug trying to help you 😄
Just thought of something. Try the following: [MapProperty(nameof(UpdateProfileRequest.ProfileId), nameof(Profile.Id))]
internal static partial Profile UpdateProfileRequestToProfile(UpdateProfileRequest req);
private static Email Map(string value)
{
return new Email() { Address = value};
} Mapperly will see a matching |
Beta Was this translation helpful? Give feedback.
-
That works a treat thanks. So just so I understand if there is a |
Beta Was this translation helpful? Give feedback.
Please do, I have a couple ideas of how to resolve this in the future. It would be handy to have something to point to. I also found a bug trying to help you 😄
Just thought of something. Try the following:
Mapperly will see a matching
Email
member on the source and attempt to mapstring
->Email
, …