summaryrefslogtreecommitdiff
path: root/compiler/cpp/src/thrift/generate
diff options
context:
space:
mode:
authorJens Geyer <jensg@apache.org>2021-10-27 12:22:25 +0200
committerJens Geyer <Jens-G@users.noreply.github.com>2021-10-27 16:43:12 +0200
commit007b99b72adcc97a0715b92d5f495620bee35715 (patch)
treecaca79eb5d4eb7a29e051b87e4579b99596174ae /compiler/cpp/src/thrift/generate
parent2b8be5154fc4f017fe98ca2e19d6526b265ca121 (diff)
downloadthrift-007b99b72adcc97a0715b92d5f495620bee35715.tar.gz
THRIFT-5408 Support for deprecated methods - follow_up fix
Diffstat (limited to 'compiler/cpp/src/thrift/generate')
-rw-r--r--compiler/cpp/src/thrift/generate/t_netstd_generator.cc27
-rw-r--r--compiler/cpp/src/thrift/generate/t_netstd_generator.h1
2 files changed, 18 insertions, 10 deletions
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<t_function*> 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);