summaryrefslogtreecommitdiff
path: root/src/bin
diff options
context:
space:
mode:
authorJoão Paulo Taylor Ienczak Zanette <joao.tiz@expertisesolutions.com.br>2020-02-12 16:39:51 +0100
committerXavi Artigas <xavierartigas@yahoo.es>2020-02-12 16:43:25 +0100
commit9510702ede61e95e8d5e2776f8178c742ece3d04 (patch)
treea0ec9f229a411b60d21eac838f453cfae17098e2 /src/bin
parentcc777c05f8b1b1a3b3259bba033aa8753b1d6109 (diff)
csharp: Fix managed name when solving Get/SetType name clash
Summary: If you declare a property called "type", the generated getter method would be called "GetType", clashing with "System.Object.GetType" method. The current workaround for that is to straight-forwardly insert the respective class/abstract's Eolian name into the function name (becoming, for example "GetMy_ClassType"), sometimes getting inconsistent to not only other methods but also with documentation (leading to XML errors, since a cref doc would reference "GetMyClassType", which doesn't exists). This patch fixes that by wrapping the Eolian name with the already existing `managed_name` function. Test Plan: Run ninja tests. Reviewers: zmike, segfaultxavi Reviewed By: segfaultxavi Subscribers: cedric, #reviewers, #committers Tags: #efl Differential Revision: https://phab.enlightenment.org/D11331
Diffstat (limited to 'src/bin')
-rw-r--r--src/bin/eolian_mono/eolian/mono/name_helpers.hh14
1 files changed, 7 insertions, 7 deletions
diff --git a/src/bin/eolian_mono/eolian/mono/name_helpers.hh b/src/bin/eolian_mono/eolian/mono/name_helpers.hh
index a6e94ea2f6..1294bf01ed 100644
--- a/src/bin/eolian_mono/eolian/mono/name_helpers.hh
+++ b/src/bin/eolian_mono/eolian/mono/name_helpers.hh
@@ -229,6 +229,12 @@ inline std::string managed_namespace(std::string const& ns)
229 return escape_keyword(utils::remove_all(ns, '_')); 229 return escape_keyword(utils::remove_all(ns, '_'));
230} 230}
231 231
232inline std::string managed_name(std::string const& name, char separator='_')
233{
234 auto tokens = utils::split(name, separator);
235 return utils::to_pascal_case(tokens);
236}
237
232inline std::string managed_method_name(attributes::function_def const& f) 238inline std::string managed_method_name(attributes::function_def const& f)
233{ 239{
234 std::vector<std::string> names = utils::split(f.name, '_'); 240 std::vector<std::string> names = utils::split(f.name, '_');
@@ -244,18 +250,12 @@ inline std::string managed_method_name(attributes::function_def const& f)
244 // Avoid clashing with System.Object.GetType 250 // Avoid clashing with System.Object.GetType
245 if (candidate == "GetType" || candidate == "SetType") 251 if (candidate == "GetType" || candidate == "SetType")
246 { 252 {
247 candidate.insert(3, f.klass.eolian_name); 253 candidate.insert(3, managed_name(f.klass.eolian_name));
248 } 254 }
249 255
250 return candidate; 256 return candidate;
251} 257}
252 258
253inline std::string managed_name(std::string const& name, char separator='_')
254{
255 auto tokens = utils::split(name, separator);
256 return utils::to_pascal_case(tokens);
257}
258
259inline std::string full_managed_name(std::string const& name) 259inline std::string full_managed_name(std::string const& name)
260{ 260{
261 std::stringstream ss; 261 std::stringstream ss;