Skip to content

Attribute-based Reverse Mapping with SourceMember does not work #3129

@dradovic

Description

@dradovic

Source/destination types

    public class Company
    {
        public int Id { get; set; }
        public string Name { get; set; }
    }

    [AutoMap(typeof(Company), ReverseMap = true)]
    public class ViewModel
    {
        public int Id { get; set; }
        [SourceMember(nameof(Company.Name))]
        public string CompanyName { get; set; }
    }

Mapping configuration

services.AddAutoMapper(Assembly.GetExecutingAssembly());

Versions

<PackageReference Include="AutoMapper" Version="8.1.1" />
<PackageReference Include="AutoMapper.Extensions.Microsoft.DependencyInjection" Version="6.1.1" />

Expected behavior

Reverse mapping of a property attributed with SourceMember should also map the property.

Actual behavior

Mapping does not work.

Steps to reproduce

A full repro repository is found here: AutoMapperAttributeMappingIssue

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions