From 9510702ede61e95e8d5e2776f8178c742ece3d04 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Paulo=20Taylor=20Ienczak=20Zanette?= Date: Wed, 12 Feb 2020 16:39:51 +0100 Subject: [PATCH] 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 --- src/bin/eolian_mono/eolian/mono/name_helpers.hh | 14 +++++++------- 1 file 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) return escape_keyword(utils::remove_all(ns, '_')); } +inline std::string managed_name(std::string const& name, char separator='_') +{ + auto tokens = utils::split(name, separator); + return utils::to_pascal_case(tokens); +} + inline std::string managed_method_name(attributes::function_def const& f) { std::vector names = utils::split(f.name, '_'); @@ -244,18 +250,12 @@ inline std::string managed_method_name(attributes::function_def const& f) // Avoid clashing with System.Object.GetType if (candidate == "GetType" || candidate == "SetType") { - candidate.insert(3, f.klass.eolian_name); + candidate.insert(3, managed_name(f.klass.eolian_name)); } return candidate; } -inline std::string managed_name(std::string const& name, char separator='_') -{ - auto tokens = utils::split(name, separator); - return utils::to_pascal_case(tokens); -} - inline std::string full_managed_name(std::string const& name) { std::stringstream ss;