Skip to content

Trying to use the message formatter throws "Unable to format value of type Microsoft.FSharp.Core.FSharpValueOption`1" for optional types #19

@marner2

Description

@marner2

This happens when trying to use the JsonFormatter for types with any optional fields.

Simple proto file:

message TestMessage {
  optional string TestField = 1;
}

Simple test:

let x = { TestMessage.empty() with TestField = ValueSome "hello" }
let string = Google.Protobuf.JsonFormatter.Default.Format(x)

Result:

  Message: 
System.ArgumentException : Unable to format value of type Microsoft.FSharp.Core.FSharpValueOption`1[System.String]

  Stack Trace: 
JsonFormatter.WriteValue(TextWriter writer, Object value)
JsonFormatter.WriteMessageFields(TextWriter writer, IMessage message, Boolean assumeFirstFieldWritten)
JsonFormatter.WriteMessage(TextWriter writer, IMessage message)
JsonFormatter.Format(IMessage message, TextWriter writer)
JsonFormatter.Format(IMessage message)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions