Skip to content

Commit

Permalink
clarify abstractions conditional scope
Browse files Browse the repository at this point in the history
  • Loading branch information
latonz committed Oct 15, 2024
1 parent 5333523 commit b17e2c9
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
12 changes: 10 additions & 2 deletions docs/docs/getting-started/installation.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,7 @@ Checkout the latest stable version [here](https://mapperly.riok.app).
### Preserving the attributes at runtime

Mapperly removes the attribute references at compile time by default (they have the `ConditionalAttribute`).
If you want
to preserve the attribute references at runtime
If you want to preserve the attribute references at runtime
you can set the MSBuild variable `MapperlyAbstractionsScope` to `runtime`.

```xml
Expand All @@ -74,3 +73,12 @@ you can set the MSBuild variable `MapperlyAbstractionsScope` to `runtime`.
When preserving the attribute usages, the Mapperly package reference needs to include the runtime assets.
Make sure `ExcludeAssets` on the `PackageReference` does not include `runtime`.
:::

:::info
`MapperlyAbstractionsScope` only works in projects referencing `Riok.Mapperly` directly.
Alternatively you can set a constant `MAPPERLY_ABSTRACTIONS_SCOPE_RUNTIME`:
```xml
<PropertyGroup>
<DefineConstants>$(DefineConstants);MAPPERLY_ABSTRACTIONS_SCOPE_RUNTIME</DefineConstants>
</PropertyGroup>
:::
12 changes: 6 additions & 6 deletions src/Riok.Mapperly.Abstractions/MapperAttribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@ public class MapperAttribute : Attribute
/// </summary>
public EnumMappingStrategy EnumMappingStrategy { get; set; } = EnumMappingStrategy.ByValue;

/// <summary>
/// Defines the strategy to use when mapping an enum from/to string.
/// Can be overwritten on specific enums via mapping method configurations.
/// </summary>
public EnumNamingStrategy EnumNamingStrategy { get; set; } = EnumNamingStrategy.MemberName;

/// <summary>
/// Whether the case should be ignored for enum mappings.
/// </summary>
Expand Down Expand Up @@ -125,10 +131,4 @@ public class MapperAttribute : Attribute
/// partial methods are discovered.
/// </summary>
public bool AutoUserMappings { get; set; } = true;

/// <summary>
/// Defines the strategy to use when mapping an enum from/to string.
/// Can be overwritten on specific enums via mapping method configurations.
/// </summary>
public EnumNamingStrategy EnumNamingStrategy { get; set; } = EnumNamingStrategy.MemberName;
}

0 comments on commit b17e2c9

Please sign in to comment.