Commit 752d1a37 authored by csharptest's avatar csharptest Committed by rogerk

Added option generate_private_ctor to disable private ctor generation

parent 4a6ed749
......@@ -42,6 +42,9 @@ message CSharpFileOptions {
// Generate messages/builders with the [Serializable] attribute
optional bool add_serializable = 9 [default = false];
// Generates a private ctor for Message types
optional bool generate_private_ctor = 10 [default = true];
// The extension that should be appended to the umbrella_classname when creating files.
optional string file_extension = 221 [default = ".cs"];
......
......@@ -181,8 +181,11 @@ namespace Google.ProtocolBuffers.ProtoGen
Descriptor.Proto.ExtensionRangeCount > 0 ? "Extendable" : "Generated",
RuntimeSuffix);
writer.Indent();
if (Descriptor.File.CSharpOptions.GeneratePrivateCtor)
{
writer.WriteLine("private {0}() {{ }}", ClassName);
// Must call BuildPartial() to make sure all lists are made read-only
}
// Must call MakeReadOnly() to make sure all lists are made read-only
writer.WriteLine("private static readonly {0} defaultInstance = new {0}().MakeReadOnly();", ClassName);
if (OptimizeSpeed)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment