mapperly

Configure C# Mapperly mappers with null-handling conventions for DTO-to-domain mappings.

2.1k|36|Updated Feb 4, 2021
One-click install
npx skills add https://github.com/recyclarr/recyclarr --skill mapperly
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: mapperly
Source: https://github.com/recyclarr/recyclarr/tree/main/.opencode/skills/mapperly
Command: npx skills add https://github.com/recyclarr/recyclarr --skill mapperly

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill helps developers write and maintain Mapperly mapper classes in C#, ensuring correct conventions and handling of null-safety in generated mapping code, especially when dealing with DTOs and domain models.

Core Features & Use Cases

  • Mapper Conventions: Enforces consistent setup for Mapperly mappers, including RequiredMappingStrategy.None and internal static partial class definitions.
  • Null Handling: Provides clear guidance on how Mapperly handles nulls when mapping from nullable DTO properties to non-nullable domain properties, covering various C# constructs like constructor parameters and init-only properties.
  • Diagnostic Management: Explains the RMG089 diagnostic and why it typically doesn't require suppression.
  • Inspecting Generated Code: Offers a method to view the code generated by Mapperly for debugging.
  • Use Case: When adding new DTO-to-domain mappings for an API response, use this Skill to ensure the mappers are configured correctly and handle potential null values gracefully according to established conventions.

Quick Start

Use the mapperly skill to generate a new mapper class for converting Sonarr API DTOs to domain models.

Frequently Asked Questions about mapperly

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I handle nullable DTO properties when mapping to non-nullable domain models in C#?

Mapperly handles nulls during C# DTO mapping by providing clear guidance on default value substitutions and assignment skipping behaviors for constructor parameters and init-only properties. This ensures generated code safely bridges nullable DTOs to non-nullable domain models.

What conventions should I use for Mapperly code generation classes?

Mapperly code generation conventions require setting `RequiredMappingStrategy.None` and defining mappers as `internal static partial class`. Enforcing this consistent setup ensures correct source-generated mapper behavior across your C# codebase.

How can I inspect and debug C# source-generated mapper code?

To inspect generated C# mapper code for debugging, you can view the source-generated files produced by Mapperly. This allows you to directly examine the mapping logic and troubleshoot issues like incorrect null handling or assignment failures.

Does the RMG089 diagnostic in Mapperly need to be suppressed?

The RMG089 diagnostic in Mapperly typically does not require suppression. This Skill explains the diagnostic and why it is generally safe to ignore, helping you manage Mapperly diagnostic management without unnecessary code changes.

How do I add new DTO-to-domain mappings for an API response in C#?

To add new DTO-to-domain mappings for a C# API response, use this Skill to configure mappers correctly and handle potential null values gracefully. It ensures your source-generated mappers follow established conventions for domain models.