A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/MapsterMapper/Mapster/issues/256 below:

Unable to enable non-public members in nested dictionary mapping. · Issue #256 · MapsterMapper/Mapster · GitHub

    public class Pet
    {
        public string Name { get; set; }
        private string Color { get; set; }
    }

    class Program
    {
        static void Main(string[] args)
        {
            var config = new TypeAdapterConfig();
            config.ForType<IDictionary<string, object>, Pet>()
                .EnableNonPublicMembers(false);

            var pet = new Dictionary<string, object>() { { "Name", "Fluffy" }, { "Color", "White" } }.Adapt<Pet>(config);
        }
    }

If you change EnableNonPublicMembers to true it will make both members null. I believe the correct behavior would be to return an instance of Pet with both Name and Color initialized with their respective values.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4