c# - Protobuf.NET using -


need send data between managed c# , unmanaged c++. after research tried use protobuf.net.

i'm not sure if understand functionality of protobuf...

  1. build type definition in proto. need type definition in both projects c++ , c#
  2. use command-line tool "protogen.exe" .cs file , .cpp, .h type definition
  3. copy .cs files c# project , .cpp, .h in c++ solution.

seems i'm stupid to solve this. here problem , questions.

  1. is possible define type in c# generate files in c++ ?
  2. tried use command-line tool protogen.exe following files

test1.proto

using protobuf; namespace protocolbuffers {     [protocontract]     class person     {         [protomember(1)]         public int id {get;set;}         [protomember(2)]         public string name { get; set; }     } } 

test2.proto

message person {   required int32 id = 1;   required string name = 2;   optional string email = 3; } 

nothing working me. tried everything. put proto files commandline dir, tried every option set dir. how build them ? second file working standard proto commandline tool c++ need c# too. need help.

firstly, note protobuf-net one available implementation .net; anyway...

"test1.proto" not .proto - c#; .proto not required use protobuf-net, in interop scenario idea. there vs2010 plugin this, or alternatively protogen tool in protobuf-net zip:

 protogen -i:test2.proto -o:test2.cs 

this should generate test2.cs contents:

//------------------------------------------------------------------------------ // <auto-generated> //     code generated tool. // //     changes file may cause incorrect behavior , lost if //     code regenerated. // </auto-generated> //------------------------------------------------------------------------------  // generated from: test2.proto namespace test2 {   [global::system.serializable, global::protobuf.protocontract(name=@"person")]   public partial class person : global::protobuf.iextensible   {     public person() {}      private int _id;     [global::protobuf.protomember(1, isrequired = true, name=@"id", dataformat = global::protobuf.dataformat.twoscomplement)]     public int id     {       { return _id; }       set { _id = value; }     }     private string _name;     [global::protobuf.protomember(2, isrequired = true, name=@"name", dataformat = global::protobuf.dataformat.default)]     public string name     {       { return _name; }       set { _name = value; }     }      private string _email = "";     [global::protobuf.protomember(3, isrequired = false, name=@"email", dataformat = global::protobuf.dataformat.default)]     [global::system.componentmodel.defaultvalue("")]     public string email     {       { return _email; }       set { _email = value; }     }     private global::protobuf.iextension extensionobject;     global::protobuf.iextension global::protobuf.iextensible.getextensionobject(bool createifmissing)       { return global::protobuf.extensible.getextensionobject(ref extensionobject, createifmissing); }   }  } 

note there additional switches if want, example, attempt case normalization (so id, name, email, etc), or want include additional serializer support (binaryformatter, datacontractserializer, etc)


Comments

Popular posts from this blog

linux - Using a Cron Job to check if my mod_wsgi / apache server is running and restart -

actionscript 3 - TweenLite does not work with object -

jQuery Ajax Render Fragments OR Whole Page -