Commit 706c5f69 authored by Jon Skeet's avatar Jon Skeet

Add option to remove CLSCompliance attribute

parent 290089ab
...@@ -35,6 +35,9 @@ message CSharpFileOptions { ...@@ -35,6 +35,9 @@ message CSharpFileOptions {
// Create subdirectories for namespaces, e.g. namespace "Foo.Bar" // Create subdirectories for namespaces, e.g. namespace "Foo.Bar"
// would generate files within [output directory]/Foo/Bar // would generate files within [output directory]/Foo/Bar
optional bool expand_namespace_directories = 7; optional bool expand_namespace_directories = 7;
// Generate attributes indicating non-CLS-compliance
optional bool cls_compliance = 8 [default = true];
} }
extend FileOptions { extend FileOptions {
......
...@@ -64,12 +64,13 @@ namespace Google.ProtocolBuffers.ProtoGen { ...@@ -64,12 +64,13 @@ namespace Google.ProtocolBuffers.ProtoGen {
public void Generate(TextGenerator writer) { public void Generate(TextGenerator writer) {
writer.WriteLine ("public const int {0} = {1};", GetFieldConstantName(Descriptor), Descriptor.FieldNumber); writer.WriteLine ("public const int {0} = {1};", GetFieldConstantName(Descriptor), Descriptor.FieldNumber);
if (Descriptor.IsRepeated) { if (Descriptor.IsRepeated) {
if (!Descriptor.IsCLSCompliant) { if (!Descriptor.IsCLSCompliant && Descriptor.File.CSharpOptions.ClsCompliance)
{
writer.WriteLine("[global::System.CLSCompliant(false)]"); writer.WriteLine("[global::System.CLSCompliant(false)]");
} }
writer.WriteLine("{0} static pb::GeneratedExtensionBase<scg::IList<{1}>> {2};", ClassAccessLevel, type, name); writer.WriteLine("{0} static pb::GeneratedExtensionBase<scg::IList<{1}>> {2};", ClassAccessLevel, type, name);
} else { } else {
if (!Descriptor.IsCLSCompliant) { if (!Descriptor.IsCLSCompliant && Descriptor.File.CSharpOptions.ClsCompliance) {
writer.WriteLine("[global::System.CLSCompliant(false)]"); writer.WriteLine("[global::System.CLSCompliant(false)]");
} }
writer.WriteLine("{0} static pb::GeneratedExtensionBase<{1}> {2};", ClassAccessLevel, type, name); writer.WriteLine("{0} static pb::GeneratedExtensionBase<{1}> {2};", ClassAccessLevel, type, name);
......
...@@ -132,7 +132,7 @@ namespace Google.ProtocolBuffers.ProtoGen { ...@@ -132,7 +132,7 @@ namespace Google.ProtocolBuffers.ProtoGen {
} }
protected void AddClsComplianceCheck(TextGenerator writer) { protected void AddClsComplianceCheck(TextGenerator writer) {
if (!Descriptor.IsCLSCompliant) { if (!Descriptor.IsCLSCompliant && Descriptor.File.CSharpOptions.ClsCompliance) {
writer.WriteLine("[global::System.CLSCompliant(false)]"); writer.WriteLine("[global::System.CLSCompliant(false)]");
} }
} }
......
...@@ -37,22 +37,23 @@ namespace Google.ProtocolBuffers.DescriptorProtos { ...@@ -37,22 +37,23 @@ namespace Google.ProtocolBuffers.DescriptorProtos {
byte[] descriptorData = global::System.Convert.FromBase64String( byte[] descriptorData = global::System.Convert.FromBase64String(
"CiRnb29nbGUvcHJvdG9idWYvY3NoYXJwX29wdGlvbnMucHJvdG8SD2dvb2ds" + "CiRnb29nbGUvcHJvdG9idWYvY3NoYXJwX29wdGlvbnMucHJvdG8SD2dvb2ds" +
"ZS5wcm90b2J1ZhogZ29vZ2xlL3Byb3RvYnVmL2Rlc2NyaXB0b3IucHJvdG8i" + "ZS5wcm90b2J1ZhogZ29vZ2xlL3Byb3RvYnVmL2Rlc2NyaXB0b3IucHJvdG8i" +
"zAEKEUNTaGFycEZpbGVPcHRpb25zEhEKCW5hbWVzcGFjZRgBIAEoCRIaChJ1" + "6gEKEUNTaGFycEZpbGVPcHRpb25zEhEKCW5hbWVzcGFjZRgBIAEoCRIaChJ1" +
"bWJyZWxsYV9jbGFzc25hbWUYAiABKAkSHAoOcHVibGljX2NsYXNzZXMYAyAB" + "bWJyZWxsYV9jbGFzc25hbWUYAiABKAkSHAoOcHVibGljX2NsYXNzZXMYAyAB" +
"KAg6BHRydWUSFgoObXVsdGlwbGVfZmlsZXMYBCABKAgSFAoMbmVzdF9jbGFz" + "KAg6BHRydWUSFgoObXVsdGlwbGVfZmlsZXMYBCABKAgSFAoMbmVzdF9jbGFz" +
"c2VzGAUgASgIEhYKDmNvZGVfY29udHJhY3RzGAYgASgIEiQKHGV4cGFuZF9u" + "c2VzGAUgASgIEhYKDmNvZGVfY29udHJhY3RzGAYgASgIEiQKHGV4cGFuZF9u" +
"YW1lc3BhY2VfZGlyZWN0b3JpZXMYByABKAgiKwoSQ1NoYXJwRmllbGRPcHRp" + "YW1lc3BhY2VfZGlyZWN0b3JpZXMYByABKAgSHAoOY2xzX2NvbXBsaWFuY2UY" +
"b25zEhUKDXByb3BlcnR5X25hbWUYASABKAk6XgoTY3NoYXJwX2ZpbGVfb3B0" + "CCABKAg6BHRydWUiKwoSQ1NoYXJwRmllbGRPcHRpb25zEhUKDXByb3BlcnR5" +
"aW9ucxIcLmdvb2dsZS5wcm90b2J1Zi5GaWxlT3B0aW9ucxjoByABKAsyIi5n" + "X25hbWUYASABKAk6XgoTY3NoYXJwX2ZpbGVfb3B0aW9ucxIcLmdvb2dsZS5w" +
"b29nbGUucHJvdG9idWYuQ1NoYXJwRmlsZU9wdGlvbnM6YQoUY3NoYXJwX2Zp" + "cm90b2J1Zi5GaWxlT3B0aW9ucxjoByABKAsyIi5nb29nbGUucHJvdG9idWYu" +
"ZWxkX29wdGlvbnMSHS5nb29nbGUucHJvdG9idWYuRmllbGRPcHRpb25zGOgH" + "Q1NoYXJwRmlsZU9wdGlvbnM6YQoUY3NoYXJwX2ZpZWxkX29wdGlvbnMSHS5n" +
"IAEoCzIjLmdvb2dsZS5wcm90b2J1Zi5DU2hhcnBGaWVsZE9wdGlvbnM="); "b29nbGUucHJvdG9idWYuRmllbGRPcHRpb25zGOgHIAEoCzIjLmdvb2dsZS5w" +
"cm90b2J1Zi5DU2hhcnBGaWVsZE9wdGlvbnM=");
pbd::FileDescriptor.InternalDescriptorAssigner assigner = delegate(pbd::FileDescriptor root) { pbd::FileDescriptor.InternalDescriptorAssigner assigner = delegate(pbd::FileDescriptor root) {
descriptor = root; descriptor = root;
internal__static_google_protobuf_CSharpFileOptions__Descriptor = Descriptor.MessageTypes[0]; internal__static_google_protobuf_CSharpFileOptions__Descriptor = Descriptor.MessageTypes[0];
internal__static_google_protobuf_CSharpFileOptions__FieldAccessorTable = internal__static_google_protobuf_CSharpFileOptions__FieldAccessorTable =
new pb::FieldAccess.FieldAccessorTable<global::Google.ProtocolBuffers.DescriptorProtos.CSharpFileOptions, global::Google.ProtocolBuffers.DescriptorProtos.CSharpFileOptions.Builder>(internal__static_google_protobuf_CSharpFileOptions__Descriptor, new pb::FieldAccess.FieldAccessorTable<global::Google.ProtocolBuffers.DescriptorProtos.CSharpFileOptions, global::Google.ProtocolBuffers.DescriptorProtos.CSharpFileOptions.Builder>(internal__static_google_protobuf_CSharpFileOptions__Descriptor,
new string[] { "Namespace", "UmbrellaClassname", "PublicClasses", "MultipleFiles", "NestClasses", "CodeContracts", "ExpandNamespaceDirectories", }); new string[] { "Namespace", "UmbrellaClassname", "PublicClasses", "MultipleFiles", "NestClasses", "CodeContracts", "ExpandNamespaceDirectories", "ClsCompliance", });
internal__static_google_protobuf_CSharpFieldOptions__Descriptor = Descriptor.MessageTypes[1]; internal__static_google_protobuf_CSharpFieldOptions__Descriptor = Descriptor.MessageTypes[1];
internal__static_google_protobuf_CSharpFieldOptions__FieldAccessorTable = internal__static_google_protobuf_CSharpFieldOptions__FieldAccessorTable =
new pb::FieldAccess.FieldAccessorTable<global::Google.ProtocolBuffers.DescriptorProtos.CSharpFieldOptions, global::Google.ProtocolBuffers.DescriptorProtos.CSharpFieldOptions.Builder>(internal__static_google_protobuf_CSharpFieldOptions__Descriptor, new pb::FieldAccess.FieldAccessorTable<global::Google.ProtocolBuffers.DescriptorProtos.CSharpFieldOptions, global::Google.ProtocolBuffers.DescriptorProtos.CSharpFieldOptions.Builder>(internal__static_google_protobuf_CSharpFieldOptions__Descriptor,
...@@ -162,6 +163,16 @@ namespace Google.ProtocolBuffers.DescriptorProtos { ...@@ -162,6 +163,16 @@ namespace Google.ProtocolBuffers.DescriptorProtos {
get { return expandNamespaceDirectories_; } get { return expandNamespaceDirectories_; }
} }
public const int ClsComplianceFieldNumber = 8;
private bool hasClsCompliance;
private bool clsCompliance_ = true;
public bool HasClsCompliance {
get { return hasClsCompliance; }
}
public bool ClsCompliance {
get { return clsCompliance_; }
}
public override bool IsInitialized { public override bool IsInitialized {
get { get {
return true; return true;
...@@ -191,6 +202,9 @@ namespace Google.ProtocolBuffers.DescriptorProtos { ...@@ -191,6 +202,9 @@ namespace Google.ProtocolBuffers.DescriptorProtos {
if (HasExpandNamespaceDirectories) { if (HasExpandNamespaceDirectories) {
output.WriteBool(7, ExpandNamespaceDirectories); output.WriteBool(7, ExpandNamespaceDirectories);
} }
if (HasClsCompliance) {
output.WriteBool(8, ClsCompliance);
}
UnknownFields.WriteTo(output); UnknownFields.WriteTo(output);
} }
...@@ -222,6 +236,9 @@ namespace Google.ProtocolBuffers.DescriptorProtos { ...@@ -222,6 +236,9 @@ namespace Google.ProtocolBuffers.DescriptorProtos {
if (HasExpandNamespaceDirectories) { if (HasExpandNamespaceDirectories) {
size += pb::CodedOutputStream.ComputeBoolSize(7, ExpandNamespaceDirectories); size += pb::CodedOutputStream.ComputeBoolSize(7, ExpandNamespaceDirectories);
} }
if (HasClsCompliance) {
size += pb::CodedOutputStream.ComputeBoolSize(8, ClsCompliance);
}
size += UnknownFields.SerializedSize; size += UnknownFields.SerializedSize;
memoizedSerializedSize = size; memoizedSerializedSize = size;
return size; return size;
...@@ -335,6 +352,9 @@ namespace Google.ProtocolBuffers.DescriptorProtos { ...@@ -335,6 +352,9 @@ namespace Google.ProtocolBuffers.DescriptorProtos {
if (other.HasExpandNamespaceDirectories) { if (other.HasExpandNamespaceDirectories) {
ExpandNamespaceDirectories = other.ExpandNamespaceDirectories; ExpandNamespaceDirectories = other.ExpandNamespaceDirectories;
} }
if (other.HasClsCompliance) {
ClsCompliance = other.ClsCompliance;
}
this.MergeUnknownFields(other.UnknownFields); this.MergeUnknownFields(other.UnknownFields);
return this; return this;
} }
...@@ -395,6 +415,10 @@ namespace Google.ProtocolBuffers.DescriptorProtos { ...@@ -395,6 +415,10 @@ namespace Google.ProtocolBuffers.DescriptorProtos {
ExpandNamespaceDirectories = input.ReadBool(); ExpandNamespaceDirectories = input.ReadBool();
break; break;
} }
case 64: {
ClsCompliance = input.ReadBool();
break;
}
} }
} }
} }
...@@ -527,6 +551,24 @@ namespace Google.ProtocolBuffers.DescriptorProtos { ...@@ -527,6 +551,24 @@ namespace Google.ProtocolBuffers.DescriptorProtos {
result.expandNamespaceDirectories_ = false; result.expandNamespaceDirectories_ = false;
return this; return this;
} }
public bool HasClsCompliance {
get { return result.HasClsCompliance; }
}
public bool ClsCompliance {
get { return result.ClsCompliance; }
set { SetClsCompliance(value); }
}
public Builder SetClsCompliance(bool value) {
result.hasClsCompliance = true;
result.clsCompliance_ = value;
return this;
}
public Builder ClearClsCompliance() {
result.hasClsCompliance = false;
result.clsCompliance_ = true;
return this;
}
} }
static CSharpFileOptions() { static CSharpFileOptions() {
object.ReferenceEquals(global::Google.ProtocolBuffers.DescriptorProtos.CSharpOptions.Descriptor, null); object.ReferenceEquals(global::Google.ProtocolBuffers.DescriptorProtos.CSharpOptions.Descriptor, null);
......
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