Skip to content

Replace AutoMapper with Riok.Mapperly in TeachingRecordSystem.Api#3308

Draft
Copilot wants to merge 1 commit intomainfrom
copilot/replace-automapper-with-mapperly
Draft

Replace AutoMapper with Riok.Mapperly in TeachingRecordSystem.Api#3308
Copilot wants to merge 1 commit intomainfrom
copilot/replace-automapper-with-mapperly

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 20, 2026

Replaces runtime reflection-based AutoMapper with source-generator-based Riok.Mapperly (4.3.1) across all 12 API version namespaces, eliminating the IMapper abstraction in favour of strongly-typed per-version ApiMapper classes.

Package changes

  • Directory.Packages.props: swap AutoMapperRiok.Mapperly 4.3.1
  • TeachingRecordSystem.Api.csproj: update <PackageReference> accordingly

Per-version ApiMapper classes (×12)

One ApiMapper per version namespace (V20240101V20250627). Complex mappings involving Option<T> / OneOf<> are written manually; flat mappings use Mapperly [Mapper] partial methods with [MapProperty] for renames. Key notes:

  • DqtInductionStatus enum conversion is name-based (not value-based) — values differ by 1 between Implementation.Dtos and V20240101.Dtos
  • Separate MapFindPersonResponseResult / MapFindPersonsResponseResult methods per version where both response shapes exist
  • TrainingAgeSpecialismType cast uses (int) intermediary since values are identical across namespaces

Controllers (all affected versions)

IMapper mapper → typed ApiMapper mapper in primary constructors; mapper.Map<T>(x)mapper.MapX(x).

Infrastructure

  • Extensions.cs: remove AddAutoMapper() + ITypeConverter<,> Scrutor scan; add AddSingleton<VXX.ApiMapper>() for all 12 versions
  • GlobalUsings.cs: remove global using AutoMapper;
  • Deleted: all 11 MapperProfile.cs files, Infrastructure/Mapping/OptionMapper.cs
  • Response DTOs: strip all [AutoMap] / [SourceMember] attributes and their using AutoMapper.Configuration.Annotations; directives (~23 files)

Checklist

  • Attach to Trello card
  • Rebased master
  • Cleaned commit history
  • Tested by running locally

…rs, fix Extensions/GlobalUsings, delete old files

Agent-Logs-Url: https://github.com/DFE-Digital/teaching-record-system/sessions/8b6ce974-583c-4911-8066-c0443ea8a848

Co-authored-by: gunndabad <2041280+gunndabad@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants