Skip to content

Commit

Permalink
Boolean properties with false or null are missing from the output
Browse files Browse the repository at this point in the history
fixes #447
  • Loading branch information
SimonCropp committed Dec 7, 2021
1 parent 397a144 commit d293fb5
Show file tree
Hide file tree
Showing 35 changed files with 153 additions and 123 deletions.
4 changes: 2 additions & 2 deletions docs/named-tuples.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ static (bool Member1, string Member2, string Member3) MethodWithNamedTuple()
return (true, "A", "B");
}
```
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L1067-L1074' 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#L1054-L1061' title='Snippet source file'>snippet source</a> | <a href='#snippet-methodwithnamedtuple' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->

Can be verified:
Expand All @@ -31,7 +31,7 @@ Can be verified:
```cs
await Verifier.VerifyTuple(() => MethodWithNamedTuple());
```
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L1060-L1064' 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#L1047-L1051' title='Snippet source file'>snippet source</a> | <a href='#snippet-verifytuple' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->

Resulting in:
Expand Down
10 changes: 5 additions & 5 deletions docs/scrubbers.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ For example remove lines containing `text`:
```cs
verifySettings.ScrubLines(line => line.Contains("text"));
```
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L938-L942' 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#L925-L929' title='Snippet source file'>snippet source</a> | <a href='#snippet-scrublines' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->


Expand All @@ -71,7 +71,7 @@ For example remove lines containing `text1` or `text2`
```cs
verifySettings.ScrubLinesContaining("text1", "text2");
```
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L944-L948' 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#L931-L935' 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 @@ -83,7 +83,7 @@ Case insensitive by default (StringComparison.OrdinalIgnoreCase).
```cs
verifySettings.ScrubLinesContaining(StringComparison.Ordinal, "text1", "text2");
```
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L950-L954' 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#L937-L941' title='Snippet source file'>snippet source</a> | <a href='#snippet-scrublinescontainingordinal' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->


Expand All @@ -98,7 +98,7 @@ For example converts lines to upper case:
```cs
verifySettings.ScrubLinesWithReplace(line => line.ToUpper());
```
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L956-L960' 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#L943-L947' title='Snippet source file'>snippet source</a> | <a href='#snippet-scrublineswithreplace' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->


Expand All @@ -111,7 +111,7 @@ Replaces `Environment.MachineName` with `TheMachineName`.
```cs
verifySettings.ScrubMachineName();
```
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L962-L966' 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#L949-L953' title='Snippet source file'>snippet source</a> | <a href='#snippet-scrubmachinename' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->


Expand Down
54 changes: 27 additions & 27 deletions docs/serializer-settings.md
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ To disable this behavior globally use:
```cs
VerifierSettings.ModifySerialization(_ => _.DontIgnoreEmptyCollections());
```
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L808-L812' title='Snippet source file'>snippet source</a> | <a href='#snippet-dontignoreemptycollections' title='Start of snippet'>anchor</a></sup>
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L795-L799' title='Snippet source file'>snippet source</a> | <a href='#snippet-dontignoreemptycollections' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->


Expand All @@ -183,7 +183,7 @@ var target = new GuidTarget

await Verifier.Verify(target);
```
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L1134-L1147' 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#L1121-L1134' title='Snippet source file'>snippet source</a> | <a href='#snippet-guid' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->

Results in the following:
Expand All @@ -208,7 +208,7 @@ Strings containing inline Guids can also be scrubbed. To enable this behavior, u
```cs
VerifierSettings.ScrubInlineGuids();
```
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L844-L848' title='Snippet source file'>snippet source</a> | <a href='#snippet-scrubinlineguids' title='Start of snippet'>anchor</a></sup>
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L831-L835' title='Snippet source file'>snippet source</a> | <a href='#snippet-scrubinlineguids' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->


Expand Down Expand Up @@ -244,7 +244,7 @@ To disable this behavior globally use:
```cs
VerifierSettings.ModifySerialization(_ => _.DontScrubGuids());
```
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L817-L821' 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#L804-L808' title='Snippet source file'>snippet source</a> | <a href='#snippet-dontscrubguidsglobal' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->


Expand Down Expand Up @@ -272,7 +272,7 @@ var target = new DateTimeTarget

await Verifier.Verify(target);
```
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L629-L648' 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#L616-L635' 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 @@ -310,7 +310,7 @@ settings.ModifySerialization(_ => _.DontScrubDateTimes());

return Verifier.Verify(target, settings);
```
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L880-L892' 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#L867-L879' title='Snippet source file'>snippet source</a> | <a href='#snippet-dontscrubdatetimes' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->

