diff --git a/modules/mono/editor/bindings_generator.cpp b/modules/mono/editor/bindings_generator.cpp index eb45ade285f..e1ce41edd5e 100644 --- a/modules/mono/editor/bindings_generator.cpp +++ b/modules/mono/editor/bindings_generator.cpp @@ -2581,6 +2581,10 @@ Error BindingsGenerator::_generate_cs_property(const BindingsGenerator::TypeInte p_output.append("\")]"); } + if (p_iprop.is_hidden) { + p_output.append(MEMBER_BEGIN "[EditorBrowsable(EditorBrowsableState.Never)]"); + } + p_output.append(MEMBER_BEGIN "public "); if (prop_allowed_inherited_member_hiding.has(p_itype.proxy_name + "." + p_iprop.proxy_name)) { @@ -2840,7 +2844,7 @@ Error BindingsGenerator::_generate_cs_method(const BindingsGenerator::TypeInterf p_output.append("\")]"); } - if (p_imethod.is_compat) { + if (p_imethod.is_hidden) { p_output.append(MEMBER_BEGIN "[EditorBrowsable(EditorBrowsableState.Never)]"); } @@ -3654,11 +3658,16 @@ bool BindingsGenerator::_populate_object_type_interfaces() { iprop.setter = ClassDB::get_property_setter(type_cname, iprop.cname); iprop.getter = ClassDB::get_property_getter(type_cname, iprop.cname); - if (iprop.setter != StringName()) { - accessor_methods[iprop.setter] = iprop.cname; - } - if (iprop.getter != StringName()) { - accessor_methods[iprop.getter] = iprop.cname; + // If the property is internal hide it; otherwise, hide the getter and setter. + if (property.usage & PROPERTY_USAGE_INTERNAL) { + iprop.is_hidden = true; + } else { + if (iprop.setter != StringName()) { + accessor_methods[iprop.setter] = iprop.cname; + } + if (iprop.getter != StringName()) { + accessor_methods[iprop.getter] = iprop.cname; + } } bool valid = false; @@ -3860,10 +3869,10 @@ bool BindingsGenerator::_populate_object_type_interfaces() { HashMap::Iterator accessor = accessor_methods.find(imethod.cname); if (accessor) { - // We only make internal an accessor method if it's in the same class as the property. + // We only hide an accessor method if it's in the same class as the property. // It's easier this way, but also we don't know if an accessor method in a different class // could have other purposes, so better leave those untouched. - imethod.is_internal = true; + imethod.is_hidden = true; } if (itype.class_doc) { @@ -3892,6 +3901,7 @@ bool BindingsGenerator::_populate_object_type_interfaces() { // after all the non-compat methods have been added. The compat methods are added in // reverse so the most recently added ones take precedence over older compat methods. if (imethod.is_compat) { + imethod.is_hidden = true; compat_methods.push_front(imethod); continue; } diff --git a/modules/mono/editor/bindings_generator.h b/modules/mono/editor/bindings_generator.h index bb0ba0cb009..a397dcb0266 100644 --- a/modules/mono/editor/bindings_generator.h +++ b/modules/mono/editor/bindings_generator.h @@ -88,6 +88,14 @@ class BindingsGenerator { StringName setter; StringName getter; + /** + * Determines if the property will be hidden with the [EditorBrowsable(EditorBrowsableState.Never)] + * attribute. + * We do this for propertyies that have the PROPERTY_USAGE_INTERNAL flag, because they are not meant + * to be exposed to scripting but we can't remove them to prevent breaking compatibility. + */ + bool is_hidden = false; + const DocData::PropertyDoc *prop_doc; bool is_deprecated = false; @@ -179,6 +187,14 @@ class BindingsGenerator { */ bool is_internal = false; + /** + * Determines if the method will be hidden with the [EditorBrowsable(EditorBrowsableState.Never)] + * attribute. + * We do this for methods that we don't want to expose but need to be public to prevent breaking + * compat (i.e: methods with 'is_compat' set to true.) + */ + bool is_hidden = false; + /** * Determines if the method is a compatibility method added to avoid breaking binary compatibility. * These methods will be generated but hidden and are considered deprecated.