enable null in OrderEnumerableBy (#1017)

* enable null in OrderEnumerableBy

* Create SerializationTests.EnumerableOrderWithNull.verified.json
This commit is contained in:
Simon Cropp 2023-10-06 11:36:51 +11:00 коммит произвёл GitHub
Родитель ff21322997
Коммит 19ea6261f1
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
11 изменённых файлов: 83 добавлений и 60 удалений

Просмотреть файл

@ -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#L1584-L1589' 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#L1596-L1601' title='Snippet source file'>snippet source</a> | <a href='#snippet-methodwithnamedtuple' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->
Can be verified:
@ -29,7 +29,7 @@ Can be verified:
```cs
await VerifyTuple(() => MethodWithNamedTuple());
```
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L1577-L1581' 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#L1589-L1593' title='Snippet source file'>snippet source</a> | <a href='#snippet-verifytuple' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->
Resulting in:

Просмотреть файл

@ -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#L1427-L1431' 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#L1439-L1443' title='Snippet source file'>snippet source</a> | <a href='#snippet-scrublines' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->
@ -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#L1433-L1437' 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#L1445-L1449' 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).
@ -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#L1439-L1443' 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#L1451-L1455' title='Snippet source file'>snippet source</a> | <a href='#snippet-scrublinescontainingordinal' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->
@ -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#L1445-L1449' 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#L1457-L1461' title='Snippet source file'>snippet source</a> | <a href='#snippet-scrublineswithreplace' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->
@ -114,7 +114,7 @@ Replaces `Environment.MachineName` with `TheMachineName`.
```cs
verifySettings.ScrubMachineName();
```
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L1451-L1455' 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#L1463-L1467' title='Snippet source file'>snippet source</a> | <a href='#snippet-scrubmachinename' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->
@ -127,7 +127,7 @@ Replaces `Environment.UserName` with `TheUserName`.
```cs
verifySettings.ScrubUserName();
```
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L1457-L1461' 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#L1469-L1473' title='Snippet source file'>snippet source</a> | <a href='#snippet-scrubusername' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->

Просмотреть файл

@ -109,7 +109,7 @@ VerifierSettings
.AddExtraSettings(_ =>
_.TypeNameHandling = TypeNameHandling.All);
```
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L531-L537' title='Snippet source file'>snippet source</a> | <a href='#snippet-addextrasettingsglobal' title='Start of snippet'>anchor</a></sup>
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L543-L549' title='Snippet source file'>snippet source</a> | <a href='#snippet-addextrasettingsglobal' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->
@ -129,7 +129,7 @@ public Task AddExtraSettings()
return Verify("Value", settings);
}
```
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L501-L514' title='Snippet source file'>snippet source</a> | <a href='#snippet-addextrasettings' title='Start of snippet'>anchor</a></sup>
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L513-L526' title='Snippet source file'>snippet source</a> | <a href='#snippet-addextrasettings' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->
@ -145,7 +145,7 @@ public Task AddExtraSettingsFluent() =>
_ => _.Error = (currentObject, originalObject, location, exception, handled) =>
Console.WriteLine(location.Member));
```
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L516-L525' title='Snippet source file'>snippet source</a> | <a href='#snippet-addextrasettingsfluent' title='Start of snippet'>anchor</a></sup>
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L528-L537' title='Snippet source file'>snippet source</a> | <a href='#snippet-addextrasettingsfluent' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->
@ -165,7 +165,7 @@ To disable this behavior globally use:
```cs
VerifierSettings.DontIgnoreEmptyCollections();
```
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L1309-L1313' 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#L1321-L1325' title='Snippet source file'>snippet source</a> | <a href='#snippet-dontignoreemptycollections' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->
@ -187,7 +187,7 @@ var target = new GuidTarget
await Verify(target);
```
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L1649-L1662' 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#L1661-L1674' title='Snippet source file'>snippet source</a> | <a href='#snippet-guid' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->
Results in the following:
@ -212,7 +212,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#L1349-L1353' 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#L1361-L1365' title='Snippet source file'>snippet source</a> | <a href='#snippet-scrubinlineguids' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->
@ -227,7 +227,7 @@ var settings = new VerifySettings();
settings.DontScrubGuids();
await Verify(target, settings);
```
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L640-L646' title='Snippet source file'>snippet source</a> | <a href='#snippet-dontscrubguids' title='Start of snippet'>anchor</a></sup>
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L652-L658' title='Snippet source file'>snippet source</a> | <a href='#snippet-dontscrubguids' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->
Or with the fluent api:
@ -238,7 +238,7 @@ Or with the fluent api:
await Verify(target)
.DontScrubGuids();
```
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L654-L659' title='Snippet source file'>snippet source</a> | <a href='#snippet-dontscrubguidsfluent' title='Start of snippet'>anchor</a></sup>
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L666-L671' title='Snippet source file'>snippet source</a> | <a href='#snippet-dontscrubguidsfluent' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->
To disable this behavior globally use:
@ -248,7 +248,7 @@ To disable this behavior globally use:
```cs
VerifierSettings.DontScrubGuids();
```
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L1319-L1323' 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#L1331-L1335' title='Snippet source file'>snippet source</a> | <a href='#snippet-dontscrubguidsglobal' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->
@ -312,7 +312,7 @@ var target = new DateTimeTarget
await Verify(target);
```
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L981-L1000' 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#L993-L1012' title='Snippet source file'>snippet source</a> | <a href='#snippet-date' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->
Results in the following:
@ -350,7 +350,7 @@ settings.DontScrubDateTimes();
return Verify(target, settings);
```
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L1373-L1385' 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#L1385-L1397' 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:
@ -366,7 +366,7 @@ var target = new
return Verify(target)
.DontScrubDateTimes();
```
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L1391-L1401' 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#L1403-L1413' title='Snippet source file'>snippet source</a> | <a href='#snippet-dontscrubdatetimesfluent' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->
Or globally use:
@ -376,7 +376,7 @@ Or globally use:
```cs
VerifierSettings.DontScrubDateTimes();
```
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L1408-L1412' 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#L1420-L1424' title='Snippet source file'>snippet source</a> | <a href='#snippet-dontscrubdatetimesglobal' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->
@ -399,7 +399,7 @@ public Task WithExtraDatetimeFormat() =>
date = "2022-11-08"
});
```
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L133-L147' title='Snippet source file'>snippet source</a> | <a href='#snippet-addextradatetimeformat' title='Start of snippet'>anchor</a></sup>
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L145-L159' title='Snippet source file'>snippet source</a> | <a href='#snippet-addextradatetimeformat' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->
@ -419,7 +419,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#L1116-L1122' title='Snippet source file'>snippet source</a> | <a href='#snippet-addinstancenameddatesandtimes' title='Start of snippet'>anchor</a></sup>
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L1128-L1134' title='Snippet source file'>snippet source</a> | <a href='#snippet-addinstancenameddatesandtimes' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->
@ -437,7 +437,7 @@ public static void AddNamedDatesAndTimes()
VerifierSettings.AddNamedDateTimeOffset(new(new(2030, 1, 1)), "namedDateTimeOffset");
}
```
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L1075-L1086' title='Snippet source file'>snippet source</a> | <a href='#snippet-addnameddatesandtimes' title='Start of snippet'>anchor</a></sup>
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L1087-L1098' title='Snippet source file'>snippet source</a> | <a href='#snippet-addnameddatesandtimes' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->
@ -571,7 +571,7 @@ public Task ScopedSerializerFluent()
.AddExtraSettings(_ => _.TypeNameHandling = TypeNameHandling.All);
}
```
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L3301-L3328' 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#L3313-L3340' title='Snippet source file'>snippet source</a> | <a href='#snippet-scopedserializer' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->
Result:
@ -699,7 +699,7 @@ public Task IgnoreTypeFluent()
.IgnoreMembersWithType<ToIgnoreStruct>();
}
```
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L2334-L2439' 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#L2346-L2451' title='Snippet source file'>snippet source</a> | <a href='#snippet-addignoretype' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->
Or globally:
@ -709,7 +709,7 @@ Or globally:
```cs
VerifierSettings.IgnoreMembersWithType<ToIgnore>();
```
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L2321-L2325' 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#L2333-L2337' title='Snippet source file'>snippet source</a> | <a href='#snippet-addignoretypeglobal' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->
Result:
@ -846,7 +846,7 @@ public Task ScrubTypeFluent()
.ScrubMembersWithType<ToIgnoreStruct>();
}
```
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L2442-L2547' title='Snippet source file'>snippet source</a> | <a href='#snippet-addscrubtype' title='Start of snippet'>anchor</a></sup>
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L2454-L2559' title='Snippet source file'>snippet source</a> | <a href='#snippet-addscrubtype' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->
Or globally:
@ -856,7 +856,7 @@ Or globally:
```cs
VerifierSettings.ScrubMembersWithType<ToIgnore>();
```
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L2327-L2331' title='Snippet source file'>snippet source</a> | <a href='#snippet-addscrubtypeglobal' title='Start of snippet'>anchor</a></sup>
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L2339-L2343' title='Snippet source file'>snippet source</a> | <a href='#snippet-addscrubtypeglobal' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->
Result:
@ -935,7 +935,7 @@ public Task AddIgnoreInstanceFluent()
.IgnoreInstance<Instance>(_ => _.Property == "Ignore");
}
```
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L2207-L2246' 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#L2219-L2258' title='Snippet source file'>snippet source</a> | <a href='#snippet-addignoreinstance' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->
Or globally:
@ -945,7 +945,7 @@ Or globally:
```cs
VerifierSettings.IgnoreInstance<Instance>(_ => _.Property == "Ignore");
```
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L2194-L2198' 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#L2206-L2210' title='Snippet source file'>snippet source</a> | <a href='#snippet-addignoreinstanceglobal' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->
Result:
@ -1007,7 +1007,7 @@ public Task AddScrubInstanceFluent()
.ScrubInstance<Instance>(_ => _.Property == "Ignore");
}
```
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L2248-L2287' title='Snippet source file'>snippet source</a> | <a href='#snippet-addscrubinstance' title='Start of snippet'>anchor</a></sup>
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L2260-L2299' title='Snippet source file'>snippet source</a> | <a href='#snippet-addscrubinstance' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->
Or globally:
@ -1017,7 +1017,7 @@ Or globally:
```cs
VerifierSettings.ScrubInstance<Instance>(_ => _.Property == "Ignore");
```
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L2200-L2204' title='Snippet source file'>snippet source</a> | <a href='#snippet-addscrubinstanceglobal' title='Start of snippet'>anchor</a></sup>
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L2212-L2216' title='Snippet source file'>snippet source</a> | <a href='#snippet-addscrubinstanceglobal' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->
Result:
@ -1062,7 +1062,7 @@ public Task WithObsoleteProp()
return Verify(target);
}
```
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L3266-L3287' 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#L3278-L3299' title='Snippet source file'>snippet source</a> | <a href='#snippet-withobsoleteprop' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->
Result:
@ -1110,7 +1110,7 @@ public Task WithObsoletePropIncludedFluent()
.IncludeObsoletes();
}
```
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L3237-L3264' 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#L3249-L3276' title='Snippet source file'>snippet source</a> | <a href='#snippet-withobsoletepropincluded' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->
Or globally:
@ -1120,7 +1120,7 @@ Or globally:
```cs
VerifierSettings.IncludeObsoletes();
```
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L3230-L3234' 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#L3242-L3246' title='Snippet source file'>snippet source</a> | <a href='#snippet-withobsoletepropincludedglobally' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->
Result:
@ -1181,7 +1181,7 @@ public Task IgnoreMemberByExpressionFluent()
_ => _.PropertyThatThrows);
}
```
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L2748-L2787' 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#L2760-L2799' title='Snippet source file'>snippet source</a> | <a href='#snippet-ignorememberbyexpression' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->
Or globally
@ -1196,7 +1196,7 @@ VerifierSettings.IgnoreMembers<IgnoreExplicitTarget>(
_ => _.GetOnlyProperty,
_ => _.PropertyThatThrows);
```
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L2725-L2734' 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#L2737-L2746' title='Snippet source file'>snippet source</a> | <a href='#snippet-ignorememberbyexpressionglobal' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->
Result:
@ -1256,7 +1256,7 @@ public Task ScrubMemberByExpressionFluent()
_ => _.PropertyThatThrows);
}
```
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L2789-L2828' title='Snippet source file'>snippet source</a> | <a href='#snippet-scrubmemberbyexpression' title='Start of snippet'>anchor</a></sup>
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L2801-L2840' title='Snippet source file'>snippet source</a> | <a href='#snippet-scrubmemberbyexpression' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->
Or globally
@ -1271,7 +1271,7 @@ VerifierSettings.ScrubMembers<IgnoreExplicitTarget>(
_ => _.GetOnlyProperty,
_ => _.PropertyThatThrows);
```
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L2736-L2745' title='Snippet source file'>snippet source</a> | <a href='#snippet-scrubmemberbyexpressionglobal' title='Start of snippet'>anchor</a></sup>
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L2748-L2757' title='Snippet source file'>snippet source</a> | <a href='#snippet-scrubmemberbyexpressionglobal' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->
Result:
@ -1350,7 +1350,7 @@ public Task IgnoreMemberByNameFluent()
.IgnoreMember<IgnoreExplicitTarget>(_ => _.PropertyThatThrows);
}
```
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L2902-L2955' 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#L2914-L2967' title='Snippet source file'>snippet source</a> | <a href='#snippet-ignorememberbyname' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->
Or globally:
@ -1370,7 +1370,7 @@ VerifierSettings.IgnoreMember<IgnoreExplicitTarget>("Field");
// For a specific type with expression
VerifierSettings.IgnoreMember<IgnoreExplicitTarget>(_ => _.PropertyThatThrows);
```
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L2869-L2883' 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#L2881-L2895' title='Snippet source file'>snippet source</a> | <a href='#snippet-ignorememberbynameglobal' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->
Result:
@ -1445,7 +1445,7 @@ public Task ScrubMemberByNameFluent()
.ScrubMember<IgnoreExplicitTarget>(_ => _.PropertyThatThrows);
}
```
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L2957-L3010' title='Snippet source file'>snippet source</a> | <a href='#snippet-scrubmemberbyname' title='Start of snippet'>anchor</a></sup>
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L2969-L3022' title='Snippet source file'>snippet source</a> | <a href='#snippet-scrubmemberbyname' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->
Or globally:
@ -1465,7 +1465,7 @@ VerifierSettings.ScrubMember<IgnoreExplicitTarget>("Field");
// For a specific type with expression
VerifierSettings.ScrubMember<IgnoreExplicitTarget>(_ => _.PropertyThatThrows);
```
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L2885-L2899' title='Snippet source file'>snippet source</a> | <a href='#snippet-scrubmemberbynameglobal' title='Start of snippet'>anchor</a></sup>
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L2897-L2911' title='Snippet source file'>snippet source</a> | <a href='#snippet-scrubmemberbynameglobal' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->
Result:
@ -1516,7 +1516,7 @@ public Task CustomExceptionPropFluent()
.IgnoreMembersThatThrow<CustomException>();
}
```
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L3118-L3137' 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#L3130-L3149' title='Snippet source file'>snippet source</a> | <a href='#snippet-ignoremembersthatthrow' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->
Or globally:
@ -1526,7 +1526,7 @@ Or globally:
```cs
VerifierSettings.IgnoreMembersThatThrow<CustomException>();
```
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L3111-L3115' 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#L3123-L3127' title='Snippet source file'>snippet source</a> | <a href='#snippet-ignoremembersthatthrowglobal' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->
Result:
@ -1563,7 +1563,7 @@ public Task ExceptionMessagePropFluent()
.IgnoreMembersThatThrow<Exception>(_ => _.Message == "Ignore");
}
```
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L1984-L2005' 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#L1996-L2017' title='Snippet source file'>snippet source</a> | <a href='#snippet-ignoremembersthatthrowexpression' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->
Or globally:
@ -1573,7 +1573,7 @@ Or globally:
```cs
VerifierSettings.IgnoreMembersThatThrow<Exception>(_ => _.Message == "Ignore");
```
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L1977-L1981' 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#L1989-L1993' title='Snippet source file'>snippet source</a> | <a href='#snippet-ignoremembersthatthrowexpressionglobal' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->
Result:
@ -1697,7 +1697,7 @@ public Task MemberConverterByExpression()
return Verify(input);
}
```
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L2830-L2858' 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#L2842-L2870' title='Snippet source file'>snippet source</a> | <a href='#snippet-memberconverter' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->
@ -1748,7 +1748,7 @@ public Task DontSortDictionaries()
.DontSortDictionaries();
}
```
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L228-L250' title='Snippet source file'>snippet source</a> | <a href='#snippet-dontsortdictionaries' title='Start of snippet'>anchor</a></sup>
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L240-L262' title='Snippet source file'>snippet source</a> | <a href='#snippet-dontsortdictionaries' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->