Or using the fluent api use:
Expand All @@ -326,7 +326,7 @@ var target = new
return Verifier.Verify(target)
.ModifySerialization(_ => _.DontScrubDateTimes());
```
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L897-L907' 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#L884-L894' title='Snippet source file'>snippet source</a> | <a href='#snippet-dontscrubdatetimesfluent' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->

Or globally use:
Expand All @@ -336,7 +336,7 @@ Or globally use:
```cs
VerifierSettings.ModifySerialization(_ => _.DontScrubDateTimes());
```
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L912-L916' 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#L899-L903' title='Snippet source file'>snippet source</a> | <a href='#snippet-dontscrubdatetimesglobal' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->


Expand Down Expand Up @@ -488,7 +488,7 @@ To disable this behavior globally use:
```cs
VerifierSettings.ModifySerialization(_ => _.DontIgnoreFalse());
```
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L921-L925' title='Snippet source file'>snippet source</a> | <a href='#snippet-dontignorefalse' title='Start of snippet'>anchor</a></sup>
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L908-L912' title='Snippet source file'>snippet source</a> | <a href='#snippet-dontignorefalse' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->


Expand Down Expand Up @@ -642,7 +642,7 @@ public Task ScopedSerializerFluent()
_ => { _.TypeNameHandling = TypeNameHandling.All; });
}
```
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L2066-L2095' title='Snippet source file'>snippet source</a> | <a href='#snippet-scopedserializer' title='Start of snippet'>anchor</a></sup>
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L2053-L2082' title='Snippet source file'>snippet source</a> | <a href='#snippet-scopedserializer' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->

Result:
Expand Down Expand Up @@ -705,7 +705,7 @@ public Task IgnoreTypeFluent()

}
```
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L1452-L1492' title='Snippet source file'>snippet source</a> | <a href='#snippet-addignoretype' title='Start of snippet'>anchor</a></sup>
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L1439-L1479' title='Snippet source file'>snippet source</a> | <a href='#snippet-addignoretype' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->

Or globally:
Expand All @@ -716,7 +716,7 @@ Or globally:
VerifierSettings.ModifySerialization(
_ => _.IgnoreMembersWithType<ToIgnore>());
```
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L1444-L1449' title='Snippet source file'>snippet source</a> | <a href='#snippet-addignoretypeglobal' title='Start of snippet'>anchor</a></sup>
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L1431-L1436' title='Snippet source file'>snippet source</a> | <a href='#snippet-addignoretypeglobal' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->

Result:
Expand Down Expand Up @@ -780,7 +780,7 @@ public Task AddIgnoreInstanceFluent()
_ => { _.IgnoreInstance<Instance>(x => x.Property == "Ignore"); });
}
```
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L1388-L1429' title='Snippet source file'>snippet source</a> | <a href='#snippet-addignoreinstance' title='Start of snippet'>anchor</a></sup>
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L1375-L1416' title='Snippet source file'>snippet source</a> | <a href='#snippet-addignoreinstance' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->

Or globally:
Expand All @@ -791,7 +791,7 @@ Or globally:
VerifierSettings.ModifySerialization(
_ => { _.IgnoreInstance<Instance>(x => x.Property == "Ignore"); });
```
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L1380-L1385' title='Snippet source file'>snippet source</a> | <a href='#snippet-addignoreinstanceglobal' title='Start of snippet'>anchor</a></sup>
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L1367-L1372' title='Snippet source file'>snippet source</a> | <a href='#snippet-addignoreinstanceglobal' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->

Result:
Expand Down Expand Up @@ -835,7 +835,7 @@ public Task WithObsoleteProp()
return Verifier.Verify(target);
}
```
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L2027-L2048' title='Snippet source file'>snippet source</a> | <a href='#snippet-withobsoleteprop' title='Start of snippet'>anchor</a></sup>
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L2014-L2035' title='Snippet source file'>snippet source</a> | <a href='#snippet-withobsoleteprop' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->

Result:
Expand Down Expand Up @@ -883,7 +883,7 @@ public Task WithObsoletePropIncludedFluent()
.ModifySerialization(_ => { _.IncludeObsoletes(); });
}
```
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L1998-L2025' title='Snippet source file'>snippet source</a> | <a href='#snippet-withobsoletepropincluded' title='Start of snippet'>anchor</a></sup>
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L1985-L2012' title='Snippet source file'>snippet source</a> | <a href='#snippet-withobsoletepropincluded' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->

Or globally:
Expand All @@ -893,7 +893,7 @@ Or globally:
```cs
VerifierSettings.ModifySerialization(_ => { _.IncludeObsoletes(); });
```
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L1991-L1995' title='Snippet source file'>snippet source</a> | <a href='#snippet-withobsoletepropincludedglobally' title='Start of snippet'>anchor</a></sup>
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L1978-L1982' title='Snippet source file'>snippet source</a> | <a href='#snippet-withobsoletepropincludedglobally' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->

