Please notice that the object is defined in proto file, not in a common cs file. It has different behavior.
I'm using c#. Part of my proto file is:
message CodeDependency {
string path = 1;
DependencyType type = 2;
enum DependencyType {
NONE = 0;
TAR = 1;
ZIP = 2;
TAR_GZ = 3;
DIRECTORY = 4;
}
}
And I have a json string:
{"codeDependency": {
"path": "/CAP_TEST/job_manager/modules/1c8185d5-2add-4bd4-a332-8b21a6819608/tmpr9z7xinh.tar.gz",
"type": "TAR_GZ"
}}
I've tried three ways to deserialize it:
Newtonsoft.Json.JsonConvert.DeserializeObject<CodeDependency>
CodeDependency.Parser.ParseFrom
ProtoBuf.Serializer.Deserialize<CodeDependency>
None of them works. From the error message, it seems that 'TAR_GZ' can't be deserialized.
Error converting value "TAR_GZ" to type 'Microsoft.ABC.GRPC.Modules.Module+Types+CodeDependency+Types+DependencyType'. Path 'graph.nodes[4].module.codeDependency.type', line 273, position 21. ---> System.ArgumentException: Requested value 'TAR_GZ' was not found
If I change 'TAR_GZ' to 'TAR', it's ok. So maybe the problem is related to the underline in 'TAR_GZ'? Is there any way to solve it in C#? (It's ok in python.) Thanks for your help!