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
This commit is contained in:
João Paulo Taylor Ienczak Zanette 2020-02-12 16:39:51 +01:00 committed by Xavi Artigas
parent cc777c05f8
commit 9510702ede
1 changed files with 7 additions and 7 deletions

View File

@ -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<std::string> 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;