Command Palette

Search for a command to run...

UnylyUnyly
Назад к скиллам

mapperly

БесплатноБез исполняемых скриптовНе проверен

Use when writing, editing, or reviewing Mapperly (`Riok.Mapperly`) mapper classes; adding or changing a `[Mapper]`-attributed partial class; configuring…

recyclarrот recyclarr★ 2 180 звёзд на GitHub

Об этом скилле

Mapperly

Repository conventions and verified null-handling behavior for Mapperly mappers. Behavior below was observed in generated output from Riok.Mapperly 4.3.1 (pinned in Directory.Packages.props). Re-verify against generated code after a Mapperly upgrade.

Mapper Conventions

  • Strictness by mapping kind:
    • Service DTOs (Refit): [Mapper(RequiredMappingStrategy = RequiredMappingStrategy.None)]; DTOs carry members we don't map, including extension data (silences RMG012, RMG020).
    • Types we own (domain <-> persistence entity): plain [Mapper] (default Both), so an unmapped member fails the build.
    • Existing-target updates ([MappingTarget]) on owned types: [MapperRequiredMapping(RequiredMappingStrategy.Source)], ignoring only source members that must not be written. Target-only members are covered by the creating mapping; checking them here only adds ignore lists.
  • Mappers are internal static partial class.
  • One mapper class per service API generation (SonarrV3*, SonarrV5*, Radarr*). Service DTO types share names but are distinct types; alias namespaces: using SonarrApi = Recyclarr.Api.Sonarr.V3.
  • Domain-to-DTO writes use an existing-target method (void UpdateDto(TDomain, [MappingTarget] TDto)) so DTO fields the domain does not model keep their fetched values.

Null Handling

Refit DTOs declare every property nullable. Mapper settings stay at defaults (ThrowOnMappingNullMismatch = true, AllowNullPropertyAssignment = true). The generated code for a null source value depends on the target member shape:

Target member Null source value
Nullable (T?) Assigned, including null
Non-nullable constructor parameter ?? throw ArgumentNullException
Non-nullable init or required (with or without =) ?? throw ArgumentNullException
Non-nullable settable (set) Assignment skipped; prior value stays

Consequences:

  • Property initializers never act as fallbacks for constructor or init targets; the generated object initializer overwrites them or throws. public string Name { get; init; } = ""; still throws when the DTO field is null.
  • A field that Sonarr/Radarr may omit needs a nullable domain property, or a user-implemented method that supplies the fallback (see ItemToDomain in SonarrV3QualityProfileMapper).
  • A non-nullable settable property with no initializer stays null when the source is null, silently violating its contract. Avoid this shape.
  • In UpdateDto, a null domain value overwrites the DTO field with null, because DTO targets are nullable.
  • ThrowOnMappingNullMismatch = false replaces the throw with "", new T(), or default. It is unused in this repository; collections such as List<T> still throw and report RMG002.

Diagnostics

  • RMG089 (Info): "Mapping the nullable source property ... to the target property ... which is not nullable". Expected for every nullable DTO to non-nullable domain member; it marks a member that throws or skips per the table above. Check that outcome is intended rather than suppressing it.
  • RMG023 (Error): a required target member has no matching source member. RequiredMappingStrategy .None does not suppress it; add [MapProperty] or a user-implemented method.
  • RMG060 (Warning): multiple user-implemented methods for the same type pair.

User-Implemented Methods

Mapperly discovers any non-partial method in the mapper with a mapping signature and uses it for that type pair, including nested members and collection elements (MapFieldValue in SonarrV3CustomFormatMapper). Parameter and return types must match the mapped types exactly, including nullability.

Verifying Generated Code

Directory.Build.props enables EmitCompilerGeneratedFiles for the whole repository. After a build, find the output with rg --files --no-ignore -g '<Mapper>.g.cs' src/<Project>/obj; it lives under obj/<Configuration>/<tfm>/generated/Riok.Mapperly/Riok.Mapperly.MapperGenerator/. Confirm null handling there instead of inferring it from attributes.

Полный SKILL.md на GitHub

Установить mapperly в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Без ограничений — скилл может использовать любой инструмент.

FAQ

Что делает скилл mapperly?

Use when writing, editing, or reviewing Mapperly (`Riok.Mapperly`) mapper classes; adding or changing a `[Mapper]`-attributed partial class; configuring `RequiredMappingStrategy`, `[MapProperty]`, `[MapperIgnore]`, or other Mapperly attributes; mapping between nullable Refit/OpenAPI DTOs and non-nullable domain records; debugging null-handling in generated mapping code (positional records, `required init`, initializer defaults); investigating Mapperly diagnostics such as RMG023, RMG060, or RMG089; inspecting source-generated output under `obj/*/*/generated/Riok.Mapperly/`. Triggers on phrases like "add a Mapperly mapper", "Mapperly null handling", "DTO to domain mapping", "generated mapper", or edits to files ending in `*Mapper.cs` under `ServarrApi/` or `Persistence/`. Do NOT use for hand-written mapping code or AutoMapper.

Как установить скилл mapperly?

Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.

Скилл mapperly запускает скрипты?

Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.

Похожие скиллы

Сравнить mapperly с