mapperly
БесплатноБез исполняемых скриптовНе проверенUse when writing, editing, or reviewing Mapperly (`Riok.Mapperly`) mapper classes; adding or changing a `[Mapper]`-attributed partial class; configuring…
от 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](defaultBoth), 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.
- Service DTOs (Refit):
- 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
inittargets; 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
ItemToDomaininSonarrV3QualityProfileMapper). - A non-nullable settable property with no initializer stays
nullwhen 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 = falsereplaces the throw with"",new T(), ordefault. It is unused in this repository; collections such asList<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
requiredtarget member has no matching source member.RequiredMappingStrategy .Nonedoes 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.
Установить 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), без исполняемых скриптов.
Похожие скиллы
doc-coauthoring
Guide users through a structured workflow for co-authoring documentation. Use when user wants to write documentation, proposals, technical specs, decision…
от Anthropicacademy-guide
Stop and check this skill before finishing any reply to a question about how to use Claude or a Claude product — it recommends matching courses, tutorials…
от Anthropicinternal-comms
A set of resources to help me write all kinds of internal communications, using the formats that my company likes to use. Claude should use this skill…
от Anthropicskill-development
This skill should be used when the user wants to "create a skill", "add a skill to plugin", "write a new skill", "improve skill description", "organize skill…
от Anthropic