Skip to content

Commit

Permalink
Respect null value handling in WriteMember for converter (#1346)
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonCropp authored Nov 13, 2024
1 parent c889294 commit 7b7b409
Show file tree
Hide file tree
Showing 26 changed files with 191 additions and 56 deletions.
26 changes: 13 additions & 13 deletions docs/dates.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ var target = new DateTimeTarget

await Verify(target);
```
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L1022-L1041' title='Snippet source file'>snippet source</a> | <a href='#snippet-Date' title='Start of snippet'>anchor</a></sup>
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L1044-L1063' title='Snippet source file'>snippet source</a> | <a href='#snippet-Date' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->

Results in the following:
Expand Down Expand Up @@ -70,7 +70,7 @@ settings.DontScrubDateTimes();

return Verify(target, settings);
```
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L1661-L1673' title='Snippet source file'>snippet source</a> | <a href='#snippet-DontScrubDateTimes' title='Start of snippet'>anchor</a></sup>
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L1683-L1695' title='Snippet source file'>snippet source</a> | <a href='#snippet-DontScrubDateTimes' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->


Expand All @@ -87,7 +87,7 @@ var target = new
return Verify(target)
.DontScrubDateTimes();
```
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L1679-L1689' title='Snippet source file'>snippet source</a> | <a href='#snippet-DontScrubDateTimesFluent' title='Start of snippet'>anchor</a></sup>
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L1701-L1711' title='Snippet source file'>snippet source</a> | <a href='#snippet-DontScrubDateTimesFluent' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->


Expand All @@ -100,7 +100,7 @@ return Verify(target)
public static void ModuleInitializer() =>
VerifierSettings.DontScrubDateTimes();
```
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L1747-L1753' title='Snippet source file'>snippet source</a> | <a href='#snippet-DontScrubDateTimesGlobal' title='Start of snippet'>anchor</a></sup>
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L1769-L1775' title='Snippet source file'>snippet source</a> | <a href='#snippet-DontScrubDateTimesGlobal' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->


Expand All @@ -124,7 +124,7 @@ settings.DisableDateCounting();

return Verify(target, settings);
```
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L1708-L1720' title='Snippet source file'>snippet source</a> | <a href='#snippet-DisableDateCounting' title='Start of snippet'>anchor</a></sup>
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L1730-L1742' title='Snippet source file'>snippet source</a> | <a href='#snippet-DisableDateCounting' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->


Expand All @@ -141,7 +141,7 @@ var target = new
return Verify(target)
.DisableDateCounting();
```
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L1726-L1736' title='Snippet source file'>snippet source</a> | <a href='#snippet-DisableDateCountingFluent' title='Start of snippet'>anchor</a></sup>
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L1748-L1758' title='Snippet source file'>snippet source</a> | <a href='#snippet-DisableDateCountingFluent' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->


Expand All @@ -154,7 +154,7 @@ return Verify(target)
public static void ModuleInitializer() =>
VerifierSettings.DisableDateCounting();
```
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L1695-L1701' title='Snippet source file'>snippet source</a> | <a href='#snippet-DisableDateCountingGlobal' title='Start of snippet'>anchor</a></sup>
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L1717-L1723' title='Snippet source file'>snippet source</a> | <a href='#snippet-DisableDateCountingGlobal' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->


Expand Down Expand Up @@ -201,7 +201,7 @@ public Task ScrubInlineDateTimesInstance()
settings);
}
```
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L1631-L1643' title='Snippet source file'>snippet source</a> | <a href='#snippet-ScrubInlineDateTimesInstance' title='Start of snippet'>anchor</a></sup>
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L1653-L1665' title='Snippet source file'>snippet source</a> | <a href='#snippet-ScrubInlineDateTimesInstance' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->


Expand All @@ -215,7 +215,7 @@ public Task ScrubInlineDateTimesFluent() =>
Verify("content 2020-10-20 content")
.ScrubInlineDateTimes("yyyy-MM-dd");
```
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L1622-L1629' title='Snippet source file'>snippet source</a> | <a href='#snippet-ScrubInlineDateTimesFluent' title='Start of snippet'>anchor</a></sup>
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L1644-L1651' title='Snippet source file'>snippet source</a> | <a href='#snippet-ScrubInlineDateTimesFluent' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->


Expand All @@ -231,7 +231,7 @@ public static class ModuleInitializer
VerifierSettings.ScrubInlineDateTimes("yyyy-MM-dd");
}
```
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L1610-L1619' title='Snippet source file'>snippet source</a> | <a href='#snippet-ScrubInlineDateTimesGlobal' title='Start of snippet'>anchor</a></sup>
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L1632-L1641' title='Snippet source file'>snippet source</a> | <a href='#snippet-ScrubInlineDateTimesGlobal' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->


Expand All @@ -252,7 +252,7 @@ settings.AddNamedDateTime(new(2030, 1, 2), "instanceNamedDateTime");
settings.AddNamedDateTimeOffset(new DateTime(2030, 1, 2), "instanceNamedTimeOffset");
await Verify(target, settings);
```
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L1204-L1213' title='Snippet source file'>snippet source</a> | <a href='#snippet-NamedDatesAndTimesInstance' title='Start of snippet'>anchor</a></sup>
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L1226-L1235' title='Snippet source file'>snippet source</a> | <a href='#snippet-NamedDatesAndTimesInstance' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->


Expand All @@ -267,7 +267,7 @@ await Verify(target)
.AddNamedDateTime(new(2030, 1, 2), "instanceNamedDateTime")
.AddNamedDateTimeOffset(new DateTime(2030, 1, 2), "instanceNamedTimeOffset");
```
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L1161-L1169' title='Snippet source file'>snippet source</a> | <a href='#snippet-NamedDatesAndTimesFluent' title='Start of snippet'>anchor</a></sup>
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L1183-L1191' title='Snippet source file'>snippet source</a> | <a href='#snippet-NamedDatesAndTimesFluent' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->


Expand All @@ -285,7 +285,7 @@ public static void NamedDatesAndTimesGlobal()
VerifierSettings.AddNamedDateTimeOffset(new(new(2030, 1, 1)), "namedDateTimeOffset");
}
```
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L1116-L1127' title='Snippet source file'>snippet source</a> | <a href='#snippet-NamedDatesAndTimesGlobal' title='Start of snippet'>anchor</a></sup>
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L1138-L1149' title='Snippet source file'>snippet source</a> | <a href='#snippet-NamedDatesAndTimesGlobal' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->


Expand Down
10 changes: 5 additions & 5 deletions docs/guids.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ var target = new GuidTarget

await Verify(target);
```
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L2010-L2023' title='Snippet source file'>snippet source</a> | <a href='#snippet-guid' title='Start of snippet'>anchor</a></sup>
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L2032-L2045' title='Snippet source file'>snippet source</a> | <a href='#snippet-guid' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->

