Skip to content

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

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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