mapperly icon indicating copy to clipboard operation
mapperly copied to clipboard

Property with private or internal setter are not mapped

Open cs-clarence opened this issue 6 months ago • 5 comments

Describe the bug Pubic property with private setter are not mapped even with IncludedMembers = MemberVisibility.All applied

Declaration code https://dotnetfiddle.net/E4iGqY - reproduction

using System;
using Riok.Mapperly.Abstractions;

public class User(string emailAddress) 
{
	public string EmailAddress { get; private set; } = emailAddress;
}

public record UserUpdateDto(string EmailAddress);

[Mapper(IncludedMembers = MemberVisibility.All)]
public static partial class UserMapper 
{
	static partial void ApplyTo(this UserUpdateDto input, User user);
	
	public static void ApplyUpdates(this UserUpdateDto input, User user) 
	{
		UserMapper.ApplyTo(input, user);
	}
}
					
public class Program
{
	public static void Main()
	{
		var user = new User("[email protected]");
		var updates = new UserUpdateDto("[email protected]");
		
		updates.ApplyUpdates(user);
		
		Console.WriteLine(user.EmailAddress); // still shows [email protected]
	}
}

Environment (please complete the following information):

  • Mapperly Version: 3.6.0
  • Nullable reference types: enabled
  • .NET Version: .NET 8.0
  • Target Framework: .NET 8.0
  • Compiler Version: 8.0

cs-clarence avatar Aug 17 '24 23:08 cs-clarence