-
-
Notifications
You must be signed in to change notification settings - Fork 155
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: support mappers nested in classes (#354)
- Loading branch information
Showing
10 changed files
with
193 additions
and
20 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
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
16 changes: 16 additions & 0 deletions
16
test/Riok.Mapperly.IntegrationTests/Mapper/NestedMapper.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,16 @@ | ||
using Riok.Mapperly.Abstractions; | ||
|
||
namespace Riok.Mapperly.IntegrationTests.Mapper | ||
{ | ||
public static partial class NestedTestMapper | ||
{ | ||
public static partial class TestNesting | ||
{ | ||
[Mapper] | ||
public static partial class NestedMapper | ||
{ | ||
public static partial int ToInt(decimal value); | ||
} | ||
} | ||
} | ||
} |
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,26 @@ | ||
using System.Threading.Tasks; | ||
using FluentAssertions; | ||
using Riok.Mapperly.IntegrationTests.Mapper; | ||
using VerifyXunit; | ||
using Xunit; | ||
|
||
namespace Riok.Mapperly.IntegrationTests | ||
{ | ||
[UsesVerify] | ||
public class NestedMapperTest : BaseMapperTest | ||
{ | ||
[Fact] | ||
public Task SnapshotGeneratedSource() | ||
{ | ||
var path = GetGeneratedMapperFilePath($"{nameof(NestedTestMapper)}.{nameof(NestedTestMapper.TestNesting)}.{nameof(NestedTestMapper.TestNesting.NestedMapper)}"); | ||
return Verifier.VerifyFile(path); | ||
} | ||
|
||
[Fact] | ||
public void RunMappingShouldWork() | ||
{ | ||
var v = NestedTestMapper.TestNesting.NestedMapper.ToInt(10.25m); | ||
v.Should().Be(10); | ||
} | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
...y.IntegrationTests/_snapshots/NET_48/NestedMapperTest.SnapshotGeneratedSource.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 @@ | ||
#nullable enable | ||
namespace Riok.Mapperly.IntegrationTests.Mapper | ||
{ | ||
public static partial class NestedTestMapper | ||
{ | ||
public static partial class TestNesting | ||
{ | ||
public static partial class NestedMapper | ||
{ | ||
public static partial int ToInt(decimal value) | ||
{ | ||
return (int)value; | ||
} | ||
} | ||
} | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
...Tests/_snapshots/Roslyn_4_4_OR_LOWER/NestedMapperTest.SnapshotGeneratedSource.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 @@ | ||
#nullable enable | ||
namespace Riok.Mapperly.IntegrationTests.Mapper | ||
{ | ||
public static partial class NestedTestMapper | ||
{ | ||
public static partial class TestNesting | ||
{ | ||
public static partial class NestedMapper | ||
{ | ||
public static partial int ToInt(decimal value) | ||
{ | ||
return (int)value; | ||
} | ||
} | ||
} | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
...tegrationTests/_snapshots/Roslyn_4_5/NestedMapperTest.SnapshotGeneratedSource.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 @@ | ||
#nullable enable | ||
namespace Riok.Mapperly.IntegrationTests.Mapper | ||
{ | ||
public static partial class NestedTestMapper | ||
{ | ||
public static partial class TestNesting | ||
{ | ||
public static partial class NestedMapper | ||
{ | ||
public static partial int ToInt(decimal value) | ||
{ | ||
return (int)value; | ||
} | ||
} | ||
} | ||
} | ||
} |
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
15 changes: 15 additions & 0 deletions
15
...shots/MapperTest.MapperInNestedClassShouldWork#CarFeature.Mappers.CarMapper.g.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,15 @@ | ||
//HintName: CarFeature.Mappers.CarMapper.g.cs | ||
#nullable enable | ||
public static partial class CarFeature | ||
{ | ||
public static partial class Mappers | ||
{ | ||
public partial class CarMapper | ||
{ | ||
public partial int ToInt(double value) | ||
{ | ||
return (int)value; | ||
} | ||
} | ||
} | ||
} |