-
-
Notifications
You must be signed in to change notification settings - Fork 141
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Increase RMG060 default severity from info to warning
- Loading branch information
Showing
15 changed files
with
92 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
--- | ||
sidebar_label: RMG060 | ||
description: 'Mapperly analyzer diagnostic RMG060 — Multiple user mappings discovered without specifying an explicit default' | ||
--- | ||
|
||
import Tabs from '@theme/Tabs'; | ||
import TabItem from '@theme/TabItem'; | ||
|
||
# RMG060 — Multiple user-mappings discovered without specifying an explicit default | ||
|
||
Multiple user-mappings for the same type pair are discovered | ||
without specifying an explicit default. | ||
Mapperly needs to now which mapping it should use. | ||
|
||
To specify a default apply `[UserMapping(Default = true)]`. | ||
|
||
See also [user-implemented mappings](../user-implemented-methods.mdx#default-user-implemented-mapping-method). | ||
|
||
## Example | ||
|
||
Two mappings from `Car` to `CarDto` are defined. | ||
When Mapperly needs to map from `Car` to `CarDto` in `CarsToCarDtos` | ||
it needs to know whether to use `CarToCarDto` or `CarToCarDtoIgnoreId`. | ||
Apply `[UserMapping(Default = true)]` to the mapping which Mapperly should use | ||
in such cases. | ||
|
||
<Tabs> | ||
<TabItem value="bad" label="Invalid" default> | ||
```csharp | ||
[Mapper] | ||
public partial class CarMapper | ||
{ | ||
public paratial List<CarDto> CarsToCarDtos(List<Car> cars); | ||
|
||
public partial CarDto CarToCarDto(Car car); | ||
|
||
[MapperIgnoreSource(nameof(Car.Id))] | ||
public partial CarDto CarToCarDtoIgnoreId(Car car); | ||
} | ||
``` | ||
</TabItem> | ||
<TabItem value="fixed" label="Fixed"> | ||
```csharp | ||
[Mapper] | ||
public partial class CarMapper | ||
{ | ||
public paratial List<CarDto> CarsToCarDtos(List<Car> cars); | ||
|
||
// highlight-start | ||
[UserMapping(Default = true)] | ||
// highlight-end | ||
public partial CarDto CarToCarDto(Car car); | ||
|
||
[MapperIgnoreSource(nameof(Car.Id))] | ||
public partial CarDto CarToCarDtoIgnoreId(Car car); | ||
} | ||
``` | ||
</TabItem> | ||
</Tabs> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters