Skip to content

DateOnly support #394

Description

@kant2002

I use Verify.Xunit + Argon.FSharp

I add AddFSharpConverters to serialize tuple.

VerifierSettings.AddExtraSettings(fun settings -> 
    //settings.Converters.Add(IsoDateConverter())
    settings.AddFSharpConverters()
    )

And (string * DateOnly * string) tuple. its serializes strings fine, but not DateOnly. I did try to add

type IsoDateConverter() = 
    inherit JsonConverter()
    override _.CanConvert(``type``: Type) =
        ``type`` = typeof<DateOnly>
    override _.ReadJson(reader: JsonReader, ``type``: Type, existingValue: obj, serializer: JsonSerializer) =
        let dateString = reader.Value :?> string
        DateOnly.ParseExact(dateString, "yyyy-MM-dd")
    override _.WriteJson(writer: JsonWriter, value: obj, settings: JsonSerializer) =
        writer.WriteValue(((value :?> DateOnly).ToString("yyyy-MM-dd")))

But seems to be it's not working and nothhing changed. It seems it would be good to add DateOnly suport for Argon probably.

I need probably some hints where should I add things.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions