Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
kapocskristof opened this issue Nov 25, 2019 · 1 comment
Open

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

kapocskristof opened this issue Nov 25, 2019 · 1 comment

Comments

@kapocskristof
Copy link

kapocskristof commented Nov 25, 2019

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;
  }
}
@gusty
Copy link
Contributor

gusty commented May 24, 2020

Could this be yet another duplicate of #131 ?

If so there's a new Fleece version that support enums.

deviousasti pushed a commit that referenced this issue Oct 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants