Re: [protobuf] Use protobuf-net in C++/CLI
Thanks a lot! Daniele. Il giorno lunedì 7 ottobre 2013 11:55:13 UTC+2, Marc Gravell ha scritto: > > > On 7 October 2013 10:45, Barzo > wrote: > >> In a meanwhile I have built the .cs generated file into a separate DLL >> assembly and I added it (linked) to my C++/CLI project. > > > Indeed, compiling it as C# and referencing/linking was what I meant - i.e. > using the C# *from* C++/CLI, rather than *in* C++/CLI > > If you wanted native C++/CLI output, you'd need to write a new > code-generator for C++/CLI and the desired library. Which isn't necessarily > too difficult (in the case of protobuf-net, you should be able to use > csharp.xslt as a starting point). > > Re the difference between protobuf-csharp-port vs protobuf-net: > > - protobuf-csharp-port tries to be idiomatic protobuf, supporting C# > - protobuf-net tries to be idiomatic C# (/.NET), supporting protobuf > > Or in other words: the API for protobuf-csharp-port is very similar to the > google implementations - and virtually identical to the protobuf java API - > builder pattern, etc. Conversely, protobuf-net aims first and foremost to > be a .NET serializer (mutable objects, primarily code-first (code-gen added > as a secondary tool), etc), but just happening to dealing with protobuf > data. > > Marc > -- You received this message because you are subscribed to the Google Groups "Protocol Buffers" group. To unsubscribe from this group and stop receiving emails from it, send an email to protobuf+unsubscr...@googlegroups.com. To post to this group, send email to protobuf@googlegroups.com. Visit this group at http://groups.google.com/group/protobuf. For more options, visit https://groups.google.com/groups/opt_out.
Re: [protobuf] Use protobuf-net in C++/CLI
On 7 October 2013 10:45, Barzo wrote: > In a meanwhile I have built the .cs generated file into a separate DLL > assembly and I added it (linked) to my C++/CLI project. Indeed, compiling it as C# and referencing/linking was what I meant - i.e. using the C# *from* C++/CLI, rather than *in* C++/CLI If you wanted native C++/CLI output, you'd need to write a new code-generator for C++/CLI and the desired library. Which isn't necessarily too difficult (in the case of protobuf-net, you should be able to use csharp.xslt as a starting point). Re the difference between protobuf-csharp-port vs protobuf-net: - protobuf-csharp-port tries to be idiomatic protobuf, supporting C# - protobuf-net tries to be idiomatic C# (/.NET), supporting protobuf Or in other words: the API for protobuf-csharp-port is very similar to the google implementations - and virtually identical to the protobuf java API - builder pattern, etc. Conversely, protobuf-net aims first and foremost to be a .NET serializer (mutable objects, primarily code-first (code-gen added as a secondary tool), etc), but just happening to dealing with protobuf data. Marc -- You received this message because you are subscribed to the Google Groups "Protocol Buffers" group. To unsubscribe from this group and stop receiving emails from it, send an email to protobuf+unsubscr...@googlegroups.com. To post to this group, send email to protobuf@googlegroups.com. Visit this group at http://groups.google.com/group/protobuf. For more options, visit https://groups.google.com/groups/opt_out.
Re: [protobuf] Use protobuf-net in C++/CLI
Hi Marc, thanks for your reply. To be more clear... In the native SDK I have a native Message class which encapsulate messages from the protoc generated file. Then, in the managed wrapper, I have a managed MessageNET class which has to encapsulate messages from protogen generated file. Of course the source .proto file is the same. However, to your question about using the generated C# files in a C++/CLI > project: yes, that will work > So I can compile it within the C++/CLI project? In a meanwhile I have built the .cs generated file into a separate DLL assembly and I added it (linked) to my C++/CLI project. > but you'll have to use a matching managed library - so if you use > protobuf-net generated types, you'll have to use protobuf-net to > serialize/deserialize. And likewise with protobuf-csharp-port generated > types and the protobuf-csharp-port library. > Yes, of course! Obviously this was understood :-) PS. I did't know protobuf-csharp-port...what are the differences between protobuf.net? Cheers, Daniele. -- You received this message because you are subscribed to the Google Groups "Protocol Buffers" group. To unsubscribe from this group and stop receiving emails from it, send an email to protobuf+unsubscr...@googlegroups.com. To post to this group, send email to protobuf@googlegroups.com. Visit this group at http://groups.google.com/group/protobuf. For more options, visit https://groups.google.com/groups/opt_out.
Re: [protobuf] Use protobuf-net in C++/CLI
I don't do much... no: *any* C++/CLI - but I guess the conflict here is that the c++ generated classes are not going to be CLI-friendly. So you need to either use a c++ library and c++ classes, or a managed library and managed classes. If your framework is unmanaged c++, then I *suspect* your best bet might be to accept managed types, and then map them manually to the unmanaged types, before feeding the unmanaged types to the unmanaged library. However, to your question about using the generated C# files in a C++/CLI project: yes, that will work - but you'll have to use a matching managed library - so if you use protobuf-net generated types, you'll have to use protobuf-net to serialize/deserialize. And likewise with protobuf-csharp-port generated types and the protobuf-csharp-port library. I'm not sure if I added anything there, but... Marc On 7 October 2013 09:17, Barzo wrote: > Hi, > > I have built a C++ framework which use protobuf library. > Now I'm writing a C++/CLI wrapper to make it visible in .NET world. > > Since I cannot made a wrapper for each message in my c++ .proto file, is > there a way to use the protobuf-net generated c# file in a C++/CLI project? > > Regards, > Daniele. > > -- > You received this message because you are subscribed to the Google Groups > "Protocol Buffers" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to protobuf+unsubscr...@googlegroups.com. > To post to this group, send email to protobuf@googlegroups.com. > Visit this group at http://groups.google.com/group/protobuf. > For more options, visit https://groups.google.com/groups/opt_out. > -- Regards, Marc -- You received this message because you are subscribed to the Google Groups "Protocol Buffers" group. To unsubscribe from this group and stop receiving emails from it, send an email to protobuf+unsubscr...@googlegroups.com. To post to this group, send email to protobuf@googlegroups.com. Visit this group at http://groups.google.com/group/protobuf. For more options, visit https://groups.google.com/groups/opt_out.