THRIFT-5408 Support for deprecated methods - follow_up fix
diff --git a/compiler/cpp/src/thrift/generate/t_netstd_generator.cc b/compiler/cpp/src/thrift/generate/t_netstd_generator.cc
index 975f33b..88f8da4 100644
--- a/compiler/cpp/src/thrift/generate/t_netstd_generator.cc
+++ b/compiler/cpp/src/thrift/generate/t_netstd_generator.cc
@@ -1926,16 +1926,7 @@
}
}
- auto iter = (*f_iter)->annotations_.find("deprecated");
- if( (*f_iter)->annotations_.end() != iter) {
- out << indent() << "[Obsolete";
- // empty annotation values end up with "1" somewhere, ignore these as well
- if ((iter->second.length() > 0) && (iter->second != "1")) {
- out << "(" << make_csharp_string_literal(iter->second) << ")";
- }
- out << "]" << endl;
- }
-
+ generate_deprecation_attribute(out, *f_iter);
out << indent() << function_signature_async(*f_iter) << ";" << endl << endl;
}
indent_down();
@@ -1943,6 +1934,19 @@
cleanup_member_name_mapping(tservice);
}
+void t_netstd_generator::generate_deprecation_attribute(ostream& out, t_function* func)
+{
+ auto iter = func->annotations_.find("deprecated");
+ if( func->annotations_.end() != iter) {
+ out << indent() << "[Obsolete";
+ // empty annotation values end up with "1" somewhere, ignore these as well
+ if ((iter->second.length() > 0) && (iter->second != "1")) {
+ out << "(" << make_csharp_string_literal(iter->second) << ")";
+ }
+ out << "]" << endl;
+ }
+}
+
void t_netstd_generator::generate_service_helpers(ostream& out, t_service* tservice)
{
vector<t_function*> functions = tservice->get_functions();
@@ -2006,6 +2010,7 @@
string function_name = raw_func_name + (add_async_postfix ? "Async" : "");
// async
+ generate_deprecation_attribute(out, *functions_iterator);
out << indent() << "public async " << function_signature_async(*functions_iterator, "") << endl
<< indent() << "{" << endl;
indent_up();
@@ -2023,6 +2028,7 @@
out << indent() << "}" << endl << endl;
// async send
+ generate_deprecation_attribute(out, *functions_iterator);
out << indent() << "public async " << function_signature_async(*functions_iterator, "send_", MODE_NO_RETURN) << endl
<< indent() << "{" << endl;
indent_up();
@@ -2063,6 +2069,7 @@
if (!(*functions_iterator)->is_oneway())
{
// async recv
+ generate_deprecation_attribute(out, *functions_iterator);
out << indent() << "public async " << function_signature_async(*functions_iterator, "recv_", MODE_NO_ARGS) << endl
<< indent() << "{" << endl;
indent_up();
diff --git a/compiler/cpp/src/thrift/generate/t_netstd_generator.h b/compiler/cpp/src/thrift/generate/t_netstd_generator.h
index 0b65a78..47a7042 100644
--- a/compiler/cpp/src/thrift/generate/t_netstd_generator.h
+++ b/compiler/cpp/src/thrift/generate/t_netstd_generator.h
@@ -105,6 +105,7 @@
void generate_netstd_union_reader(ostream& out, t_struct* tunion);
void generate_function_helpers(ostream& out, t_function* tfunction);
void generate_service_interface(ostream& out, t_service* tservice);
+ void generate_deprecation_attribute(ostream& out, t_function* func);
void generate_service_helpers(ostream& out, t_service* tservice);
void generate_service_client(ostream& out, t_service* tservice);
void generate_service_server(ostream& out, t_service* tservice);