Result:
Expand Down Expand Up @@ -958,7 +958,7 @@ public Task IgnoreMemberByExpressionFluent()
});
}
```
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L1595-L1638' title='Snippet source file'>snippet source</a> | <a href='#snippet-ignorememberbyexpression' title='Start of snippet'>anchor</a></sup>
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L1582-L1625' title='Snippet source file'>snippet source</a> | <a href='#snippet-ignorememberbyexpression' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->

Or globally
Expand All @@ -975,7 +975,7 @@ VerifierSettings.ModifySerialization(_ =>
_.IgnoreMember<IgnoreExplicitTarget>(x => x.PropertyThatThrows);
});
```
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L1581-L1592' title='Snippet source file'>snippet source</a> | <a href='#snippet-ignorememberbyexpressionglobal' title='Start of snippet'>anchor</a></sup>
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L1568-L1579' title='Snippet source file'>snippet source</a> | <a href='#snippet-ignorememberbyexpressionglobal' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->

Result:
Expand Down Expand Up @@ -1043,7 +1043,7 @@ public Task IgnoreMemberByNameFluent()
});
}
```
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L1722-L1769' title='Snippet source file'>snippet source</a> | <a href='#snippet-ignorememberbyname' title='Start of snippet'>anchor</a></sup>
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L1709-L1756' title='Snippet source file'>snippet source</a> | <a href='#snippet-ignorememberbyname' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->

Or globally:
Expand All @@ -1061,7 +1061,7 @@ VerifierSettings.ModifySerialization(_ =>
_.IgnoreMember(type, "PropertyThatThrows");
});
```
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L1707-L1719' title='Snippet source file'>snippet source</a> | <a href='#snippet-ignorememberbynameglobal' title='Start of snippet'>anchor</a></sup>
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L1694-L1706' title='Snippet source file'>snippet source</a> | <a href='#snippet-ignorememberbynameglobal' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->

Result:
Expand Down Expand Up @@ -1107,7 +1107,7 @@ public Task CustomExceptionPropFluent()
.ModifySerialization(_ => _.IgnoreMembersThatThrow<CustomException>());
}
```
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L1888-L1907' title='Snippet source file'>snippet source</a> | <a href='#snippet-ignoremembersthatthrow' title='Start of snippet'>anchor</a></sup>
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L1875-L1894' title='Snippet source file'>snippet source</a> | <a href='#snippet-ignoremembersthatthrow' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->

Or globally:
Expand All @@ -1117,7 +1117,7 @@ Or globally:
```cs
VerifierSettings.ModifySerialization(_ => _.IgnoreMembersThatThrow<CustomException>());
```
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L1881-L1885' title='Snippet source file'>snippet source</a> | <a href='#snippet-ignoremembersthatthrowglobal' title='Start of snippet'>anchor</a></sup>
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L1868-L1872' title='Snippet source file'>snippet source</a> | <a href='#snippet-ignoremembersthatthrowglobal' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->

Result:
Expand Down Expand Up @@ -1156,7 +1156,7 @@ public Task ExceptionMessagePropFluent()
_ => _.IgnoreMembersThatThrow<Exception>(x => x.Message == "Ignore"));
}
```
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L1325-L1348' title='Snippet source file'>snippet source</a> | <a href='#snippet-ignoremembersthatthrowexpression' title='Start of snippet'>anchor</a></sup>
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L1312-L1335' title='Snippet source file'>snippet source</a> | <a href='#snippet-ignoremembersthatthrowexpression' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->

Or globally:
Expand All @@ -1167,7 +1167,7 @@ Or globally:
VerifierSettings.ModifySerialization(
_ => _.IgnoreMembersThatThrow<Exception>(x => x.Message == "Ignore"));
```
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L1317-L1322' title='Snippet source file'>snippet source</a> | <a href='#snippet-ignoremembersthatthrowexpressionglobal' title='Start of snippet'>anchor</a></sup>
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L1304-L1309' title='Snippet source file'>snippet source</a> | <a href='#snippet-ignoremembersthatthrowexpressionglobal' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->

Result:
Expand Down Expand Up @@ -1320,7 +1320,7 @@ public Task MemberConverterByExpressionFluent()
});
}
```
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L1641-L1680' title='Snippet source file'>snippet source</a> | <a href='#snippet-memberconverter' title='Start of snippet'>anchor</a></sup>
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L1628-L1667' title='Snippet source file'>snippet source</a> | <a href='#snippet-memberconverter' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->

This can also be configured globally:
Expand All @@ -1338,7 +1338,7 @@ VerifierSettings.ModifySerialization(_ =>
(target, value) => value + "Suffix");
});
```
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L1684-L1696' title='Snippet source file'>snippet source</a> | <a href='#snippet-memberconverterglobal' title='Start of snippet'>anchor</a></sup>
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L1671-L1683' title='Snippet source file'>snippet source</a> | <a href='#snippet-memberconverterglobal' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->


Expand Down
Loading

0 comments on commit d293fb5

Please sign in to comment.