diff --git a/test/Riok.Mapperly.IntegrationTests/BaseMapperTest.cs b/test/Riok.Mapperly.IntegrationTests/BaseMapperTest.cs
index 96ddb174ce..be39eb8718 100644
--- a/test/Riok.Mapperly.IntegrationTests/BaseMapperTest.cs
+++ b/test/Riok.Mapperly.IntegrationTests/BaseMapperTest.cs
@@ -9,6 +9,7 @@
using Riok.Mapperly.IntegrationTests.Helpers;
using Riok.Mapperly.IntegrationTests.Models;
using VerifyTests;
+using VerifyTests.DiffPlex;
using VerifyXunit;
namespace Riok.Mapperly.IntegrationTests
@@ -29,6 +30,7 @@ static BaseMapperTest()
#endif
VerifierSettings.DontScrubDateTimes();
+ VerifyDiffPlex.Initialize(OutputType.Compact);
Verifier.DerivePathInfo(
(_, _, type, method) =>
@@ -42,17 +44,30 @@ static BaseMapperTest()
protected string GetGeneratedMapperFilePath(string name)
{
+#if NET8_0_OR_GREATER || NET48_OR_GREATER
+ // artifacts output
return Path.Combine(
_solutionDirectory,
"artifacts",
"obj",
"Riok.Mapperly.IntegrationTests",
- "debug",
"generated",
"Riok.Mapperly",
"Riok.Mapperly.MapperGenerator",
name + ".g.cs"
);
+#else
+ return Path.Combine(
+ _solutionDirectory,
+ "test",
+ "Riok.Mapperly.IntegrationTests",
+ "obj",
+ "generated",
+ "Riok.Mapperly",
+ "Riok.Mapperly.MapperGenerator",
+ name + ".g.cs"
+ );
+#endif
}
public static TestObject NewTestObj()
diff --git a/test/Riok.Mapperly.IntegrationTests/Mapper/TestMapper.cs b/test/Riok.Mapperly.IntegrationTests/Mapper/TestMapper.cs
index c860a9c05d..b4d84ef967 100644
--- a/test/Riok.Mapperly.IntegrationTests/Mapper/TestMapper.cs
+++ b/test/Riok.Mapperly.IntegrationTests/Mapper/TestMapper.cs
@@ -19,10 +19,18 @@ namespace Riok.Mapperly.IntegrationTests.Mapper
public partial class TestMapper
{
[FormatProvider(Default = true)]
- private readonly CultureInfo _formatDeCh = CultureInfo.GetCultureInfo("de-CH");
+ private readonly CultureInfo _formatDeCh = (CultureInfo)CultureInfo.GetCultureInfo("de-CH").Clone();
[FormatProvider]
- private readonly CultureInfo _formatEnUs = CultureInfo.GetCultureInfo("en-US");
+ private readonly CultureInfo _formatEnUs = (CultureInfo)CultureInfo.GetCultureInfo("en-US").Clone();
+
+ public TestMapper()
+ {
+ // these seem to vary depending on the OS
+ // set them to a fixed value.
+ _formatDeCh.NumberFormat.CurrencyPositivePattern = 2;
+ _formatEnUs.NumberFormat.CurrencyPositivePattern = 2;
+ }
public partial int DirectInt(int value);
diff --git a/test/Riok.Mapperly.IntegrationTests/MapperTest.cs b/test/Riok.Mapperly.IntegrationTests/MapperTest.cs
index 21cb845cc2..0865afb867 100644
--- a/test/Riok.Mapperly.IntegrationTests/MapperTest.cs
+++ b/test/Riok.Mapperly.IntegrationTests/MapperTest.cs
@@ -21,7 +21,7 @@ public Task SnapshotGeneratedSource()
}
[Fact]
- [VersionedSnapshot(Versions.NET6_0)]
+ [VersionedSnapshot(Versions.NET6_0 | Versions.NET8_0)]
public Task RunMappingShouldWork()
{
var model = NewTestObj();
diff --git a/test/Riok.Mapperly.IntegrationTests/Riok.Mapperly.IntegrationTests.csproj b/test/Riok.Mapperly.IntegrationTests/Riok.Mapperly.IntegrationTests.csproj
index 36fc498c5c..3291a8f105 100644
--- a/test/Riok.Mapperly.IntegrationTests/Riok.Mapperly.IntegrationTests.csproj
+++ b/test/Riok.Mapperly.IntegrationTests/Riok.Mapperly.IntegrationTests.csproj
@@ -6,6 +6,7 @@
$(MapperlyIntegrationTestsTargetFramework)
true
+ $(BaseIntermediateOutputPath)/generated
disable
@@ -28,7 +29,7 @@
-
+
diff --git a/test/Riok.Mapperly.IntegrationTests/_snapshots/DeepCloningMapperTest.RunMappingShouldWork.verified.txt b/test/Riok.Mapperly.IntegrationTests/_snapshots/DeepCloningMapperTest.RunMappingShouldWork.verified.txt
index a9046f7811..5cab95c322 100644
--- a/test/Riok.Mapperly.IntegrationTests/_snapshots/DeepCloningMapperTest.RunMappingShouldWork.verified.txt
+++ b/test/Riok.Mapperly.IntegrationTests/_snapshots/DeepCloningMapperTest.RunMappingShouldWork.verified.txt
@@ -4,6 +4,7 @@
IntValue: 10,
IntInitOnlyValue: 3,
RequiredValue: 4,
+ UnmappedValue: 10,
StringValue: fooBar,
RenamedStringValue: fooBar2,
Flattening: {
@@ -27,6 +28,7 @@
CtorValue: 5,
CtorValue2: 100,
RequiredValue: 4,
+ UnmappedValue: 10,
StringValue: ,
RenamedStringValue: ,
Flattening: {},
@@ -38,13 +40,15 @@
ImmutableStackValue: [],
EnumValue: Value10,
EnumName: Value30,
- EnumReverseStringValue: DtoValue3
+ EnumReverseStringValue: DtoValue3,
+ ExposePrivateValue: 16
},
SourceTargetSameObjectType: {
CtorValue: 8,
CtorValue2: 100,
IntValue: 99,
RequiredValue: 98,
+ UnmappedValue: 10,
StringValue: ,
RenamedStringValue: ,
Flattening: {},
@@ -54,7 +58,8 @@
ImmutableArrayValue: null,
ImmutableQueueValue: [],
ImmutableStackValue: [],
- EnumReverseStringValue:
+ EnumReverseStringValue: ,
+ ExposePrivateValue: 19
},
NullableReadOnlyObjectCollection: [
{
@@ -158,6 +163,8 @@
SubIntValue: 2,
BaseIntValue: 1
},
+ DateTimeValue: 2020-01-03 15:10:05 Utc,
DateTimeValueTargetDateOnly: 2020-01-03 15:10:05 Utc,
- DateTimeValueTargetTimeOnly: 2020-01-03 15:10:05 Utc
+ DateTimeValueTargetTimeOnly: 2020-01-03 15:10:05 Utc,
+ ExposePrivateValue: 18
}
\ No newline at end of file
diff --git a/test/Riok.Mapperly.IntegrationTests/_snapshots/DeepCloningMapperTest.SnapshotGeneratedSource.verified.cs b/test/Riok.Mapperly.IntegrationTests/_snapshots/DeepCloningMapperTest.SnapshotGeneratedSource.verified.cs
index 7ce76976a9..403780cfc3 100644
--- a/test/Riok.Mapperly.IntegrationTests/_snapshots/DeepCloningMapperTest.SnapshotGeneratedSource.verified.cs
+++ b/test/Riok.Mapperly.IntegrationTests/_snapshots/DeepCloningMapperTest.SnapshotGeneratedSource.verified.cs
@@ -22,34 +22,66 @@ public static partial class DeepCloningMapper
{
target.NullableFlattening = Copy(src.NullableFlattening);
}
+ else
+ {
+ target.NullableFlattening = null;
+ }
if (src.NestedNullable != null)
{
target.NestedNullable = MapToTestObjectNested(src.NestedNullable);
}
+ else
+ {
+ target.NestedNullable = null;
+ }
if (src.NestedNullableTargetNotNullable != null)
{
target.NestedNullableTargetNotNullable = MapToTestObjectNested(src.NestedNullableTargetNotNullable);
}
+ else
+ {
+ target.NestedNullableTargetNotNullable = null;
+ }
if (src.TupleValue != null)
{
target.TupleValue = MapToValueTuple(src.TupleValue.Value);
}
+ else
+ {
+ target.TupleValue = null;
+ }
if (src.RecursiveObject != null)
{
target.RecursiveObject = Copy(src.RecursiveObject);
}
+ else
+ {
+ target.RecursiveObject = null;
+ }
if (src.SourceTargetSameObjectType != null)
{
target.SourceTargetSameObjectType = Copy(src.SourceTargetSameObjectType);
}
+ else
+ {
+ target.SourceTargetSameObjectType = null;
+ }
if (src.NullableReadOnlyObjectCollection != null)
{
target.NullableReadOnlyObjectCollection = MapToIReadOnlyCollection(src.NullableReadOnlyObjectCollection);
}
+ else
+ {
+ target.NullableReadOnlyObjectCollection = null;
+ }
if (src.SubObject != null)
{
target.SubObject = MapToInheritanceSubObject(src.SubObject);
}
+ else
+ {
+ target.SubObject = null;
+ }
target.IntValue = src.IntValue;
target.StringValue = src.StringValue;
target.RenamedStringValue = src.RenamedStringValue;
@@ -92,6 +124,7 @@ public static partial class DeepCloningMapper
target.EnumRawValue = src.EnumRawValue;
target.EnumStringValue = src.EnumStringValue;
target.EnumReverseStringValue = src.EnumReverseStringValue;
+ target.DateTimeValue = src.DateTimeValue;
target.DateTimeValueTargetDateOnly = src.DateTimeValueTargetDateOnly;
target.DateTimeValueTargetTimeOnly = src.DateTimeValueTargetTimeOnly;
return target;
diff --git a/test/Riok.Mapperly.IntegrationTests/_snapshots/MapperTest.RunMappingShouldWork.verified.txt b/test/Riok.Mapperly.IntegrationTests/_snapshots/MapperTest.RunMappingShouldWork.verified.txt
index 140a1fe5e4..c07ba62a2b 100644
--- a/test/Riok.Mapperly.IntegrationTests/_snapshots/MapperTest.RunMappingShouldWork.verified.txt
+++ b/test/Riok.Mapperly.IntegrationTests/_snapshots/MapperTest.RunMappingShouldWork.verified.txt
@@ -47,20 +47,25 @@
EnumValue: DtoValue1,
EnumName: Value30,
EnumStringValue: 0,
- EnumReverseStringValue: DtoValue3
+ EnumReverseStringValue: DtoValue3,
+ FormattedIntValue: CHF 0.00,
+ FormattedDateValue: Monday, January 1, 0001,
+ ExposePrivateValue: 26
},
SourceTargetSameObjectType: {
CtorValue: 8,
CtorValue2: 100,
IntValue: 99,
RequiredValue: 98,
+ UnmappedValue: 10,
StringValue: ,
RenamedStringValue: ,
Flattening: {},
ImmutableArrayValue: null,
ImmutableQueueValue: [],
ImmutableStackValue: [],
- EnumReverseStringValue:
+ EnumReverseStringValue: ,
+ ExposePrivateValue: 19
},
NullableReadOnlyObjectCollection: [
{
@@ -175,5 +180,8 @@
BaseIntValue: 1
},
DateTimeValueTargetDateOnly: 2020-01-03,
- DateTimeValueTargetTimeOnly: 3:10 PM
+ DateTimeValueTargetTimeOnly: 3:10 PM,
+ FormattedIntValue: CHF 10.00,
+ FormattedDateValue: Friday, January 3, 2020,
+ ExposePrivateValue: 28
}
\ No newline at end of file
diff --git a/test/Riok.Mapperly.IntegrationTests/_snapshots/MapperTest.RunMappingShouldWork_NET6_0.verified.txt b/test/Riok.Mapperly.IntegrationTests/_snapshots/MapperTest.RunMappingShouldWork_NET6_0.verified.txt
index 1adfb8a39b..eba46cf5d5 100644
--- a/test/Riok.Mapperly.IntegrationTests/_snapshots/MapperTest.RunMappingShouldWork_NET6_0.verified.txt
+++ b/test/Riok.Mapperly.IntegrationTests/_snapshots/MapperTest.RunMappingShouldWork_NET6_0.verified.txt
@@ -50,7 +50,7 @@
EnumReverseStringValue: DtoValue3,
FormattedIntValue: CHF 0.00,
FormattedDateValue: Monday, January 1, 0001,
- ExposePrivateValue: 16
+ ExposePrivateValue: 26
},
SourceTargetSameObjectType: {
CtorValue: 8,
@@ -188,5 +188,5 @@
DateTimeValueTargetTimeOnly: 3:10 PM,
FormattedIntValue: CHF 10.00,
FormattedDateValue: Friday, January 3, 2020,
- ExposePrivateValue: 18
+ ExposePrivateValue: 28
}
\ No newline at end of file
diff --git a/test/Riok.Mapperly.IntegrationTests/_snapshots/MapperTest.RunMappingShouldWork_NET8_0.verified.txt b/test/Riok.Mapperly.IntegrationTests/_snapshots/MapperTest.RunMappingShouldWork_NET8_0.verified.txt
new file mode 100644
index 0000000000..1adfb8a39b
--- /dev/null
+++ b/test/Riok.Mapperly.IntegrationTests/_snapshots/MapperTest.RunMappingShouldWork_NET8_0.verified.txt
@@ -0,0 +1,192 @@
+{
+ CtorValue: 7,
+ CtorValue2: 100,
+ IntValue: 10,
+ IntInitOnlyValue: 3,
+ RequiredValue: 4,
+ StringValue: fooBar+after-map,
+ RenamedStringValue2: fooBar2,
+ FlatteningIdValue: 10,
+ NullableFlatteningIdValue: 100,
+ Unflattening: {
+ IdValue: 20
+ },
+ NullableUnflattening: {
+ IdValue: 200
+ },
+ NestedNullableIntValue: 100,
+ NestedNullable: {
+ IntValue: 100
+ },
+ NestedNullableTargetNotNullable: {},
+ StringNullableTargetNotNullable: fooBar3,
+ TupleValue: {
+ Item1: 10,
+ Item2: 20
+ },
+ RecursiveObject: {
+ CtorValue: 5,
+ CtorValue2: 100,
+ RequiredValue: 4,
+ StringValue: +after-map,
+ RenamedStringValue2: ,
+ Unflattening: {},
+ NestedNullableTargetNotNullable: {},
+ StringNullableTargetNotNullable: ,
+ SpanValue: [
+ 1,
+ 2,
+ 3
+ ],
+ MemoryValue: {
+ IsEmpty: true
+ },
+ ImmutableArrayValue: null,
+ ImmutableQueueValue: [],
+ ImmutableStackValue: [],
+ EnumValue: DtoValue1,
+ EnumName: Value30,
+ EnumStringValue: 0,
+ EnumReverseStringValue: DtoValue3,
+ FormattedIntValue: CHF 0.00,
+ FormattedDateValue: Monday, January 1, 0001,
+ ExposePrivateValue: 16
+ },
+ SourceTargetSameObjectType: {
+ CtorValue: 8,
+ CtorValue2: 100,
+ IntValue: 99,
+ RequiredValue: 98,
+ UnmappedValue: 10,
+ StringValue: ,
+ RenamedStringValue: ,
+ Flattening: {},
+ ImmutableArrayValue: null,
+ ImmutableQueueValue: [],
+ ImmutableStackValue: [],
+ EnumReverseStringValue: ,
+ ExposePrivateValue: 19
+ },
+ NullableReadOnlyObjectCollection: [
+ {
+ IntValue: 10
+ },
+ {
+ IntValue: 20
+ }
+ ],
+ SpanValue: [
+ 1,
+ 2,
+ 3
+ ],
+ MemoryValue: {
+ Length: 3,
+ IsEmpty: false
+ },
+ StackValue: [
+ 1,
+ 2,
+ 3
+ ],
+ QueueValue: [
+ 1,
+ 2,
+ 3
+ ],
+ ImmutableArrayValue: [
+ 1,
+ 2,
+ 3
+ ],
+ ImmutableListValue: [
+ 1,
+ 2,
+ 3
+ ],
+ ImmutableHashSetValue: [
+ 1,
+ 2,
+ 3
+ ],
+ ImmutableQueueValue: [
+ 1,
+ 2,
+ 3
+ ],
+ ImmutableStackValue: [
+ 1,
+ 2,
+ 3
+ ],
+ ImmutableSortedSetValue: [
+ 1,
+ 2,
+ 3
+ ],
+ ImmutableDictionaryValue: {
+ 1: 1,
+ 2: 2,
+ 3: 3
+ },
+ ImmutableSortedDictionaryValue: {
+ 1: 1,
+ 2: 2,
+ 3: 3
+ },
+ ExistingISet: [
+ 1,
+ 2,
+ 3
+ ],
+ ExistingHashSet: [
+ 1,
+ 2,
+ 3
+ ],
+ ExistingSortedSet: [
+ 1,
+ 2,
+ 3
+ ],
+ ExistingList: [
+ 1,
+ 2,
+ 3
+ ],
+ ISet: [
+ 1,
+ 2,
+ 3
+ ],
+ IReadOnlySet: [
+ 1,
+ 2,
+ 3
+ ],
+ HashSet: [
+ 1,
+ 2,
+ 3
+ ],
+ SortedSet: [
+ 1,
+ 2,
+ 3
+ ],
+ EnumValue: DtoValue1,
+ FlagsEnumValue: V1, V3,
+ EnumName: Value10,
+ EnumRawValue: 20,
+ EnumStringValue: Value30,
+ EnumReverseStringValue: DtoValue3,
+ SubObject: {
+ SubIntValue: 2,
+ BaseIntValue: 1
+ },
+ DateTimeValueTargetDateOnly: 2020-01-03,
+ DateTimeValueTargetTimeOnly: 3:10 PM,
+ FormattedIntValue: CHF 10.00,
+ FormattedDateValue: Friday, January 3, 2020,
+ ExposePrivateValue: 18
+}
\ No newline at end of file
diff --git a/test/Riok.Mapperly.IntegrationTests/_snapshots/MapperTest.SnapshotGeneratedSource.verified.cs b/test/Riok.Mapperly.IntegrationTests/_snapshots/MapperTest.SnapshotGeneratedSource.verified.cs
index e04e6dc2e9..8812289297 100644
--- a/test/Riok.Mapperly.IntegrationTests/_snapshots/MapperTest.SnapshotGeneratedSource.verified.cs
+++ b/test/Riok.Mapperly.IntegrationTests/_snapshots/MapperTest.SnapshotGeneratedSource.verified.cs
@@ -55,6 +55,10 @@ public partial int ParseableInt(string value)
{
target.NullableFlatteningIdValue = CastIntNullable(testObject.NullableFlattening.IdValue);
}
+ else
+ {
+ target.NullableFlatteningIdValue = null;
+ }
if (testObject.NullableUnflatteningIdValue != null)
{
target.NullableUnflattening ??= new();
@@ -65,6 +69,10 @@ public partial int ParseableInt(string value)
target.NestedNullableIntValue = DirectInt(testObject.NestedNullable.IntValue);
target.NestedNullable = MapToTestObjectNestedDto(testObject.NestedNullable);
}
+ else
+ {
+ target.NestedNullable = null;
+ }
if (testObject.NestedNullableTargetNotNullable != null)
{
target.NestedNullableTargetNotNullable = MapToTestObjectNestedDto(testObject.NestedNullableTargetNotNullable);
@@ -77,18 +85,34 @@ public partial int ParseableInt(string value)
{
target.TupleValue = MapToValueTuple(testObject.TupleValue.Value);
}
+ else
+ {
+ target.TupleValue = null;
+ }
if (testObject.RecursiveObject != null)
{
target.RecursiveObject = MapToDto(testObject.RecursiveObject);
}
+ else
+ {
+ target.RecursiveObject = null;
+ }
if (testObject.NullableReadOnlyObjectCollection != null)
{
target.NullableReadOnlyObjectCollection = MapToTestObjectNestedDtoArray(testObject.NullableReadOnlyObjectCollection);
}
+ else
+ {
+ target.NullableReadOnlyObjectCollection = null;
+ }
if (testObject.SubObject != null)
{
target.SubObject = MapToInheritanceSubObjectDto(testObject.SubObject);
}
+ else
+ {
+ target.SubObject = null;
+ }
target.IntValue = DirectInt(testObject.IntValue);
target.StringValue = testObject.StringValue;
target.RenamedStringValue2 = testObject.RenamedStringValue;
@@ -134,6 +158,8 @@ public partial int ParseableInt(string value)
target.EnumReverseStringValue = MapToTestEnumDtoByValue(testObject.EnumReverseStringValue);
target.DateTimeValueTargetDateOnly = global::System.DateOnly.FromDateTime(testObject.DateTimeValueTargetDateOnly);
target.DateTimeValueTargetTimeOnly = global::System.TimeOnly.FromDateTime(testObject.DateTimeValueTargetTimeOnly);
+ target.FormattedIntValue = testObject.IntValue.ToString("C", _formatDeCh);
+ target.FormattedDateValue = testObject.DateTimeValue.ToString("D", _formatEnUs);
return target;
}
@@ -148,26 +174,50 @@ public partial int ParseableInt(string value)
{
target.NullableUnflatteningIdValue = CastIntNullable(dto.NullableUnflattening.IdValue);
}
+ else
+ {
+ target.NullableUnflatteningIdValue = null;
+ }
if (dto.NestedNullable != null)
{
target.NestedNullable = MapToTestObjectNested(dto.NestedNullable);
}
+ else
+ {
+ target.NestedNullable = null;
+ }
if (dto.TupleValue != null)
{
target.TupleValue = MapToValueTuple1(dto.TupleValue.Value);
}
+ else
+ {
+ target.TupleValue = null;
+ }
if (dto.RecursiveObject != null)
{
target.RecursiveObject = MapFromDto(dto.RecursiveObject);
}
+ else
+ {
+ target.RecursiveObject = null;
+ }
if (dto.NullableReadOnlyObjectCollection != null)
{
target.NullableReadOnlyObjectCollection = MapToIReadOnlyCollection(dto.NullableReadOnlyObjectCollection);
}
+ else
+ {
+ target.NullableReadOnlyObjectCollection = null;
+ }
if (dto.SubObject != null)
{
target.SubObject = MapToInheritanceSubObject(dto.SubObject);
}
+ else
+ {
+ target.SubObject = null;
+ }
target.IntValue = DirectInt(dto.IntValue);
target.StringValue = dto.StringValue;
target.UnflatteningIdValue = DirectInt(dto.Unflattening.IdValue);
@@ -175,35 +225,35 @@ public partial int ParseableInt(string value)
target.StringNullableTargetNotNullable = dto.StringNullableTargetNotNullable;
target.SourceTargetSameObjectType = dto.SourceTargetSameObjectType;
target.MemoryValue = MapToStringArray(dto.MemoryValue.Span);
- target.StackValue = new global::System.Collections.Generic.Stack(global::System.Linq.Enumerable.Select(dto.StackValue, x => x.ToString()));
- target.QueueValue = new global::System.Collections.Generic.Queue(global::System.Linq.Enumerable.Select(dto.QueueValue, x => x.ToString()));
- target.ImmutableArrayValue = global::System.Collections.Immutable.ImmutableArray.ToImmutableArray(global::System.Linq.Enumerable.Select(dto.ImmutableArrayValue, x => x.ToString()));
- target.ImmutableListValue = global::System.Collections.Immutable.ImmutableList.ToImmutableList(global::System.Linq.Enumerable.Select(dto.ImmutableListValue, x => x.ToString()));
- target.ImmutableHashSetValue = global::System.Collections.Immutable.ImmutableHashSet.ToImmutableHashSet(global::System.Linq.Enumerable.Select(dto.ImmutableHashSetValue, x => x.ToString()));
- target.ImmutableQueueValue = global::System.Collections.Immutable.ImmutableQueue.CreateRange(global::System.Linq.Enumerable.Select(dto.ImmutableQueueValue, x => x.ToString()));
- target.ImmutableStackValue = global::System.Collections.Immutable.ImmutableStack.CreateRange(global::System.Linq.Enumerable.Select(dto.ImmutableStackValue, x => x.ToString()));
- target.ImmutableSortedSetValue = global::System.Collections.Immutable.ImmutableSortedSet.ToImmutableSortedSet(global::System.Linq.Enumerable.Select(dto.ImmutableSortedSetValue, x => x.ToString()));
- target.ImmutableDictionaryValue = global::System.Collections.Immutable.ImmutableDictionary.ToImmutableDictionary(dto.ImmutableDictionaryValue, x => x.Key.ToString(), x => x.Value.ToString());
- target.ImmutableSortedDictionaryValue = global::System.Collections.Immutable.ImmutableSortedDictionary.ToImmutableSortedDictionary(dto.ImmutableSortedDictionaryValue, x => x.Key.ToString(), x => x.Value.ToString());
+ target.StackValue = new global::System.Collections.Generic.Stack(global::System.Linq.Enumerable.Select(dto.StackValue, x => x.ToString(_formatDeCh)));
+ target.QueueValue = new global::System.Collections.Generic.Queue(global::System.Linq.Enumerable.Select(dto.QueueValue, x => x.ToString(_formatDeCh)));
+ target.ImmutableArrayValue = global::System.Collections.Immutable.ImmutableArray.ToImmutableArray(global::System.Linq.Enumerable.Select(dto.ImmutableArrayValue, x => x.ToString(_formatDeCh)));
+ target.ImmutableListValue = global::System.Collections.Immutable.ImmutableList.ToImmutableList(global::System.Linq.Enumerable.Select(dto.ImmutableListValue, x => x.ToString(_formatDeCh)));
+ target.ImmutableHashSetValue = global::System.Collections.Immutable.ImmutableHashSet.ToImmutableHashSet(global::System.Linq.Enumerable.Select(dto.ImmutableHashSetValue, x => x.ToString(_formatDeCh)));
+ target.ImmutableQueueValue = global::System.Collections.Immutable.ImmutableQueue.CreateRange(global::System.Linq.Enumerable.Select(dto.ImmutableQueueValue, x => x.ToString(_formatDeCh)));
+ target.ImmutableStackValue = global::System.Collections.Immutable.ImmutableStack.CreateRange(global::System.Linq.Enumerable.Select(dto.ImmutableStackValue, x => x.ToString(_formatDeCh)));
+ target.ImmutableSortedSetValue = global::System.Collections.Immutable.ImmutableSortedSet.ToImmutableSortedSet(global::System.Linq.Enumerable.Select(dto.ImmutableSortedSetValue, x => x.ToString(_formatDeCh)));
+ target.ImmutableDictionaryValue = global::System.Collections.Immutable.ImmutableDictionary.ToImmutableDictionary(dto.ImmutableDictionaryValue, x => x.Key.ToString(_formatDeCh), x => x.Value.ToString(_formatDeCh));
+ target.ImmutableSortedDictionaryValue = global::System.Collections.Immutable.ImmutableSortedDictionary.ToImmutableSortedDictionary(dto.ImmutableSortedDictionaryValue, x => x.Key.ToString(_formatDeCh), x => x.Value.ToString(_formatDeCh));
foreach (var item in dto.ExistingISet)
{
- target.ExistingISet.Add(item.ToString());
+ target.ExistingISet.Add(item.ToString(_formatDeCh));
}
foreach (var item1 in dto.ExistingHashSet)
{
- target.ExistingHashSet.Add(item1.ToString());
+ target.ExistingHashSet.Add(item1.ToString(_formatDeCh));
}
foreach (var item2 in dto.ExistingSortedSet)
{
- target.ExistingSortedSet.Add(item2.ToString());
+ target.ExistingSortedSet.Add(item2.ToString(_formatDeCh));
}
foreach (var item3 in dto.ExistingList)
{
- target.ExistingList.Add(item3.ToString());
+ target.ExistingList.Add(item3.ToString(_formatDeCh));
}
- target.ISet = global::System.Linq.Enumerable.ToHashSet(global::System.Linq.Enumerable.Select(dto.ISet, x => x.ToString()));
- target.HashSet = global::System.Linq.Enumerable.ToHashSet(global::System.Linq.Enumerable.Select(dto.HashSet, x => x.ToString()));
- target.SortedSet = new global::System.Collections.Generic.SortedSet(global::System.Linq.Enumerable.Select(dto.SortedSet, x => x.ToString()));
+ target.ISet = global::System.Linq.Enumerable.ToHashSet(global::System.Linq.Enumerable.Select(dto.ISet, x => x.ToString(_formatDeCh)));
+ target.HashSet = global::System.Linq.Enumerable.ToHashSet(global::System.Linq.Enumerable.Select(dto.HashSet, x => x.ToString(_formatDeCh)));
+ target.SortedSet = new global::System.Collections.Generic.SortedSet(global::System.Linq.Enumerable.Select(dto.SortedSet, x => x.ToString(_formatDeCh)));
target.EnumValue = (global::Riok.Mapperly.IntegrationTests.Models.TestEnum)dto.EnumValue;
target.FlagsEnumValue = (global::Riok.Mapperly.IntegrationTests.Models.TestFlagsEnum)dto.FlagsEnumValue;
target.EnumName = (global::Riok.Mapperly.IntegrationTests.Models.TestEnum)dto.EnumName;
@@ -219,11 +269,19 @@ public partial void UpdateDto(global::Riok.Mapperly.IntegrationTests.Models.Test
{
target.NullableFlatteningIdValue = CastIntNullable(source.NullableFlattening.IdValue);
}
+ else
+ {
+ target.NullableFlatteningIdValue = null;
+ }
if (source.NestedNullable != null)
{
target.NestedNullableIntValue = DirectInt(source.NestedNullable.IntValue);
target.NestedNullable = MapToTestObjectNestedDto(source.NestedNullable);
}
+ else
+ {
+ target.NestedNullable = null;
+ }
if (source.NestedNullableTargetNotNullable != null)
{
target.NestedNullableTargetNotNullable = MapToTestObjectNestedDto(source.NestedNullableTargetNotNullable);
@@ -236,18 +294,34 @@ public partial void UpdateDto(global::Riok.Mapperly.IntegrationTests.Models.Test
{
target.TupleValue = MapToValueTuple(source.TupleValue.Value);
}
+ else
+ {
+ target.TupleValue = null;
+ }
if (source.RecursiveObject != null)
{
target.RecursiveObject = MapToDto(source.RecursiveObject);
}
+ else
+ {
+ target.RecursiveObject = null;
+ }
if (source.NullableReadOnlyObjectCollection != null)
{
target.NullableReadOnlyObjectCollection = MapToTestObjectNestedDtoArray(source.NullableReadOnlyObjectCollection);
}
+ else
+ {
+ target.NullableReadOnlyObjectCollection = null;
+ }
if (source.SubObject != null)
{
target.SubObject = MapToInheritanceSubObjectDto(source.SubObject);
}
+ else
+ {
+ target.SubObject = null;
+ }
target.CtorValue = DirectInt(source.CtorValue);
target.CtorValue2 = DirectInt(source.CtorValue2);
target.IntValue = DirectInt(source.IntValue);
@@ -395,7 +469,7 @@ private string MapToString(global::Riok.Mapperly.IntegrationTests.Models.TestEnu
private (string A, string) MapToValueTuple1((int A, int) source)
{
- var target = (A: source.A.ToString(), source.Item2.ToString());
+ var target = (A: source.A.ToString(_formatDeCh), source.Item2.ToString(_formatDeCh));
return target;
}
@@ -414,7 +488,7 @@ private string[] MapToStringArray(global::System.ReadOnlySpan source)
var target = new string[source.Length];
for (var i = 0; i < source.Length; i++)
{
- target[i] = source[i].ToString();
+ target[i] = source[i].ToString(_formatDeCh);
}
return target;
}
diff --git a/test/Riok.Mapperly.IntegrationTests/_snapshots/MapperTest.SnapshotGeneratedSource_NET6_0.verified.cs b/test/Riok.Mapperly.IntegrationTests/_snapshots/MapperTest.SnapshotGeneratedSource_NET6_0.verified.cs
index 782d0d233f..2bbc71c3eb 100644
--- a/test/Riok.Mapperly.IntegrationTests/_snapshots/MapperTest.SnapshotGeneratedSource_NET6_0.verified.cs
+++ b/test/Riok.Mapperly.IntegrationTests/_snapshots/MapperTest.SnapshotGeneratedSource_NET6_0.verified.cs
@@ -55,6 +55,10 @@ public partial int ParseableInt(string value)
{
target.NullableFlatteningIdValue = CastIntNullable(testObject.NullableFlattening.IdValue);
}
+ else
+ {
+ target.NullableFlatteningIdValue = null;
+ }
if (testObject.NullableUnflatteningIdValue != null)
{
target.NullableUnflattening ??= new();
@@ -65,6 +69,10 @@ public partial int ParseableInt(string value)
target.NestedNullableIntValue = DirectInt(testObject.NestedNullable.IntValue);
target.NestedNullable = MapToTestObjectNestedDto(testObject.NestedNullable);
}
+ else
+ {
+ target.NestedNullable = null;
+ }
if (testObject.NestedNullableTargetNotNullable != null)
{
target.NestedNullableTargetNotNullable = MapToTestObjectNestedDto(testObject.NestedNullableTargetNotNullable);
@@ -77,18 +85,34 @@ public partial int ParseableInt(string value)
{
target.TupleValue = MapToValueTuple(testObject.TupleValue.Value);
}
+ else
+ {
+ target.TupleValue = null;
+ }
if (testObject.RecursiveObject != null)
{
target.RecursiveObject = MapToDto(testObject.RecursiveObject);
}
+ else
+ {
+ target.RecursiveObject = null;
+ }
if (testObject.NullableReadOnlyObjectCollection != null)
{
target.NullableReadOnlyObjectCollection = MapToTestObjectNestedDtoArray(testObject.NullableReadOnlyObjectCollection);
}
+ else
+ {
+ target.NullableReadOnlyObjectCollection = null;
+ }
if (testObject.SubObject != null)
{
target.SubObject = MapToInheritanceSubObjectDto(testObject.SubObject);
}
+ else
+ {
+ target.SubObject = null;
+ }
target.IntValue = DirectInt(testObject.IntValue);
target.StringValue = testObject.StringValue;
target.RenamedStringValue2 = testObject.RenamedStringValue;
@@ -137,6 +161,8 @@ public partial int ParseableInt(string value)
target.EnumReverseStringValue = MapToTestEnumDtoByValue(testObject.EnumReverseStringValue);
target.DateTimeValueTargetDateOnly = global::System.DateOnly.FromDateTime(testObject.DateTimeValueTargetDateOnly);
target.DateTimeValueTargetTimeOnly = global::System.TimeOnly.FromDateTime(testObject.DateTimeValueTargetTimeOnly);
+ target.FormattedIntValue = testObject.IntValue.ToString("C", _formatDeCh);
+ target.FormattedDateValue = testObject.DateTimeValue.ToString("D", _formatEnUs);
return target;
}
@@ -151,26 +177,50 @@ public partial int ParseableInt(string value)
{
target.NullableUnflatteningIdValue = CastIntNullable(dto.NullableUnflattening.IdValue);
}
+ else
+ {
+ target.NullableUnflatteningIdValue = null;
+ }
if (dto.NestedNullable != null)
{
target.NestedNullable = MapToTestObjectNested(dto.NestedNullable);
}
+ else
+ {
+ target.NestedNullable = null;
+ }
if (dto.TupleValue != null)
{
target.TupleValue = MapToValueTuple1(dto.TupleValue.Value);
}
+ else
+ {
+ target.TupleValue = null;
+ }
if (dto.RecursiveObject != null)
{
target.RecursiveObject = MapFromDto(dto.RecursiveObject);
}
+ else
+ {
+ target.RecursiveObject = null;
+ }
if (dto.NullableReadOnlyObjectCollection != null)
{
target.NullableReadOnlyObjectCollection = MapToIReadOnlyCollection(dto.NullableReadOnlyObjectCollection);
}
+ else
+ {
+ target.NullableReadOnlyObjectCollection = null;
+ }
if (dto.SubObject != null)
{
target.SubObject = MapToInheritanceSubObject(dto.SubObject);
}
+ else
+ {
+ target.SubObject = null;
+ }
target.IntValue = DirectInt(dto.IntValue);
target.StringValue = dto.StringValue;
target.UnflatteningIdValue = DirectInt(dto.Unflattening.IdValue);
@@ -178,38 +228,38 @@ public partial int ParseableInt(string value)
target.StringNullableTargetNotNullable = dto.StringNullableTargetNotNullable;
target.SourceTargetSameObjectType = dto.SourceTargetSameObjectType;
target.MemoryValue = MapToStringArray(dto.MemoryValue.Span);
- target.StackValue = new global::System.Collections.Generic.Stack(global::System.Linq.Enumerable.Select(dto.StackValue, x => x.ToString()));
- target.QueueValue = new global::System.Collections.Generic.Queue(global::System.Linq.Enumerable.Select(dto.QueueValue, x => x.ToString()));
- target.ImmutableArrayValue = global::System.Collections.Immutable.ImmutableArray.ToImmutableArray(global::System.Linq.Enumerable.Select(dto.ImmutableArrayValue, x => x.ToString()));
- target.ImmutableListValue = global::System.Collections.Immutable.ImmutableList.ToImmutableList(global::System.Linq.Enumerable.Select(dto.ImmutableListValue, x => x.ToString()));
- target.ImmutableHashSetValue = global::System.Collections.Immutable.ImmutableHashSet.ToImmutableHashSet(global::System.Linq.Enumerable.Select(dto.ImmutableHashSetValue, x => x.ToString()));
- target.ImmutableQueueValue = global::System.Collections.Immutable.ImmutableQueue.CreateRange(global::System.Linq.Enumerable.Select(dto.ImmutableQueueValue, x => x.ToString()));
- target.ImmutableStackValue = global::System.Collections.Immutable.ImmutableStack.CreateRange(global::System.Linq.Enumerable.Select(dto.ImmutableStackValue, x => x.ToString()));
- target.ImmutableSortedSetValue = global::System.Collections.Immutable.ImmutableSortedSet.ToImmutableSortedSet(global::System.Linq.Enumerable.Select(dto.ImmutableSortedSetValue, x => x.ToString()));
- target.ImmutableDictionaryValue = global::System.Collections.Immutable.ImmutableDictionary.ToImmutableDictionary(dto.ImmutableDictionaryValue, x => x.Key.ToString(), x => x.Value.ToString());
- target.ImmutableSortedDictionaryValue = global::System.Collections.Immutable.ImmutableSortedDictionary.ToImmutableSortedDictionary(dto.ImmutableSortedDictionaryValue, x => x.Key.ToString(), x => x.Value.ToString());
+ target.StackValue = new global::System.Collections.Generic.Stack(global::System.Linq.Enumerable.Select(dto.StackValue, x => x.ToString(_formatDeCh)));
+ target.QueueValue = new global::System.Collections.Generic.Queue(global::System.Linq.Enumerable.Select(dto.QueueValue, x => x.ToString(_formatDeCh)));
+ target.ImmutableArrayValue = global::System.Collections.Immutable.ImmutableArray.ToImmutableArray(global::System.Linq.Enumerable.Select(dto.ImmutableArrayValue, x => x.ToString(_formatDeCh)));
+ target.ImmutableListValue = global::System.Collections.Immutable.ImmutableList.ToImmutableList(global::System.Linq.Enumerable.Select(dto.ImmutableListValue, x => x.ToString(_formatDeCh)));
+ target.ImmutableHashSetValue = global::System.Collections.Immutable.ImmutableHashSet.ToImmutableHashSet(global::System.Linq.Enumerable.Select(dto.ImmutableHashSetValue, x => x.ToString(_formatDeCh)));
+ target.ImmutableQueueValue = global::System.Collections.Immutable.ImmutableQueue.CreateRange(global::System.Linq.Enumerable.Select(dto.ImmutableQueueValue, x => x.ToString(_formatDeCh)));
+ target.ImmutableStackValue = global::System.Collections.Immutable.ImmutableStack.CreateRange(global::System.Linq.Enumerable.Select(dto.ImmutableStackValue, x => x.ToString(_formatDeCh)));
+ target.ImmutableSortedSetValue = global::System.Collections.Immutable.ImmutableSortedSet.ToImmutableSortedSet(global::System.Linq.Enumerable.Select(dto.ImmutableSortedSetValue, x => x.ToString(_formatDeCh)));
+ target.ImmutableDictionaryValue = global::System.Collections.Immutable.ImmutableDictionary.ToImmutableDictionary(dto.ImmutableDictionaryValue, x => x.Key.ToString(_formatDeCh), x => x.Value.ToString(_formatDeCh));
+ target.ImmutableSortedDictionaryValue = global::System.Collections.Immutable.ImmutableSortedDictionary.ToImmutableSortedDictionary(dto.ImmutableSortedDictionaryValue, x => x.Key.ToString(_formatDeCh), x => x.Value.ToString(_formatDeCh));
foreach (var item in dto.ExistingISet)
{
- target.ExistingISet.Add(item.ToString());
+ target.ExistingISet.Add(item.ToString(_formatDeCh));
}
target.ExistingHashSet.EnsureCapacity(dto.ExistingHashSet.Count + target.ExistingHashSet.Count);
foreach (var item1 in dto.ExistingHashSet)
{
- target.ExistingHashSet.Add(item1.ToString());
+ target.ExistingHashSet.Add(item1.ToString(_formatDeCh));
}
foreach (var item2 in dto.ExistingSortedSet)
{
- target.ExistingSortedSet.Add(item2.ToString());
+ target.ExistingSortedSet.Add(item2.ToString(_formatDeCh));
}
target.ExistingList.EnsureCapacity(dto.ExistingList.Count + target.ExistingList.Count);
foreach (var item3 in dto.ExistingList)
{
- target.ExistingList.Add(item3.ToString());
+ target.ExistingList.Add(item3.ToString(_formatDeCh));
}
- target.ISet = global::System.Linq.Enumerable.ToHashSet(global::System.Linq.Enumerable.Select(dto.ISet, x => x.ToString()));
- target.IReadOnlySet = global::System.Linq.Enumerable.ToHashSet(global::System.Linq.Enumerable.Select(dto.IReadOnlySet, x => x.ToString()));
- target.HashSet = global::System.Linq.Enumerable.ToHashSet(global::System.Linq.Enumerable.Select(dto.HashSet, x => x.ToString()));
- target.SortedSet = new global::System.Collections.Generic.SortedSet(global::System.Linq.Enumerable.Select(dto.SortedSet, x => x.ToString()));
+ target.ISet = global::System.Linq.Enumerable.ToHashSet(global::System.Linq.Enumerable.Select(dto.ISet, x => x.ToString(_formatDeCh)));
+ target.IReadOnlySet = global::System.Linq.Enumerable.ToHashSet(global::System.Linq.Enumerable.Select(dto.IReadOnlySet, x => x.ToString(_formatDeCh)));
+ target.HashSet = global::System.Linq.Enumerable.ToHashSet(global::System.Linq.Enumerable.Select(dto.HashSet, x => x.ToString(_formatDeCh)));
+ target.SortedSet = new global::System.Collections.Generic.SortedSet(global::System.Linq.Enumerable.Select(dto.SortedSet, x => x.ToString(_formatDeCh)));
target.EnumValue = (global::Riok.Mapperly.IntegrationTests.Models.TestEnum)dto.EnumValue;
target.FlagsEnumValue = (global::Riok.Mapperly.IntegrationTests.Models.TestFlagsEnum)dto.FlagsEnumValue;
target.EnumName = (global::Riok.Mapperly.IntegrationTests.Models.TestEnum)dto.EnumName;
@@ -225,11 +275,19 @@ public partial void UpdateDto(global::Riok.Mapperly.IntegrationTests.Models.Test
{
target.NullableFlatteningIdValue = CastIntNullable(source.NullableFlattening.IdValue);
}
+ else
+ {
+ target.NullableFlatteningIdValue = null;
+ }
if (source.NestedNullable != null)
{
target.NestedNullableIntValue = DirectInt(source.NestedNullable.IntValue);
target.NestedNullable = MapToTestObjectNestedDto(source.NestedNullable);
}
+ else
+ {
+ target.NestedNullable = null;
+ }
if (source.NestedNullableTargetNotNullable != null)
{
target.NestedNullableTargetNotNullable = MapToTestObjectNestedDto(source.NestedNullableTargetNotNullable);
@@ -242,18 +300,34 @@ public partial void UpdateDto(global::Riok.Mapperly.IntegrationTests.Models.Test
{
target.TupleValue = MapToValueTuple(source.TupleValue.Value);
}
+ else
+ {
+ target.TupleValue = null;
+ }
if (source.RecursiveObject != null)
{
target.RecursiveObject = MapToDto(source.RecursiveObject);
}
+ else
+ {
+ target.RecursiveObject = null;
+ }
if (source.NullableReadOnlyObjectCollection != null)
{
target.NullableReadOnlyObjectCollection = MapToTestObjectNestedDtoArray(source.NullableReadOnlyObjectCollection);
}
+ else
+ {
+ target.NullableReadOnlyObjectCollection = null;
+ }
if (source.SubObject != null)
{
target.SubObject = MapToInheritanceSubObjectDto(source.SubObject);
}
+ else
+ {
+ target.SubObject = null;
+ }
target.CtorValue = DirectInt(source.CtorValue);
target.CtorValue2 = DirectInt(source.CtorValue2);
target.IntValue = DirectInt(source.IntValue);
@@ -404,7 +478,7 @@ private string MapToString(global::Riok.Mapperly.IntegrationTests.Models.TestEnu
private (string A, string) MapToValueTuple1((int A, int) source)
{
- var target = (A: source.A.ToString(), source.Item2.ToString());
+ var target = (A: source.A.ToString(_formatDeCh), source.Item2.ToString(_formatDeCh));
return target;
}
@@ -423,7 +497,7 @@ private string[] MapToStringArray(global::System.ReadOnlySpan source)
var target = new string[source.Length];
for (var i = 0; i < source.Length; i++)
{
- target[i] = source[i].ToString();
+ target[i] = source[i].ToString(_formatDeCh);
}
return target;
}
diff --git a/test/Riok.Mapperly.IntegrationTests/_snapshots/ProjectionMapperTest.SnapshotGeneratedSource.verified.cs b/test/Riok.Mapperly.IntegrationTests/_snapshots/ProjectionMapperTest.SnapshotGeneratedSource.verified.cs
index 3b623594a9..f8dff4ef0d 100644
--- a/test/Riok.Mapperly.IntegrationTests/_snapshots/ProjectionMapperTest.SnapshotGeneratedSource.verified.cs
+++ b/test/Riok.Mapperly.IntegrationTests/_snapshots/ProjectionMapperTest.SnapshotGeneratedSource.verified.cs
@@ -15,7 +15,7 @@ public static partial class ProjectionMapper
StringValue = x.StringValue,
RenamedStringValue2 = x.RenamedStringValue,
FlatteningIdValue = x.Flattening.IdValue,
- NullableFlatteningIdValue = x.NullableFlattening != null ? x.NullableFlattening.IdValue : default,
+ NullableFlatteningIdValue = x.NullableFlattening != null ? x.NullableFlattening.IdValue : default(int?),
NestedNullableIntValue = x.NestedNullable != null ? x.NestedNullable.IntValue : default,
NestedNullable = x.NestedNullable != null ? new global::Riok.Mapperly.IntegrationTests.Dto.TestObjectNestedDto()
{
@@ -44,6 +44,7 @@ public static partial class ProjectionMapper
DateTimeValueTargetDateOnly = global::System.DateOnly.FromDateTime(x.DateTimeValueTargetDateOnly),
DateTimeValueTargetTimeOnly = global::System.TimeOnly.FromDateTime(x.DateTimeValueTargetTimeOnly),
ManuallyMapped = MapManual(x.ManuallyMapped),
+ ManuallyMappedList = global::System.Linq.Enumerable.ToList(global::System.Linq.Enumerable.Select(x.ManuallyMappedList, x1 => MapManual(x1))),
});
#nullable enable
}
@@ -77,6 +78,10 @@ public static partial class ProjectionMapper
target.NestedNullableIntValue = testObject.NestedNullable.IntValue;
target.NestedNullable = MapToTestObjectNestedDto(testObject.NestedNullable);
}
+ else
+ {
+ target.NestedNullable = null;
+ }
if (testObject.NestedNullableTargetNotNullable != null)
{
target.NestedNullableTargetNotNullable = MapToTestObjectNestedDto(testObject.NestedNullableTargetNotNullable);
@@ -89,10 +94,18 @@ public static partial class ProjectionMapper
{
target.NullableReadOnlyObjectCollection = MapToIReadOnlyCollection(testObject.NullableReadOnlyObjectCollection);
}
+ else
+ {
+ target.NullableReadOnlyObjectCollection = null;
+ }
if (testObject.SubObject != null)
{
target.SubObject = MapToInheritanceSubObjectDto(testObject.SubObject);
}
+ else
+ {
+ target.SubObject = null;
+ }
target.IntValue = testObject.IntValue;
target.StringValue = testObject.StringValue;
target.RenamedStringValue2 = testObject.RenamedStringValue;
@@ -107,6 +120,7 @@ public static partial class ProjectionMapper
target.DateTimeValueTargetDateOnly = global::System.DateOnly.FromDateTime(testObject.DateTimeValueTargetDateOnly);
target.DateTimeValueTargetTimeOnly = global::System.TimeOnly.FromDateTime(testObject.DateTimeValueTargetTimeOnly);
target.ManuallyMapped = MapManual(testObject.ManuallyMapped);
+ target.ManuallyMappedList = MapToList(testObject.ManuallyMappedList);
return target;
}
@@ -186,5 +200,15 @@ private static string MapToString(global::Riok.Mapperly.IntegrationTests.Models.
target.BaseIntValue = source.BaseIntValue;
return target;
}
+
+ private static global::System.Collections.Generic.List MapToList(global::System.Collections.Generic.List source)
+ {
+ var target = new global::System.Collections.Generic.List(source.Count);
+ foreach (var item in source)
+ {
+ target.Add(MapManual(item));
+ }
+ return target;
+ }
}
}
\ No newline at end of file
diff --git a/test/Riok.Mapperly.IntegrationTests/_snapshots/StaticMapperTest.RunExtensionMappingShouldWork.verified.txt b/test/Riok.Mapperly.IntegrationTests/_snapshots/StaticMapperTest.RunExtensionMappingShouldWork.verified.txt
index ebc087b139..3b351ccf72 100644
--- a/test/Riok.Mapperly.IntegrationTests/_snapshots/StaticMapperTest.RunExtensionMappingShouldWork.verified.txt
+++ b/test/Riok.Mapperly.IntegrationTests/_snapshots/StaticMapperTest.RunExtensionMappingShouldWork.verified.txt
@@ -42,20 +42,25 @@
EnumValue: DtoValue1,
EnumName: Value30,
EnumStringValue: 0,
- EnumReverseStringValue: DtoValue3
+ EnumReverseStringValue: DtoValue3,
+ FormattedIntValue: ,
+ FormattedDateValue: ,
+ ExposePrivateValue: 26
},
SourceTargetSameObjectType: {
CtorValue: 8,
CtorValue2: 100,
IntValue: 99,
RequiredValue: 98,
+ UnmappedValue: 10,
StringValue: ,
RenamedStringValue: ,
Flattening: {},
ImmutableArrayValue: null,
ImmutableQueueValue: [],
ImmutableStackValue: [],
- EnumReverseStringValue:
+ EnumReverseStringValue: ,
+ ExposePrivateValue: 19
},
NullableReadOnlyObjectCollection: [
{
@@ -170,5 +175,8 @@
BaseIntValue: 1
},
DateTimeValueTargetDateOnly: 2020-01-03,
- DateTimeValueTargetTimeOnly: 3:10 PM
+ DateTimeValueTargetTimeOnly: 3:10 PM,
+ FormattedIntValue: ,
+ FormattedDateValue: ,
+ ExposePrivateValue: 28
}
\ No newline at end of file
diff --git a/test/Riok.Mapperly.IntegrationTests/_snapshots/StaticMapperTest.RunMappingShouldWork.verified.txt b/test/Riok.Mapperly.IntegrationTests/_snapshots/StaticMapperTest.RunMappingShouldWork.verified.txt
index 31cad1c1be..a773be224e 100644
--- a/test/Riok.Mapperly.IntegrationTests/_snapshots/StaticMapperTest.RunMappingShouldWork.verified.txt
+++ b/test/Riok.Mapperly.IntegrationTests/_snapshots/StaticMapperTest.RunMappingShouldWork.verified.txt
@@ -47,20 +47,25 @@
EnumValue: DtoValue1,
EnumName: Value30,
EnumStringValue: 0,
- EnumReverseStringValue: DtoValue3
+ EnumReverseStringValue: DtoValue3,
+ FormattedIntValue: ,
+ FormattedDateValue: ,
+ ExposePrivateValue: 26
},
SourceTargetSameObjectType: {
CtorValue: 8,
CtorValue2: 100,
IntValue: 99,
RequiredValue: 98,
+ UnmappedValue: 10,
StringValue: ,
RenamedStringValue: ,
Flattening: {},
ImmutableArrayValue: null,
ImmutableQueueValue: [],
ImmutableStackValue: [],
- EnumReverseStringValue:
+ EnumReverseStringValue: ,
+ ExposePrivateValue: 19
},
NullableReadOnlyObjectCollection: [
{
@@ -175,5 +180,8 @@
BaseIntValue: 1
},
DateTimeValueTargetDateOnly: 2020-01-03,
- DateTimeValueTargetTimeOnly: 3:10 PM
+ DateTimeValueTargetTimeOnly: 3:10 PM,
+ FormattedIntValue: ,
+ FormattedDateValue: ,
+ ExposePrivateValue: 28
}
\ No newline at end of file
diff --git a/test/Riok.Mapperly.IntegrationTests/_snapshots/StaticMapperTest.SnapshotGeneratedSource.verified.cs b/test/Riok.Mapperly.IntegrationTests/_snapshots/StaticMapperTest.SnapshotGeneratedSource.verified.cs
index 93c5d77fd9..6b884bd7f1 100644
--- a/test/Riok.Mapperly.IntegrationTests/_snapshots/StaticMapperTest.SnapshotGeneratedSource.verified.cs
+++ b/test/Riok.Mapperly.IntegrationTests/_snapshots/StaticMapperTest.SnapshotGeneratedSource.verified.cs
@@ -11,7 +11,7 @@ public static partial int DirectInt(int value)
public static partial int? DirectIntNullable(int? value)
{
- return value == null ? default : value.Value;
+ return value == null ? default(int?) : value.Value;
}
public static partial long ImplicitCastInt(int value)
@@ -60,11 +60,19 @@ public static partial int ParseableInt(string value)
{
target.NullableFlatteningIdValue = CastIntNullable(src.NullableFlattening.IdValue);
}
+ else
+ {
+ target.NullableFlatteningIdValue = null;
+ }
if (src.NestedNullable != null)
{
target.NestedNullableIntValue = DirectInt(src.NestedNullable.IntValue);
target.NestedNullable = MapToTestObjectNestedDto(src.NestedNullable);
}
+ else
+ {
+ target.NestedNullable = null;
+ }
if (src.NestedNullableTargetNotNullable != null)
{
target.NestedNullableTargetNotNullable = MapToTestObjectNestedDto(src.NestedNullableTargetNotNullable);
@@ -77,18 +85,34 @@ public static partial int ParseableInt(string value)
{
target.TupleValue = MapToValueTuple(src.TupleValue.Value);
}
+ else
+ {
+ target.TupleValue = null;
+ }
if (src.RecursiveObject != null)
{
target.RecursiveObject = MapToDtoExt(src.RecursiveObject);
}
+ else
+ {
+ target.RecursiveObject = null;
+ }
if (src.NullableReadOnlyObjectCollection != null)
{
target.NullableReadOnlyObjectCollection = MapToTestObjectNestedDtoArray(src.NullableReadOnlyObjectCollection);
}
+ else
+ {
+ target.NullableReadOnlyObjectCollection = null;
+ }
if (src.SubObject != null)
{
target.SubObject = MapToInheritanceSubObjectDto(src.SubObject);
}
+ else
+ {
+ target.SubObject = null;
+ }
target.IntValue = DirectInt(src.IntValue);
target.StringValue = src.StringValue;
target.FlatteningIdValue = DirectInt(src.Flattening.IdValue);
@@ -143,6 +167,10 @@ public static partial int ParseableInt(string value)
{
target.NullableFlatteningIdValue = CastIntNullable(testObject.NullableFlattening.IdValue);
}
+ else
+ {
+ target.NullableFlatteningIdValue = null;
+ }
if (testObject.NullableUnflatteningIdValue != null)
{
target.NullableUnflattening ??= new();
@@ -153,6 +181,10 @@ public static partial int ParseableInt(string value)
target.NestedNullableIntValue = DirectInt(testObject.NestedNullable.IntValue);
target.NestedNullable = MapToTestObjectNestedDto(testObject.NestedNullable);
}
+ else
+ {
+ target.NestedNullable = null;
+ }
if (testObject.NestedNullableTargetNotNullable != null)
{
target.NestedNullableTargetNotNullable = MapToTestObjectNestedDto(testObject.NestedNullableTargetNotNullable);
@@ -165,18 +197,34 @@ public static partial int ParseableInt(string value)
{
target.TupleValue = MapToValueTuple(testObject.TupleValue.Value);
}
+ else
+ {
+ target.TupleValue = null;
+ }
if (testObject.RecursiveObject != null)
{
target.RecursiveObject = MapToDtoExt(testObject.RecursiveObject);
}
+ else
+ {
+ target.RecursiveObject = null;
+ }
if (testObject.NullableReadOnlyObjectCollection != null)
{
target.NullableReadOnlyObjectCollection = MapToTestObjectNestedDtoArray(testObject.NullableReadOnlyObjectCollection);
}
+ else
+ {
+ target.NullableReadOnlyObjectCollection = null;
+ }
if (testObject.SubObject != null)
{
target.SubObject = MapToInheritanceSubObjectDto(testObject.SubObject);
}
+ else
+ {
+ target.SubObject = null;
+ }
target.IntValue = DirectInt(testObject.IntValue);
target.StringValue = testObject.StringValue;
target.RenamedStringValue2 = testObject.RenamedStringValue;
@@ -233,26 +281,50 @@ public static partial int ParseableInt(string value)
{
target.NullableUnflatteningIdValue = CastIntNullable(dto.NullableUnflattening.IdValue);
}
+ else
+ {
+ target.NullableUnflatteningIdValue = null;
+ }
if (dto.NestedNullable != null)
{
target.NestedNullable = MapToTestObjectNested(dto.NestedNullable);
}
+ else
+ {
+ target.NestedNullable = null;
+ }
if (dto.TupleValue != null)
{
target.TupleValue = MapToValueTuple1(dto.TupleValue.Value);
}
+ else
+ {
+ target.TupleValue = null;
+ }
if (dto.RecursiveObject != null)
{
target.RecursiveObject = MapFromDto(dto.RecursiveObject);
}
+ else
+ {
+ target.RecursiveObject = null;
+ }
if (dto.NullableReadOnlyObjectCollection != null)
{
target.NullableReadOnlyObjectCollection = MapToIReadOnlyCollection(dto.NullableReadOnlyObjectCollection);
}
+ else
+ {
+ target.NullableReadOnlyObjectCollection = null;
+ }
if (dto.SubObject != null)
{
target.SubObject = MapToInheritanceSubObject(dto.SubObject);
}
+ else
+ {
+ target.SubObject = null;
+ }
target.IntValue = DirectInt(dto.IntValue);
target.StringValue = dto.StringValue;
target.UnflatteningIdValue = DirectInt(dto.Unflattening.IdValue);
@@ -304,11 +376,19 @@ public static partial void UpdateDto(global::Riok.Mapperly.IntegrationTests.Mode
{
target.NullableFlatteningIdValue = CastIntNullable(source.NullableFlattening.IdValue);
}
+ else
+ {
+ target.NullableFlatteningIdValue = null;
+ }
if (source.NestedNullable != null)
{
target.NestedNullableIntValue = DirectInt(source.NestedNullable.IntValue);
target.NestedNullable = MapToTestObjectNestedDto(source.NestedNullable);
}
+ else
+ {
+ target.NestedNullable = null;
+ }
if (source.NestedNullableTargetNotNullable != null)
{
target.NestedNullableTargetNotNullable = MapToTestObjectNestedDto(source.NestedNullableTargetNotNullable);
@@ -321,18 +401,34 @@ public static partial void UpdateDto(global::Riok.Mapperly.IntegrationTests.Mode
{
target.TupleValue = MapToValueTuple(source.TupleValue.Value);
}
+ else
+ {
+ target.TupleValue = null;
+ }
if (source.RecursiveObject != null)
{
target.RecursiveObject = MapToDtoExt(source.RecursiveObject);
}
+ else
+ {
+ target.RecursiveObject = null;
+ }
if (source.NullableReadOnlyObjectCollection != null)
{
target.NullableReadOnlyObjectCollection = MapToTestObjectNestedDtoArray(source.NullableReadOnlyObjectCollection);
}
+ else
+ {
+ target.NullableReadOnlyObjectCollection = null;
+ }
if (source.SubObject != null)
{
target.SubObject = MapToInheritanceSubObjectDto(source.SubObject);
}
+ else
+ {
+ target.SubObject = null;
+ }
target.CtorValue = DirectInt(source.CtorValue);
target.CtorValue2 = DirectInt(source.CtorValue2);
target.IntValue = DirectInt(source.IntValue);