Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I control the visibility of the generated class with Protobuf-net?

I'm using protobuf-net (thanks Marc :) ) to serialize my object model, but I want the object model not to be visible outside my assembly (specifically, I want it to be internal).

By default protobuf-net seems to generate public partial classes. Can I tell it to mark the class internal?

Here's a cut down version of my .proto file:

package MyProject.Core.Persistence;

option optimize_for = SPEED;

message DataObject {
  required string name = 1;
  required int32 id = 2;
}

Which generates the following class definition:

[global::System.Serializable,
   global::ProtoBuf.ProtoContract(Name=@"DataObject")]
public partial class DataObject : global::ProtoBuf.IExtensible
{
  public DataObject () {}

  ...
}
like image 996
Mark Pim Avatar asked Sep 10 '25 18:09

Mark Pim


1 Answers

Not at the moment; however you can edit csharp.xslt to suit your own needs.

This doesn't seem a common case, but it could be added as an option easily enough.

like image 63
Marc Gravell Avatar answered Sep 13 '25 06:09

Marc Gravell