jet / jet/falanx

Generation fails when an Enum is inside of a oneof block

Open
#165 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
F#
Stars
144
Forks
24
PR merge metrics
No merged PRs in 30d

Description

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 [--defaultnamespace ] --outputfile [--serializer ]

OPTIONS:

--inputfile specify a proto file to input.
--defaultnamespace
specify a default namespace to use for code generation.
--outputfile Specify the file name that the generated code will be written to.
--serializer
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;
}
}
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.