Skip to content

Commit b1d40f5

Browse files
committed
use null instead of empty string when formatting
1 parent d8a0207 commit b1d40f5

16 files changed

+12
-29
lines changed

src/EntityChange/EntityComparer.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -406,14 +406,14 @@ private void CreateChange(
406406
_changes.Add(changeRecord);
407407
}
408408

409-
private static string FormatValue(object? value, Func<object?, string?>? formatter)
409+
private static string? FormatValue(object? value, Func<object?, string?>? formatter)
410410
{
411411
if (value is null)
412-
return string.Empty;
412+
return null;
413413

414414
if (formatter is not null)
415-
return formatter(value) ?? string.Empty;
415+
return formatter(value);
416416

417-
return value?.ToString() ?? string.Empty;
417+
return value?.ToString();
418418
}
419419
}

test/EntityChange.Tests/Snapshots/EntityCompareTests.CompareCollectionAddItemTest.verified.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
Quanity: 1,
2929
UnitPrice: 5000.0
3030
},
31-
OriginalFormatted: ,
3231
CurrentFormatted: EntityChange.Tests.Models.OrderLine
3332
},
3433
{

test/EntityChange.Tests/Snapshots/EntityCompareTests.CompareCollectionRemoveItemTest.verified.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,7 @@
2929
Quanity: 1,
3030
UnitPrice: 5000.0
3131
},
32-
OriginalFormatted: EntityChange.Tests.Models.OrderLine,
33-
CurrentFormatted:
32+
OriginalFormatted: EntityChange.Tests.Models.OrderLine
3433
},
3534
{
3635
PropertyName: Total,

test/EntityChange.Tests/Snapshots/EntityCompareTests.CompareCollectionRemoveTest.verified.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,7 @@
1919
Quanity: 1,
2020
UnitPrice: 5000.0
2121
},
22-
OriginalFormatted: abc-123,
23-
CurrentFormatted:
22+
OriginalFormatted: abc-123
2423
},
2524
{
2625
PropertyName: Total,

test/EntityChange.Tests/Snapshots/EntityCompareTests.CompareCollectionReplaceTest.verified.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
Quanity: 1,
1919
UnitPrice: 5000.0
2020
},
21-
OriginalFormatted: ,
2221
CurrentFormatted: abc-123
2322
},
2423
{

test/EntityChange.Tests/Snapshots/EntityCompareTests.CompareComplexCompareTest.verified.txt

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@
55
Path: Roles,
66
Operation: Remove,
77
OriginalValue: Administrator,
8-
OriginalFormatted: Administrator,
9-
CurrentFormatted:
8+
OriginalFormatted: Administrator
109
},
1110
{
1211
PropertyName: Address,
@@ -25,7 +24,6 @@
2524
CurrentValue: {
2625
Address: user@home.com
2726
},
28-
OriginalFormatted: ,
2927
CurrentFormatted: user@home.com
3028
},
3129
{
@@ -73,7 +71,6 @@
7371
DisplayName: Categories,
7472
Path: Categories[2],
7573
CurrentValue: Blah,
76-
OriginalFormatted: ,
7774
CurrentFormatted: Blah
7875
},
7976
{

test/EntityChange.Tests/Snapshots/EntityCompareTests.CompareDictionaryAddItemTest.verified.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
DisplayName: Data,
55
Path: Data[Path],
66
CurrentValue: ./home,
7-
OriginalFormatted: ,
87
CurrentFormatted: ./home
98
}
109
]

test/EntityChange.Tests/Snapshots/EntityCompareTests.CompareDictionaryRemoveItemTest.verified.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
Path: Data[Path],
66
Operation: Remove,
77
OriginalValue: ./home,
8-
OriginalFormatted: ./home,
9-
CurrentFormatted:
8+
OriginalFormatted: ./home
109
}
1110
]

test/EntityChange.Tests/Snapshots/EntityCompareTests.CompareDictionaryRemoveTest.verified.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
Path: Data[Boost],
66
Operation: Remove,
77
OriginalValue: 1,
8-
OriginalFormatted: 1,
9-
CurrentFormatted:
8+
OriginalFormatted: 1
109
}
1110
]

test/EntityChange.Tests/Snapshots/EntityCompareTests.CompareDictionaryReplaceTest.verified.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
DisplayName: Data,
55
Path: Data[Boost],
66
CurrentValue: 1,
7-
OriginalFormatted: ,
87
CurrentFormatted: 1
98
}
109
]

0 commit comments

Comments
 (0)