diff --git a/src/Verify/Serialization/CustomContractResolver_Dictionary.cs b/src/Verify/Serialization/CustomContractResolver_Dictionary.cs index 39bd343a4..36abd88d7 100644 --- a/src/Verify/Serialization/CustomContractResolver_Dictionary.cs +++ b/src/Verify/Serialization/CustomContractResolver_Dictionary.cs @@ -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)