From 007b99b72adcc97a0715b92d5f495620bee35715 Mon Sep 17 00:00:00 2001 From: Jens Geyer Date: Wed, 27 Oct 2021 12:22:25 +0200 Subject: THRIFT-5408 Support for deprecated methods - follow_up fix --- .../cpp/src/thrift/generate/t_netstd_generator.cc | 27 ++++++++++++++-------- .../cpp/src/thrift/generate/t_netstd_generator.h | 1 + 2 files changed, 18 insertions(+), 10 deletions(-) (limited to 'compiler/cpp/src/thrift/generate') diff --git a/compiler/cpp/src/thrift/generate/t_netstd_generator.cc b/compiler/cpp/src/thrift/generate/t_netstd_generator.cc index 975f33b92..88f8da417 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 @@ void t_netstd_generator::generate_service_interface(ostream& out, t_service* tse } } - 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 @@ void t_netstd_generator::generate_service_interface(ostream& out, t_service* tse 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 functions = tservice->get_functions(); @@ -2006,6 +2010,7 @@ void t_netstd_generator::generate_service_client(ostream& out, t_service* tservi 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 @@ void t_netstd_generator::generate_service_client(ostream& out, t_service* tservi 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 @@ void t_netstd_generator::generate_service_client(ostream& out, t_service* tservi 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 0b65a789a..47a704280 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 @@ public: 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); -- cgit v1.2.1