Skip to content

Automapper tries to map private class #105

Open
@doerig

Description

@doerig

After Upgrading from FNH 1.2 to 1.3 my project threw some runtime exceptions. It turned out that fnh 1.3 tries to map a private nested class. Is this intended behaviour or a bug?

I fixed the problem within the AutomappingConfiguration (checking for IsPublic).

    public class AutomappingConfiguration : DefaultAutomappingConfiguration
    {
        public override bool ShouldMap(Type type)
        {
            return type.IsPublic && type.IsSubclassOf(typeof(ModelBase));
        }
    }

Simplified class-setup:

public class MappedClass : ModelBase
{
}

public class NotMappedClass
{
    private class WhyDoesThisClassGetsMapped : MappedClass
    {
    }
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions