Commit 6c021b3d authored by Andrew Spiering's avatar Andrew Spiering

Added the support for class level deprecation which will in turn also deprecate…

Added the support for class level deprecation which will in turn also deprecate any fields that are currently using that type
parent d948b66d
......@@ -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) {
......
......@@ -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");
......
......@@ -69,6 +69,8 @@ class MessageGenerator : public SourceGeneratorBase {
bool HasNestedGeneratedTypes();
void AddDeprecatedFlag(io::Printer* printer);
std::string class_name();
std::string full_class_name();
......
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