Results in the following:
Expand Down Expand Up @@ -79,7 +79,7 @@ await Verify(target)
```cs
VerifierSettings.DontScrubGuids();
```
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L1539-L1543' title='Snippet source file'>snippet source</a> | <a href='#snippet-DontScrubGuidsGlobal' title='Start of snippet'>anchor</a></sup>
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L1561-L1565' title='Snippet source file'>snippet source</a> | <a href='#snippet-DontScrubGuidsGlobal' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->


Expand All @@ -103,7 +103,7 @@ public Task ScrubInlineGuidsInstance()
settings);
}
```
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L1595-L1607' title='Snippet source file'>snippet source</a> | <a href='#snippet-ScrubInlineGuidsInstance' title='Start of snippet'>anchor</a></sup>
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L1617-L1629' title='Snippet source file'>snippet source</a> | <a href='#snippet-ScrubInlineGuidsInstance' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->


Expand All @@ -117,7 +117,7 @@ public Task ScrubInlineGuidsFluent() =>
Verify("content 651ad409-fc30-4b12-a47e-616d3f953e4c content")
.ScrubInlineGuids();
```
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L1586-L1593' title='Snippet source file'>snippet source</a> | <a href='#snippet-ScrubInlineGuidsFluent' title='Start of snippet'>anchor</a></sup>
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L1608-L1615' title='Snippet source file'>snippet source</a> | <a href='#snippet-ScrubInlineGuidsFluent' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->


