diff options
Diffstat (limited to 'src/google')
-rw-r--r-- | src/google/protobuf/compiler/csharp/csharp_field_base.cc | 10 | ||||
-rw-r--r-- | src/google/protobuf/compiler/csharp/csharp_message.cc | 10 | ||||
-rw-r--r-- | src/google/protobuf/compiler/csharp/csharp_message.h | 2 |
3 files changed, 22 insertions, 0 deletions
diff --git a/src/google/protobuf/compiler/csharp/csharp_field_base.cc b/src/google/protobuf/compiler/csharp/csharp_field_base.cc index e2011b76..7dde6f44 100644 --- a/src/google/protobuf/compiler/csharp/csharp_field_base.cc +++ b/src/google/protobuf/compiler/csharp/csharp_field_base.cc @@ -126,6 +126,16 @@ void FieldGeneratorBase::AddDeprecatedFlag(io::Printer* printer) { { printer->Print("[global::System.ObsoleteAttribute]\n"); } + else + { + if (descriptor_->type() == FieldDescriptor::TYPE_MESSAGE) + { + if (descriptor_->message_type()->options().deprecated()) + { + printer->Print("[global::System.ObsoleteAttribute]\n"); + } + } + } } void FieldGeneratorBase::AddPublicMemberAttributes(io::Printer* printer) { diff --git a/src/google/protobuf/compiler/csharp/csharp_message.cc b/src/google/protobuf/compiler/csharp/csharp_message.cc index ed744854..78e076c8 100644 --- a/src/google/protobuf/compiler/csharp/csharp_message.cc +++ b/src/google/protobuf/compiler/csharp/csharp_message.cc @@ -98,12 +98,21 @@ const std::vector<const FieldDescriptor*>& MessageGenerator::fields_by_number() return fields_by_number_; } +void MessageGenerator::AddDeprecatedFlag(io::Printer* printer) { + if (descriptor_->options().deprecated()) + { + printer->Print("[global::System.ObsoleteAttribute]\n"); + } +} + void MessageGenerator::Generate(io::Printer* printer) { map<string, string> vars; vars["class_name"] = class_name(); vars["access_level"] = class_access_level(); WriteMessageDocComment(printer, descriptor_); + AddDeprecatedFlag(printer); + printer->Print( vars, "$access_level$ sealed partial class $class_name$ : pb::IMessage<$class_name$> {\n"); @@ -115,6 +124,7 @@ void MessageGenerator::Generate(io::Printer* printer) { "private static readonly pb::MessageParser<$class_name$> _parser = new pb::MessageParser<$class_name$>(() => new $class_name$());\n"); WriteGeneratedCodeAttributes(printer); + printer->Print( vars, "public static pb::MessageParser<$class_name$> Parser { get { return _parser; } }\n\n"); diff --git a/src/google/protobuf/compiler/csharp/csharp_message.h b/src/google/protobuf/compiler/csharp/csharp_message.h index f794d68d..e7f3b4d0 100644 --- a/src/google/protobuf/compiler/csharp/csharp_message.h +++ b/src/google/protobuf/compiler/csharp/csharp_message.h @@ -69,6 +69,8 @@ class MessageGenerator : public SourceGeneratorBase { bool HasNestedGeneratedTypes(); + void AddDeprecatedFlag(io::Printer* printer); + std::string class_name(); std::string full_class_name(); |