Skip to content

Commit

Permalink
docs: one side strict property mappings (#810)
Browse files Browse the repository at this point in the history
  • Loading branch information
latonz authored Oct 11, 2023
1 parent 9d6c21a commit 7bf0e5e
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions docs/docs/configuration/mapper.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,49 @@ dotnet_diagnostic.RMG012.severity = error # Unmapped target member
dotnet_diagnostic.RMG020.severity = error # Unmapped source member
```

#### One side strict property mappings

To enforce strict mappings on only either the source or the target,
the `RequiredMappingStrategy` can be used.

<!-- do not indent this, it won't work, https://stackoverflow.com/a/67579641/3302887 -->

<Tabs>
<TabItem value="global" label="Global (mapper level)" default>

Sets the `RequiredMappingStrategy` for all methods within the mapper,
by default it is `Both` requiring all members to be mapped.
This can be overriden by individual mapping methods using `MapperRequiredMappingAttribute`.

```csharp
// highlight-start
[Mapper(RequiredMappingStrategy = RequiredMappingStrategy.Source)]
// highlight-end
public partial class CarMapper
{
...
}
```

</TabItem>
<TabItem value="enum" label="Enum (mapping method level)">

Applied to the specific mapping method.

```csharp
[Mapper]
public partial class CarMapper
{
// highlight-start
[MapperRequiredMapping(RequiredMappingStrategy.Source)]
// highlight-end
public partial CarDto MapMake(Car make);
}
```

</TabItem>
</Tabs>

### Strict enum mappings

To enforce strict enum mappings set `RMG037` and `RMG038` to error, see [strict enum mappings](./enum.mdx#strict-enum-mappings).
Expand Down

0 comments on commit 7bf0e5e

Please sign in to comment.