Просмотреть файл

@ -2,7 +2,7 @@
<Project>
<PropertyGroup>
<NoWarn>CS1591;CS0649;xUnit1026;xUnit1013;msb3277;CS0436;CS1573;NU1901;NU1902;NU1903</NoWarn>
<Version>22.1.0</Version>
<Version>22.1.1</Version>
<ImplicitUsings>enable</ImplicitUsings>
<LangVersion>preview</LangVersion>
<SuppressTfmSupportBuildWarnings>true</SuppressTfmSupportBuildWarnings>

Просмотреть файл

@ -0,0 +1,5 @@
[
"a",
"c",
"b"
]

Просмотреть файл

@ -0,0 +1,5 @@
[
a,
c,
b
]

Просмотреть файл

@ -89,9 +89,21 @@ public class SerializationTests
"b"
},
settings);
} [Fact]
public Task EnumerableOrderWithNull()
{
var settings = new VerifySettings();
settings.OrderEnumerableBy<string>(_ => null);
return Verify(
new List<string>
{
"a",
"c",
"b"
},
settings);
}
[Fact]
public Task OrderEnumerableByDescending()
{

Просмотреть файл

@ -2,10 +2,10 @@
{
Dictionary<Type, Func<IEnumerable, IEnumerable>> enumerableInterceptors = new();
public void OrderEnumerableBy<T>(Func<T, object> keySelector) =>
public void OrderEnumerableBy<T>(Func<T, object?> keySelector) =>
enumerableInterceptors[typeof(T)] = _ => _.Cast<T>().OrderBy(keySelector);
public void OrderEnumerableByDescending<T>(Func<T, object> keySelector) =>
public void OrderEnumerableByDescending<T>(Func<T, object?> keySelector) =>
enumerableInterceptors[typeof(T)] = _ => _.Cast<T>().OrderByDescending(keySelector);
internal bool TryGetEnumerableInterceptors(Type memberType, [NotNullWhen(true)] out Func<IEnumerable, IEnumerable>? order) =>

Просмотреть файл

@ -186,12 +186,13 @@ public static partial class VerifierSettings
serialization.ScrubInstance(shouldIgnore);
}
public static void OrderEnumerableBy<T>(Func<T, object> keySelector)
public static void OrderEnumerableBy<T>(Func<T, object?> keySelector)
{
InnerVerifier.ThrowIfVerifyHasBeenRun();
serialization.OrderEnumerableBy(keySelector);
}
public static void OrderEnumerableByDescending<T>(Func<T, object> keySelector)
public static void OrderEnumerableByDescending<T>(Func<T, object?> keySelector)
{
InnerVerifier.ThrowIfVerifyHasBeenRun();
serialization.OrderEnumerableByDescending(keySelector);

Просмотреть файл

@ -156,13 +156,13 @@ public partial class VerifySettings
serialization.ScrubInstance(shouldScrub);
}
public void OrderEnumerableBy<T>(Func<T, object> keySelector)
public void OrderEnumerableBy<T>(Func<T, object?> keySelector)
{
CloneSettings();
serialization.OrderEnumerableBy(keySelector);
}
public void OrderEnumerableByDescending<T>(Func<T, object> keySelector)
public void OrderEnumerableByDescending<T>(Func<T, object?> keySelector)
{
CloneSettings();
serialization.OrderEnumerableByDescending(keySelector);

Просмотреть файл

@ -24,14 +24,14 @@ public partial class SettingsTask
}
[Pure]
public SettingsTask OrderEnumerableBy<T>(Func<T, object> keySelector)
public SettingsTask OrderEnumerableBy<T>(Func<T, object?> keySelector)
{
CurrentSettings.OrderEnumerableBy(keySelector);
return this;
}
[Pure]
public SettingsTask OrderEnumerableByDescending<T>(Func<T, object> keySelector)
public SettingsTask OrderEnumerableByDescending<T>(Func<T, object?> keySelector)
{
CurrentSettings.OrderEnumerableByDescending(keySelector);
return this;