::Eolian_Function_Type ftype = ::eolian_function_type_get(function);
const char* eo_name = ::eolian_function_name_get(function);
std::string name = object_ref_conversion(klass);
+
+ // Klass is needed to check the property naming rulles
+ attributes::klass_def klass_d((const ::Eolian_Class *)klass, eolian_object_unit_get(klass));
+
switch(ftype)
{
case ::EOLIAN_METHOD:
break;
case ::EOLIAN_PROP_SET:
name += ".Set";
- name += name_helpers::property_managed_name(eo_name);
+ name += name_helpers::property_managed_name(klass_d, eo_name);
break;
case ::EOLIAN_PROP_GET:
name += ".Get";
- name += name_helpers::property_managed_name(eo_name);
+ name += name_helpers::property_managed_name(klass_d, eo_name);
break;
case ::EOLIAN_PROPERTY:
{
int getter_params = property_num_parameters(function, ::EOLIAN_PROP_GET);
int setter_params = property_num_parameters(function, ::EOLIAN_PROP_SET);
- std::string short_name = name_helpers::property_managed_name(eo_name);
+ std::string short_name = name_helpers::property_managed_name(klass_d, eo_name);
bool blacklisted = blacklist::is_property_blacklisted(name + "." + short_name);
// EO properties with keys, with more than one value, or blacklisted, are not
// converted into C# properties.
return false;
if (property.getter.is_engaged())
- if (!as_generator(scope_tab << scope_tab << "get " << (interface ? ";" : "{ return Get" + managed_name + "(); }") << "\n"
+ if (!as_generator(scope_tab << scope_tab << "get " << (interface ? ";" : "{ return " + name_helpers::managed_method_name(*property.getter) + "(); }") << "\n"
).generate(sink, attributes::unused, context))
return false;
if (property.setter.is_engaged())
- if (!as_generator(scope_tab << scope_tab << "set " << (interface ? ";" : "{ Set" + managed_name + "(" + dir_mod + "value); }") << "\n"
+ if (!as_generator(scope_tab << scope_tab << "set " << (interface ? ";" : "{ " + name_helpers::managed_method_name(*property.setter) + "(" + dir_mod + "value); }") << "\n"
).generate(sink, attributes::unused, context))
return false;
}
}
+// Forward declarations
+template<typename T>
+inline std::string klass_concrete_or_interface_name(T const& klass);
+
inline std::string identity(std::string const& str)
{
return str;
if (candidate == klass)
candidate = "Do" + candidate;
+ // Avoid clashing with System.Object.GetType
+ if (candidate == "GetType" || candidate == "SetType")
+ {
+ candidate.insert(3, klass);
+ }
+
return candidate;
}
return utils::capitalize(in);
}
-inline std::string property_managed_name(const std::string name)
+
+
+template<typename T>
+inline std::string property_managed_name(T const& klass, std::string const& name)
{
auto names = utils::split(name, '_');
// No need to escape keyword here as it will be capitalized and already
// namespaced inside the owner class.
- return utils::to_pascal_case(names);
+ auto managed_name = utils::to_pascal_case(names);
+ auto managed_klass_name = klass_concrete_or_interface_name(klass);
+
+ if (managed_name == "Type")
+ managed_name = managed_klass_name + managed_name;
+
+ return managed_name;
}
inline std::string property_managed_name(attributes::property_def const& property)
{
- return property_managed_name(property.name);
+ return property_managed_name(property.klass, property.name);
}
inline std::string managed_part_name(attributes::part_def const& part)