EGG1003 — Consider compile-time mapping with [MapTo]

PropertyValue
SeverityInfo
PackageEggMapper.Analyzers
CategoryEggMapper

Description

A CreateMap<TSource, TDestination>() call has no customization chains (no ForMember, BeforeMap, AfterMap, etc.). Simple maps like this can be replaced with the [MapTo(typeof(TDestination))] attribute and EggMapper.Generator, gaining compile-time type checking and zero-overhead mapping.

ReverseMap() alone is not considered a customization — the diagnostic still fires.

Example (triggers info)

class MyProfile : Profile
{
    public MyProfile()
    {
        CreateMap<Order, OrderDto>();              // EGG1003
        CreateMap<Customer, CustomerDto>()
            .ReverseMap();                         // EGG1003 (ReverseMap alone is not a customization)
        CreateMap<Line, LineDto>()
            .ForMember(d => d.Label, o => ...);   // no diagnostic — has customization
    }
}

How to fix

Install EggMapper.Generator and annotate the source class:

[MapTo(typeof(OrderDto))]
public class Order { ... }

// Usage:
var dto = order.ToOrderDto();

See Attribute Mapper for full details.

How to suppress

#pragma warning disable EGG1003
CreateMap<Order, OrderDto>();
#pragma warning restore EGG1003

Or in .editorconfig:

dotnet_diagnostic.EGG1003.severity = none