Add option to remove CLSCompliance attribute
This commit is contained in:
parent
290089ab7c
commit
706c5f6985
4 changed files with 57 additions and 11 deletions
|
@ -35,6 +35,9 @@ message CSharpFileOptions {
|
|||
// Create subdirectories for namespaces, e.g. namespace "Foo.Bar"
|
||||
// would generate files within [output directory]/Foo/Bar
|
||||
optional bool expand_namespace_directories = 7;
|
||||
|
||||
// Generate attributes indicating non-CLS-compliance
|
||||
optional bool cls_compliance = 8 [default = true];
|
||||
}
|
||||
|
||||
extend FileOptions {
|
||||
|
|
|
@ -64,12 +64,13 @@ namespace Google.ProtocolBuffers.ProtoGen {
|
|||
public void Generate(TextGenerator writer) {
|
||||
writer.WriteLine ("public const int {0} = {1};", GetFieldConstantName(Descriptor), Descriptor.FieldNumber);
|
||||
if (Descriptor.IsRepeated) {
|
||||
if (!Descriptor.IsCLSCompliant) {
|
||||
if (!Descriptor.IsCLSCompliant && Descriptor.File.CSharpOptions.ClsCompliance)
|
||||
{
|
||||
writer.WriteLine("[global::System.CLSCompliant(false)]");
|
||||
}
|
||||
writer.WriteLine("{0} static pb::GeneratedExtensionBase<scg::IList<{1}>> {2};", ClassAccessLevel, type, name);
|
||||
} else {
|
||||
if (!Descriptor.IsCLSCompliant) {
|
||||
if (!Descriptor.IsCLSCompliant && Descriptor.File.CSharpOptions.ClsCompliance) {
|
||||
writer.WriteLine("[global::System.CLSCompliant(false)]");
|
||||
}
|
||||
writer.WriteLine("{0} static pb::GeneratedExtensionBase<{1}> {2};", ClassAccessLevel, type, name);
|
||||
|
|
|
@ -132,7 +132,7 @@ namespace Google.ProtocolBuffers.ProtoGen {
|
|||
}
|
||||
|
||||
protected void AddClsComplianceCheck(TextGenerator writer) {
|
||||
if (!Descriptor.IsCLSCompliant) {
|
||||
if (!Descriptor.IsCLSCompliant && Descriptor.File.CSharpOptions.ClsCompliance) {
|
||||
writer.WriteLine("[global::System.CLSCompliant(false)]");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -37,22 +37,23 @@ namespace Google.ProtocolBuffers.DescriptorProtos {
|
|||
byte[] descriptorData = global::System.Convert.FromBase64String(
|
||||
"CiRnb29nbGUvcHJvdG9idWYvY3NoYXJwX29wdGlvbnMucHJvdG8SD2dvb2ds" +
|
||||
"ZS5wcm90b2J1ZhogZ29vZ2xlL3Byb3RvYnVmL2Rlc2NyaXB0b3IucHJvdG8i" +
|
||||
"zAEKEUNTaGFycEZpbGVPcHRpb25zEhEKCW5hbWVzcGFjZRgBIAEoCRIaChJ1" +
|
||||
"6gEKEUNTaGFycEZpbGVPcHRpb25zEhEKCW5hbWVzcGFjZRgBIAEoCRIaChJ1" +
|
||||
"bWJyZWxsYV9jbGFzc25hbWUYAiABKAkSHAoOcHVibGljX2NsYXNzZXMYAyAB" +
|
||||
"KAg6BHRydWUSFgoObXVsdGlwbGVfZmlsZXMYBCABKAgSFAoMbmVzdF9jbGFz" +
|
||||
"c2VzGAUgASgIEhYKDmNvZGVfY29udHJhY3RzGAYgASgIEiQKHGV4cGFuZF9u" +
|
||||
"YW1lc3BhY2VfZGlyZWN0b3JpZXMYByABKAgiKwoSQ1NoYXJwRmllbGRPcHRp" +
|
||||
"b25zEhUKDXByb3BlcnR5X25hbWUYASABKAk6XgoTY3NoYXJwX2ZpbGVfb3B0" +
|
||||
"aW9ucxIcLmdvb2dsZS5wcm90b2J1Zi5GaWxlT3B0aW9ucxjoByABKAsyIi5n" +
|
||||
"b29nbGUucHJvdG9idWYuQ1NoYXJwRmlsZU9wdGlvbnM6YQoUY3NoYXJwX2Zp" +
|
||||
"ZWxkX29wdGlvbnMSHS5nb29nbGUucHJvdG9idWYuRmllbGRPcHRpb25zGOgH" +
|
||||
"IAEoCzIjLmdvb2dsZS5wcm90b2J1Zi5DU2hhcnBGaWVsZE9wdGlvbnM=");
|
||||
"YW1lc3BhY2VfZGlyZWN0b3JpZXMYByABKAgSHAoOY2xzX2NvbXBsaWFuY2UY" +
|
||||
"CCABKAg6BHRydWUiKwoSQ1NoYXJwRmllbGRPcHRpb25zEhUKDXByb3BlcnR5" +
|
||||
"X25hbWUYASABKAk6XgoTY3NoYXJwX2ZpbGVfb3B0aW9ucxIcLmdvb2dsZS5w" +
|
||||
"cm90b2J1Zi5GaWxlT3B0aW9ucxjoByABKAsyIi5nb29nbGUucHJvdG9idWYu" +
|
||||
"Q1NoYXJwRmlsZU9wdGlvbnM6YQoUY3NoYXJwX2ZpZWxkX29wdGlvbnMSHS5n" +
|
||||
"b29nbGUucHJvdG9idWYuRmllbGRPcHRpb25zGOgHIAEoCzIjLmdvb2dsZS5w" +
|
||||
"cm90b2J1Zi5DU2hhcnBGaWVsZE9wdGlvbnM=");
|
||||
pbd::FileDescriptor.InternalDescriptorAssigner assigner = delegate(pbd::FileDescriptor root) {
|
||||
descriptor = root;
|
||||
internal__static_google_protobuf_CSharpFileOptions__Descriptor = Descriptor.MessageTypes[0];
|
||||
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 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__FieldAccessorTable =
|
||||
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 {
|
|||
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 {
|
||||
get {
|
||||
return true;
|
||||
|
@ -191,6 +202,9 @@ namespace Google.ProtocolBuffers.DescriptorProtos {
|
|||
if (HasExpandNamespaceDirectories) {
|
||||
output.WriteBool(7, ExpandNamespaceDirectories);
|
||||
}
|
||||
if (HasClsCompliance) {
|
||||
output.WriteBool(8, ClsCompliance);
|
||||
}
|
||||
UnknownFields.WriteTo(output);
|
||||
}
|
||||
|
||||
|
@ -222,6 +236,9 @@ namespace Google.ProtocolBuffers.DescriptorProtos {
|
|||
if (HasExpandNamespaceDirectories) {
|
||||
size += pb::CodedOutputStream.ComputeBoolSize(7, ExpandNamespaceDirectories);
|
||||
}
|
||||
if (HasClsCompliance) {
|
||||
size += pb::CodedOutputStream.ComputeBoolSize(8, ClsCompliance);
|
||||
}
|
||||
size += UnknownFields.SerializedSize;
|
||||
memoizedSerializedSize = size;
|
||||
return size;
|
||||
|
@ -335,6 +352,9 @@ namespace Google.ProtocolBuffers.DescriptorProtos {
|
|||
if (other.HasExpandNamespaceDirectories) {
|
||||
ExpandNamespaceDirectories = other.ExpandNamespaceDirectories;
|
||||
}
|
||||
if (other.HasClsCompliance) {
|
||||
ClsCompliance = other.ClsCompliance;
|
||||
}
|
||||
this.MergeUnknownFields(other.UnknownFields);
|
||||
return this;
|
||||
}
|
||||
|
@ -395,6 +415,10 @@ namespace Google.ProtocolBuffers.DescriptorProtos {
|
|||
ExpandNamespaceDirectories = input.ReadBool();
|
||||
break;
|
||||
}
|
||||
case 64: {
|
||||
ClsCompliance = input.ReadBool();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -527,6 +551,24 @@ namespace Google.ProtocolBuffers.DescriptorProtos {
|
|||
result.expandNamespaceDirectories_ = false;
|
||||
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() {
|
||||
object.ReferenceEquals(global::Google.ProtocolBuffers.DescriptorProtos.CSharpOptions.Descriptor, null);
|
||||
|
|
Loading…
Add table
Reference in a new issue