Expand All @@ -133,7 +133,7 @@ public static class ModuleInitializer
VerifierSettings.ScrubInlineGuids();
}
```
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L1574-L1583' title='Snippet source file'>snippet source</a> | <a href='#snippet-ScrubInlineGuidsGlobal' title='Start of snippet'>anchor</a></sup>
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L1596-L1605' title='Snippet source file'>snippet source</a> | <a href='#snippet-ScrubInlineGuidsGlobal' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->


Expand Down
4 changes: 2 additions & 2 deletions docs/named-tuples.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Given a method that returns a named tuple:
static (bool Member1, string Member2, string Member3) MethodWithNamedTuple() =>
(true, "A", "B");
```
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L1945-L1950' title='Snippet source file'>snippet source</a> | <a href='#snippet-MethodWithNamedTuple' title='Start of snippet'>anchor</a></sup>
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L1967-L1972' title='Snippet source file'>snippet source</a> | <a href='#snippet-MethodWithNamedTuple' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->

Can be verified:
Expand All @@ -29,7 +29,7 @@ Can be verified:
```cs
await VerifyTuple(() => MethodWithNamedTuple());
```
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L1939-L1943' title='Snippet source file'>snippet source</a> | <a href='#snippet-VerifyTuple' title='Start of snippet'>anchor</a></sup>
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L1961-L1965' title='Snippet source file'>snippet source</a> | <a href='#snippet-VerifyTuple' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->

Resulting in:
Expand Down
12 changes: 6 additions & 6 deletions docs/scrubbers.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ For example remove lines containing `text`:
```cs
verifySettings.ScrubLines(line => line.Contains("text"));
```
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L1769-L1773' title='Snippet source file'>snippet source</a> | <a href='#snippet-ScrubLines' title='Start of snippet'>anchor</a></sup>
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L1791-L1795' title='Snippet source file'>snippet source</a> | <a href='#snippet-ScrubLines' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->


Expand All @@ -74,7 +74,7 @@ For example remove lines containing `text1` or `text2`
```cs
verifySettings.ScrubLinesContaining("text1", "text2");
```
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L1775-L1779' title='Snippet source file'>snippet source</a> | <a href='#snippet-ScrubLinesContaining' title='Start of snippet'>anchor</a></sup>
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L1797-L1801' title='Snippet source file'>snippet source</a> | <a href='#snippet-ScrubLinesContaining' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->

Case insensitive by default (StringComparison.OrdinalIgnoreCase).
Expand All @@ -86,7 +86,7 @@ Case insensitive by default (StringComparison.OrdinalIgnoreCase).
```cs
verifySettings.ScrubLinesContaining(StringComparison.Ordinal, "text1", "text2");
```
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L1781-L1785' title='Snippet source file'>snippet source</a> | <a href='#snippet-ScrubLinesContainingOrdinal' title='Start of snippet'>anchor</a></sup>
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L1803-L1807' title='Snippet source file'>snippet source</a> | <a href='#snippet-ScrubLinesContainingOrdinal' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->


Expand All @@ -101,7 +101,7 @@ For example converts lines to upper case:
```cs
verifySettings.ScrubLinesWithReplace(line => line.ToUpper());
```
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L1787-L1791' title='Snippet source file'>snippet source</a> | <a href='#snippet-ScrubLinesWithReplace' title='Start of snippet'>anchor</a></sup>
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L1809-L1813' title='Snippet source file'>snippet source</a> | <a href='#snippet-ScrubLinesWithReplace' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->


Expand All @@ -114,7 +114,7 @@ Replaces `Environment.MachineName` with `TheMachineName`.
```cs
verifySettings.ScrubMachineName();
```
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L1793-L1797' title='Snippet source file'>snippet source</a> | <a href='#snippet-ScrubMachineName' title='Start of snippet'>anchor</a></sup>
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L1815-L1819' title='Snippet source file'>snippet source</a> | <a href='#snippet-ScrubMachineName' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->


Expand All @@ -127,7 +127,7 @@ Replaces `Environment.UserName` with `TheUserName`.
```cs
verifySettings.ScrubUserName();
```
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L1799-L1803' title='Snippet source file'>snippet source</a> | <a href='#snippet-ScrubUserName' title='Start of snippet'>anchor</a></sup>
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L1821-L1825' title='Snippet source file'>snippet source</a> | <a href='#snippet-ScrubUserName' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->


Expand Down
Loading

0 comments on commit 7b7b409

Please sign in to comment.