Skip to content

Commit

Permalink
Update CustomContractResolver_Dictionary.cs
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonCropp committed Jan 21, 2025
1 parent 3733403 commit 5f63891
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions src/Verify/Serialization/CustomContractResolver_Dictionary.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,33 +77,33 @@ bool TryConvertDictionaryKey(JsonWriter writer, object original, [NotNullWhen(tr
}
}

if (original is string stringValue)
if (original is DateTime dateTime)
{
if (settings.TryParseConvert(counter, stringValue.AsSpan(), out result))
if (settings.TryConvert(counter, dateTime, out result))
{
return true;
}

var verifyJsonWriter = (VerifyJsonWriter)writer;
result = ApplyScrubbers.ApplyForPropertyValue(stringValue.AsSpan(), verifyJsonWriter.settings, counter).ToString();

return true;
}

if (original is DateTime dateTime)
if (original is DateTimeOffset dateTimeOffset)
{
if (settings.TryConvert(counter, dateTime, out result))
if (settings.TryConvert(counter, dateTimeOffset, out result))
{
return true;
}
}

if (original is DateTimeOffset dateTimeOffset)
if (original is string stringValue)
{
if (settings.TryConvert(counter, dateTimeOffset, out result))
if (settings.TryParseConvert(counter, stringValue.AsSpan(), out result))
{
return true;
}

var verifyJsonWriter = (VerifyJsonWriter)writer;
result = ApplyScrubbers.ApplyForPropertyValue(stringValue.AsSpan(), verifyJsonWriter.settings, counter).ToString();

return true;
}

if (original is Type type)
Expand Down

0 comments on commit 5f63891

Please sign in to comment.