Skip to content

Generation fails when an Enum is inside of a oneof block #165

@kapocskristof

Description

@kapocskristof

The code Generation fails with an error when a message has a oneof block with an enum inside that.

Generation command falanx --inputfile .\bundle.proto --defaultnamespace Evening --outputfile bundle.fs --serializer binary

bundle.proto file

syntax = "proto3";

enum SomeEnum {
  A = 0;
  B = 1;
  C = 2;
  D = 3;
}

message SM {
  oneof result {
     string other_response = 1;
     SomeEnum some_enum = 2;
  }
}

Error message

Generating code for: .\bundle.proto
Failed to serialize property Some_enum: System.Int32. Error: System.ArgumentException: Type mismatch when building 'f': function argument type doesn't match. Expected 'Microsoft.FSharp.Core.FSharpOption`1[System.Int32]', but received type 'System.Int32'.
Parameter name: receivedType
   at Microsoft.FSharp.Quotations.PatternsModule.checkTypesSR[a](Type expectedType, Type receivedType, a name, String threeHoleSR)
   at Microsoft.FSharp.Quotations.PatternsModule.checkAppliedLambda(FSharpExpr f, FSharpExpr v)
   at Microsoft.FSharp.Quotations.PatternsModule.mkApplication(FSharpExpr v_0, FSharpExpr v_1)
   at Microsoft.FSharp.Collections.SeqModule.Fold[T,TState](FSharpFunc`2 folder, TState state, IEnumerable`1 source)
   at Falanx.Proto.Codec.Binary.Serialization.serializeProperty(FSharpExpr buffer, FSharpExpr this, PropertyDescriptor prop) in D:\a\1\s\src\Falanx.Proto.Core\BinaryCodec\Serialization.fs:line 79
USAGE: falanx [--help] --inputfile <string> [--defaultnamespace <string>] --outputfile <string> [--serializer <binary|json>]

OPTIONS:

    --inputfile <string>  specify a proto file to input.
    --defaultnamespace <string>
                          specify a default namespace to use for code generation.
    --outputfile <string> Specify the file name that the generated code will be written to.
    --serializer <binary|json>
                          serialization format. default binary
    --help                display this list of options.

Type mismatch when building 'f': function argument type doesn't match. Expected 'Microsoft.FSharp.Core.FSharpOption`1[System.Int32]', but received type 'System.Int32'.
Parameter name: receivedType

I've tried these cases to check what is going on and in these cases everything worked fine.

Without oneof

syntax = "proto3";

enum SomeEnum {
  A = 0;
  B = 1;
}

message SM {
   SomeEnum some_enum = 2;
}

Without enum

syntax = "proto3";

enum SomeEnum {
  A = 0;
  B = 1;
}

message SM {
  oneof result {
     string some_string = 1;
  }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions