From 5b2274fc7c4752f542d846d51e24587eb1ba3144 Mon Sep 17 00:00:00 2001 From: Timothy Makkison Date: Fri, 24 Nov 2023 20:52:19 +0000 Subject: [PATCH] chore: add existing type models --- .../Mapper/StaticTestMapper.cs | 10 ++++++++++ .../Models/ExistingObjects/ExistingObjectBase.cs | 7 +++++++ .../Models/ExistingObjects/ExistingObjectBaseDto.cs | 7 +++++++ .../Models/ExistingObjects/ExistingObjectTypeA.cs | 7 +++++++ .../Models/ExistingObjects/ExistingObjectTypeADto.cs | 7 +++++++ .../Models/ExistingObjects/ExistingObjectTypeB.cs | 7 +++++++ .../Models/ExistingObjects/ExistingObjectTypeBDto.cs | 7 +++++++ 7 files changed, 52 insertions(+) create mode 100644 test/Riok.Mapperly.IntegrationTests/Models/ExistingObjects/ExistingObjectBase.cs create mode 100644 test/Riok.Mapperly.IntegrationTests/Models/ExistingObjects/ExistingObjectBaseDto.cs create mode 100644 test/Riok.Mapperly.IntegrationTests/Models/ExistingObjects/ExistingObjectTypeA.cs create mode 100644 test/Riok.Mapperly.IntegrationTests/Models/ExistingObjects/ExistingObjectTypeADto.cs create mode 100644 test/Riok.Mapperly.IntegrationTests/Models/ExistingObjects/ExistingObjectTypeB.cs create mode 100644 test/Riok.Mapperly.IntegrationTests/Models/ExistingObjects/ExistingObjectTypeBDto.cs diff --git a/test/Riok.Mapperly.IntegrationTests/Mapper/StaticTestMapper.cs b/test/Riok.Mapperly.IntegrationTests/Mapper/StaticTestMapper.cs index a5623620ac..73adc8b87d 100644 --- a/test/Riok.Mapperly.IntegrationTests/Mapper/StaticTestMapper.cs +++ b/test/Riok.Mapperly.IntegrationTests/Mapper/StaticTestMapper.cs @@ -3,6 +3,7 @@ using Riok.Mapperly.Abstractions; using Riok.Mapperly.IntegrationTests.Dto; using Riok.Mapperly.IntegrationTests.Models; +using Riok.Mapperly.IntegrationTests.Models.ExistingObjects; namespace Riok.Mapperly.IntegrationTests.Mapper { @@ -91,6 +92,15 @@ public static void MapExistingList(List src, List dst) public static partial TTarget MapGeneric(TSource source); +#if NET7_0_OR_GREATER + [MapDerivedType] + [MapDerivedType] +#else + [MapDerivedType(typeof(ExistingObjectTypeA), typeof(ExistingObjectTypeADto))] + [MapDerivedType(typeof(ExistingObjectTypeB), typeof(ExistingObjectTypeBDto))] +#endif + public static partial void MapToDerivedExisting(ExistingObjectBase source, ExistingObjectBaseDto target); + [MapEnum(EnumMappingStrategy.ByName)] public static partial TestEnumDtoByName MapToEnumDtoByName(TestEnum v); diff --git a/test/Riok.Mapperly.IntegrationTests/Models/ExistingObjects/ExistingObjectBase.cs b/test/Riok.Mapperly.IntegrationTests/Models/ExistingObjects/ExistingObjectBase.cs new file mode 100644 index 0000000000..f079b6b3a6 --- /dev/null +++ b/test/Riok.Mapperly.IntegrationTests/Models/ExistingObjects/ExistingObjectBase.cs @@ -0,0 +1,7 @@ +namespace Riok.Mapperly.IntegrationTests.Models.ExistingObjects +{ + public class ExistingObjectBase + { + public int Value { get; set; } + } +} diff --git a/test/Riok.Mapperly.IntegrationTests/Models/ExistingObjects/ExistingObjectBaseDto.cs b/test/Riok.Mapperly.IntegrationTests/Models/ExistingObjects/ExistingObjectBaseDto.cs new file mode 100644 index 0000000000..fcaa00ba26 --- /dev/null +++ b/test/Riok.Mapperly.IntegrationTests/Models/ExistingObjects/ExistingObjectBaseDto.cs @@ -0,0 +1,7 @@ +namespace Riok.Mapperly.IntegrationTests.Models.ExistingObjects +{ + public class ExistingObjectBaseDto + { + public int Value { get; } + } +} diff --git a/test/Riok.Mapperly.IntegrationTests/Models/ExistingObjects/ExistingObjectTypeA.cs b/test/Riok.Mapperly.IntegrationTests/Models/ExistingObjects/ExistingObjectTypeA.cs new file mode 100644 index 0000000000..f770030b82 --- /dev/null +++ b/test/Riok.Mapperly.IntegrationTests/Models/ExistingObjects/ExistingObjectTypeA.cs @@ -0,0 +1,7 @@ +namespace Riok.Mapperly.IntegrationTests.Models.ExistingObjects +{ + public class ExistingObjectTypeA + { + public int ValueA { get; set; } + } +} diff --git a/test/Riok.Mapperly.IntegrationTests/Models/ExistingObjects/ExistingObjectTypeADto.cs b/test/Riok.Mapperly.IntegrationTests/Models/ExistingObjects/ExistingObjectTypeADto.cs new file mode 100644 index 0000000000..1d1ca8893d --- /dev/null +++ b/test/Riok.Mapperly.IntegrationTests/Models/ExistingObjects/ExistingObjectTypeADto.cs @@ -0,0 +1,7 @@ +namespace Riok.Mapperly.IntegrationTests.Models.ExistingObjects +{ + public class ExistingObjectTypeADto + { + public int ValueA { get; } + } +} diff --git a/test/Riok.Mapperly.IntegrationTests/Models/ExistingObjects/ExistingObjectTypeB.cs b/test/Riok.Mapperly.IntegrationTests/Models/ExistingObjects/ExistingObjectTypeB.cs new file mode 100644 index 0000000000..44de25fd14 --- /dev/null +++ b/test/Riok.Mapperly.IntegrationTests/Models/ExistingObjects/ExistingObjectTypeB.cs @@ -0,0 +1,7 @@ +namespace Riok.Mapperly.IntegrationTests.Models.ExistingObjects +{ + public class ExistingObjectTypeB + { + public int ValueB { get; set; } + } +} diff --git a/test/Riok.Mapperly.IntegrationTests/Models/ExistingObjects/ExistingObjectTypeBDto.cs b/test/Riok.Mapperly.IntegrationTests/Models/ExistingObjects/ExistingObjectTypeBDto.cs new file mode 100644 index 0000000000..6f044caaba --- /dev/null +++ b/test/Riok.Mapperly.IntegrationTests/Models/ExistingObjects/ExistingObjectTypeBDto.cs @@ -0,0 +1,7 @@ +namespace Riok.Mapperly.IntegrationTests.Models.ExistingObjects +{ + public class ExistingObjectTypeBDto + { + public int ValueB { get; set; } + } +}