Skip to content

Commit

Permalink
missing date time key conversion
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonCropp committed Feb 2, 2023
1 parent c0a3c00 commit e887846
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
18 changes: 18 additions & 0 deletions src/Verify/Serialization/CustomContractResolver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,24 @@ string ResolveDictionaryKey(JsonDictionaryContract contract, string value)
{
var counter = Counter.Current;
var keyType = contract.DictionaryKeyType;
#if NET6_0_OR_GREATER

if (keyType == typeof(Date))
{
if (settings.TryParseConvertDate(counter, value, out var result))
{
return result;
}
}

if (keyType == typeof(Time))
{
if (settings.TryParseConvertTime(counter, value, out var result))
{
return result;
}
}
#endif
if (keyType == typeof(Guid))
{
if (settings.TryParseConvertGuid(counter, value, out var result))
Expand Down
4 changes: 2 additions & 2 deletions src/Verify/Serialization/Scrubbers/SharedScrubber_Dates.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ internal bool TryConvert(Counter counter, DateTime value, [NotNullWhen(true)] ou
}

#if NET6_0_OR_GREATER
bool TryParseConvertDate(Counter counter, string value, [NotNullWhen(true)] out string? result)
internal bool TryParseConvertDate(Counter counter, string value, [NotNullWhen(true)] out string? result)
{
if (scrubDateTimes)
{
Expand Down Expand Up @@ -63,7 +63,7 @@ static string Convert(Counter counter, Date date)
return counter.NextString(date);
}

bool TryParseConvertTime(Counter counter, string value, [NotNullWhen(true)] out string? result)
internal bool TryParseConvertTime(Counter counter, string value, [NotNullWhen(true)] out string? result)
{
if (scrubDateTimes)
{
Expand Down

0 comments on commit e887846

Please sign in to comment.