Skip to content

Problem with reflection for methods with many enums #323

Open
@GoNextGroup

Description

@GoNextGroup

Hello, Marc.

I try to use reflection in my project, but got problem with enums.

I have service with request record:


    [ProtoContract]
    public record GenerateTokenRequest
    {
        [ProtoMember(1)]
        public Guid UserId { get; init; }
        [ProtoMember(2)]
        public Roles Role { get; init; }
        [ProtoMember(3)]
        public ClientTypes ClientType { get; init; }
        [ProtoMember(4)]
        public TokenType TokenType { get; init; }
    }

The proto file was generated:

syntax = "proto3";
package SharedInterfaces.TokenService.SecurityInterfaces.Token;
import "protobuf-net/bcl.proto"; // schema for protobuf-net's handling of core .NET types

enum ClientTypes {
   ZERO = 0; // proto3 requires a zero value as the first item (it can be named anything)
   Dealer = 1;
   Executor = 2;
}
message GenerateTokenRequest {
   .bcl.Guid UserId = 1; // default value could not be applied: 00000000-0000-0000-0000-000000000000
   Roles Role = 2;
   ClientTypes ClientType = 3;
   TokenType TokenType = 4;
}
enum Roles {
   User = 0;
   Worker = 1;
   Setter = 2;
   Customer = 3;
   ManagerOP = 4;
   Manager = 5;
   Employee = 998;
   LegalEntity = 999;
}
enum TokenType {
   ZERO = 0; // proto3 requires a zero value as the first item (it can be named anything)
   Temporary = 1;
   Persistent = 2;
}
message UserToken {
   string AuthenticationType = 1;
   string Token = 2;
   .bcl.DateTime Expiration = 3;
   int64 ExpirationUnixTime = 4;
   ClientTypes ClientType = 5;
   Roles Role = 6;
}
service TokenGeneration {
   rpc Generate (GenerateTokenRequest) returns (UserToken);
}

So, when I try to use command docker run fullstorydev/grpcurl -plaintext -use-reflection 172.23.17.107:50029 describe SharedInterfaces.TokenService.SecurityInterfaces.Token.TokenGeneration

I got a message
Failed to resolve symbol "SharedInterfaces.TokenService.SecurityInterfaces.Token.TokenGeneration": proto: descriptor "SharedInterfaces.TokenService.SecurityInterfaces.Token.ZERO" already declared

I've tried to find solution in the internet/SO/tg chats, but without any success. Could you help me to fix this problem? Or is there no way just only change enum elements order starting not from 1, but from 0?

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