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

Due to protobuf-net RuntimeTypeModel class, the complex datatype such as Dictionary<string,string[]> are not getting converted to corresponding proto schema #351

Open
atulDc opened this issue Nov 25, 2024 · 0 comments

Comments

@atulDc
Copy link

atulDc commented Nov 25, 2024

The protobuf-net RuntimeTypeModel class has a function TryGetRepeatedProvider which checks if a C# data type is a proto's "repeated" type and its c# System.Reflection.MemeberInfo type is present (e.g. string[] or List or Dictionary<T,K>) then do not create its proto schema.

Below Example:

c# Dictionary<string,string[]> is not getting converted to proto schema :

// below Array_String message is not getting generated.
message Array_String {
repeated string item = 1;
}

// KeyValuePair_String_Array_String message is getting generated
message KeyValuePair_String_Array_String {
string Key = 1;
Array_String Value = 2; // getting generated too
}

the message Array_String is not getting generated because c# string[] System.Reflection.Memberinfo type is available to RuntimeTypeModel class of protobuf-net library.

When c# System.Reflection.Memberinfo type is available why its message is not generated in proto?

If those are not generated then the above-mentioned complex types are not working, what could be a workaround?

If we try to bypass the below mentioned check in RuntimeTypeModel class's GetSchema function what could go wrong ?

Bypassing this instruction :

TryGetRepeatedProvider(tmp.Type) is not null) continue;

The bottom line is:
Dictionary<string,string[]> or Dictionary<string,Dictionary<string,string>> these c# types should be parsed and their proto schema should be generated.

@atulDc atulDc changed the title Due to protobuf-net RuntimeTypeModel class, the complex datatype such as Dictionary<string,string[]> are not getting converted to proto schema Due to protobuf-net RuntimeTypeModel class, the complex datatype such as Dictionary<string,string[]> are not getting converted to corresponding proto schema Nov 25, 2024
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

1 participant