From d9e3063eb054503a98f8ef74fe0484c0f12210ea Mon Sep 17 00:00:00 2001 From: Jie Luo Date: Fri, 1 May 2015 11:20:50 -0700 Subject: Remove ClsCompliant declarations from C# code --- src/google/protobuf/compiler/csharp/csharp_extension.cc | 8 -------- src/google/protobuf/compiler/csharp/csharp_field_base.cc | 13 ------------- src/google/protobuf/compiler/csharp/csharp_field_base.h | 2 -- src/google/protobuf/compiler/csharp/csharp_generator.cc | 5 +---- src/google/protobuf/compiler/csharp/csharp_message.cc | 5 ----- .../compiler/csharp/csharp_source_generator_base.cc | 5 ----- .../protobuf/compiler/csharp/csharp_source_generator_base.h | 1 - 7 files changed, 1 insertion(+), 38 deletions(-) diff --git a/src/google/protobuf/compiler/csharp/csharp_extension.cc b/src/google/protobuf/compiler/csharp/csharp_extension.cc index 5d38f52e..2bac320d 100644 --- a/src/google/protobuf/compiler/csharp/csharp_extension.cc +++ b/src/google/protobuf/compiler/csharp/csharp_extension.cc @@ -63,11 +63,6 @@ ExtensionGenerator::~ExtensionGenerator() { } void ExtensionGenerator::Generate(Writer* writer) { - if (cls_compliance() - && (GetFieldConstantName(descriptor_).substr(0, 1) == "_")) { - writer->WriteLine("[global::System.CLSCompliant(false)]"); - } - writer->WriteLine("public const int $0$ = $1$;", GetFieldConstantName(descriptor_), SimpleItoa(descriptor_->number())); @@ -80,7 +75,6 @@ void ExtensionGenerator::Generate(Writer* writer) { // "option message_set_wire_format = true; is not supported in Lite runtime extensions."); //} - AddClsComplianceCheck(writer); writer->Write("$0$ ", class_access_level()); writer->WriteLine( "static pb::$3$<$0$, $1$> $2$;", @@ -90,12 +84,10 @@ void ExtensionGenerator::Generate(Writer* writer) { descriptor_->is_repeated() ? "GeneratedRepeatExtensionLite" : "GeneratedExtensionLite"); } else if (descriptor_->is_repeated()) { - AddClsComplianceCheck(writer); writer->WriteLine( "$0$ static pb::GeneratedExtensionBase> $2$;", class_access_level(), type_name(), property_name()); } else { - AddClsComplianceCheck(writer); writer->WriteLine("$0$ static pb::GeneratedExtensionBase<$1$> $2$;", class_access_level(), type_name(), property_name()); } diff --git a/src/google/protobuf/compiler/csharp/csharp_field_base.cc b/src/google/protobuf/compiler/csharp/csharp_field_base.cc index ed4d55c4..145b6743 100644 --- a/src/google/protobuf/compiler/csharp/csharp_field_base.cc +++ b/src/google/protobuf/compiler/csharp/csharp_field_base.cc @@ -79,13 +79,6 @@ void FieldGeneratorBase::AddNullCheck(Writer* writer, const std::string& name) { void FieldGeneratorBase::AddPublicMemberAttributes(Writer* writer) { AddDeprecatedFlag(writer); - AddClsComplianceCheck(writer); -} - -void FieldGeneratorBase::AddClsComplianceCheck(Writer* writer) { - if (cls_compliance() && !is_cls_compliant()) { - writer->WriteLine("[global::System.CLSCompliant(false)]"); - } } std::string FieldGeneratorBase::property_name() { @@ -211,12 +204,6 @@ bool FieldGeneratorBase::is_nullable_type() { } } -bool FieldGeneratorBase::is_cls_compliant() { - CSharpType type = GetCSharpType(descriptor_->type()); - return (type != CSHARPTYPE_UINT32) && (type != CSHARPTYPE_UINT64) - && (UnderscoresToPascalCase(name()).substr(0, 1) != "_"); -} - inline bool IsNaN(double value) { // NaN is never equal to anything, even itself. return value != value; diff --git a/src/google/protobuf/compiler/csharp/csharp_field_base.h b/src/google/protobuf/compiler/csharp/csharp_field_base.h index 4f3a7658..311f7a6e 100644 --- a/src/google/protobuf/compiler/csharp/csharp_field_base.h +++ b/src/google/protobuf/compiler/csharp/csharp_field_base.h @@ -70,14 +70,12 @@ class FieldGeneratorBase : public SourceGeneratorBase { void AddNullCheck(Writer* writer, const std::string& name); void AddPublicMemberAttributes(Writer* writer); - void AddClsComplianceCheck(Writer* writer); std::string property_name(); std::string name(); std::string type_name(); bool has_default_value(); bool is_nullable_type(); - bool is_cls_compliant(); std::string default_value(); std::string number(); std::string message_or_group(); diff --git a/src/google/protobuf/compiler/csharp/csharp_generator.cc b/src/google/protobuf/compiler/csharp/csharp_generator.cc index 61ed37ad..64c4bd7d 100644 --- a/src/google/protobuf/compiler/csharp/csharp_generator.cc +++ b/src/google/protobuf/compiler/csharp/csharp_generator.cc @@ -71,10 +71,7 @@ bool Generator::Generate( std::string file_extension = ".cs"; for (int i = 0; i < options.size(); i++) { - if (options[i].first == "no_cls_compliance") { - *error = "Turning off CLS compliance is not implemented yet."; - return false; - } else if (options[i].first == "file_extension") { + if (options[i].first == "file_extension") { file_extension = options[i].second; } else { *error = "Unknown generator option: " + options[i].first; diff --git a/src/google/protobuf/compiler/csharp/csharp_message.cc b/src/google/protobuf/compiler/csharp/csharp_message.cc index 36f41c70..96f7c17c 100644 --- a/src/google/protobuf/compiler/csharp/csharp_message.cc +++ b/src/google/protobuf/compiler/csharp/csharp_message.cc @@ -262,11 +262,6 @@ void MessageGenerator::Generate(Writer* writer) { for (int i = 0; i < descriptor_->field_count(); i++) { const FieldDescriptor* fieldDescriptor = descriptor_->field(i); - // TODO(jtattermusch): same code for cls compliance is in csharp_extension - if (cls_compliance() - && GetFieldConstantName(fieldDescriptor)[0] == '_') { - writer->WriteLine("[global::System.CLSCompliant(false)]"); - } // Rats: we lose the debug comment here :( writer->WriteLine("public const int $0$ = $1$;", diff --git a/src/google/protobuf/compiler/csharp/csharp_source_generator_base.cc b/src/google/protobuf/compiler/csharp/csharp_source_generator_base.cc index e39911ee..8dfb41d4 100644 --- a/src/google/protobuf/compiler/csharp/csharp_source_generator_base.cc +++ b/src/google/protobuf/compiler/csharp/csharp_source_generator_base.cc @@ -69,11 +69,6 @@ std::string SourceGeneratorBase::class_access_level() { return "public"; // public_classes is always on. } -bool SourceGeneratorBase::cls_compliance() { - // TODO(jtattermusch): implement this based on "cls_compliance" cmdline param. - return true; -} - } // namespace csharp } // namespace compiler } // namespace protobuf diff --git a/src/google/protobuf/compiler/csharp/csharp_source_generator_base.h b/src/google/protobuf/compiler/csharp/csharp_source_generator_base.h index dbc65d04..1955394e 100644 --- a/src/google/protobuf/compiler/csharp/csharp_source_generator_base.h +++ b/src/google/protobuf/compiler/csharp/csharp_source_generator_base.h @@ -48,7 +48,6 @@ class SourceGeneratorBase { virtual ~SourceGeneratorBase(); std::string class_access_level(); - bool cls_compliance(); bool optimize_size() { return optimizeSize_; -- cgit v1.2.3