-
-
Notifications
You must be signed in to change notification settings - Fork 143
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: get mapper defaults for roslyn version smaller 4.4
- Loading branch information
Showing
5 changed files
with
73 additions
and
6 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,28 @@ | ||
using System.Threading.Tasks; | ||
using Riok.Mapperly.IntegrationTests.Helpers; | ||
using Riok.Mapperly.IntegrationTests.Mapper; | ||
using VerifyXunit; | ||
using Xunit; | ||
|
||
namespace Riok.Mapperly.IntegrationTests | ||
{ | ||
[UsesVerify] | ||
public class EnumMapperTest : BaseMapperTest | ||
{ | ||
[Fact] | ||
[VersionedSnapshot(Versions.NET7_0)] | ||
public Task SnapshotGeneratedSource() | ||
{ | ||
var path = GetGeneratedMapperFilePath(nameof(EnumMapper)); | ||
return Verifier.VerifyFile(path); | ||
} | ||
|
||
[Fact] | ||
[VersionedSnapshot(Versions.NET7_0)] | ||
public Task RunMappingShouldWork() | ||
{ | ||
var enum2 = Enum1.Value1.Map(); | ||
return Verifier.Verify(enum2); | ||
} | ||
} | ||
} |
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,24 @@ | ||
using Riok.Mapperly.Abstractions; | ||
|
||
[assembly: MapperDefaults(EnumMappingStrategy = EnumMappingStrategy.ByName)] | ||
|
||
namespace Riok.Mapperly.IntegrationTests.Mapper | ||
{ | ||
[Mapper] | ||
public static partial class EnumMapper | ||
{ | ||
public static partial Enum2 Map(this Enum1 e); | ||
} | ||
|
||
public enum Enum1 | ||
{ | ||
Value1 = 4, | ||
Value2 = 7, | ||
} | ||
|
||
public enum Enum2 | ||
{ | ||
Value1, | ||
Value2, | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
...perly.IntegrationTests/_snapshots/EnumMapperTest.RunMappingShouldWork_NET7_0.verified.txt
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 @@ | ||
Value1 |
17 changes: 17 additions & 0 deletions
17
...rly.IntegrationTests/_snapshots/EnumMapperTest.SnapshotGeneratedSource_NET7_0.verified.cs
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,17 @@ | ||
// <auto-generated /> | ||
#nullable enable | ||
namespace Riok.Mapperly.IntegrationTests.Mapper | ||
{ | ||
public static partial class EnumMapper | ||
{ | ||
public static partial global::Riok.Mapperly.IntegrationTests.Mapper.Enum2 Map(this global::Riok.Mapperly.IntegrationTests.Mapper.Enum1 e) | ||
{ | ||
return e switch | ||
{ | ||
global::Riok.Mapperly.IntegrationTests.Mapper.Enum1.Value1 => global::Riok.Mapperly.IntegrationTests.Mapper.Enum2.Value1, | ||
global::Riok.Mapperly.IntegrationTests.Mapper.Enum1.Value2 => global::Riok.Mapperly.IntegrationTests.Mapper.Enum2.Value2, | ||
_ => throw new System.ArgumentOutOfRangeException(nameof(e), e, "The value of enum Enum1 is not supported"), | ||
}; | ||
} | ||
} | ||
} |