Skip to content

Commit

Permalink
THRIFT-5408 Support for deprecated methods - follow_up fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Jens-G committed Oct 27, 2021
1 parent 2b8be51 commit 007b99b
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 10 deletions.
27 changes: 17 additions & 10 deletions compiler/cpp/src/thrift/generate/t_netstd_generator.cc
Expand Up @@ -1926,23 +1926,27 @@ 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();
out << indent() << "}" << endl << endl;
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();
Expand Down Expand Up @@ -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();
Expand All @@ -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();
Expand Down Expand 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();
Expand Down
1 change: 1 addition & 0 deletions compiler/cpp/src/thrift/generate/t_netstd_generator.h
Expand Up @@ -105,6 +105,7 @@ class t_netstd_generator : public t_oop_generator
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);
Expand Down

0 comments on commit 007b99b

Please sign in to comment.