THRIFT-4832 superfluous backing field causes CS0169 "field never used"
Client: netstd
Patch: Jens Geyer
This closes #1768
diff --git a/compiler/cpp/src/thrift/generate/t_netstd_generator.cc b/compiler/cpp/src/thrift/generate/t_netstd_generator.cc
index 47a1dd1..b76a34d 100644
--- a/compiler/cpp/src/thrift/generate/t_netstd_generator.cc
+++ b/compiler/cpp/src/thrift/generate/t_netstd_generator.cc
@@ -918,7 +918,11 @@
// make private members with public Properties
for (m_iter = members.begin(); m_iter != members.end(); ++m_iter)
{
- out << indent() << "private " << declare_field(*m_iter, false, "_") << endl;
+ // if the field is required, then we use auto-properties
+ if (!field_is_required((*m_iter)))
+ {
+ out << indent() << "private " << declare_field(*m_iter, false, "_") << endl;
+ }
}
out << endl;