Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

C#: Make property accessors internal #71516

Merged
merged 1 commit into from
Jan 17, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 8 additions & 30 deletions modules/mono/editor/bindings_generator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1864,12 +1864,7 @@ Error BindingsGenerator::_generate_cs_property(const BindingsGenerator::TypeInte
p_output.append("\n" OPEN_BLOCK_L1);

if (getter) {
p_output.append(INDENT2 "get\n"

// TODO Remove this once we make accessor methods private/internal (they will no longer be marked as obsolete after that)
"#pragma warning disable CS0618 // Disable warning about obsolete method\n"

OPEN_BLOCK_L2 INDENT3);
p_output.append(INDENT2 "get\n" OPEN_BLOCK_L2 INDENT3);

p_output.append("return ");
p_output.append(getter->proxy_name + "(");
Expand All @@ -1884,21 +1879,11 @@ Error BindingsGenerator::_generate_cs_property(const BindingsGenerator::TypeInte
p_output.append(itos(p_iprop.index));
}
}
p_output.append(");\n"

CLOSE_BLOCK_L2

// TODO Remove this once we make accessor methods private/internal (they will no longer be marked as obsolete after that)
"#pragma warning restore CS0618\n");
p_output.append(");\n" CLOSE_BLOCK_L2);
}

if (setter) {
p_output.append(INDENT2 "set\n"

// TODO Remove this once we make accessor methods private/internal (they will no longer be marked as obsolete after that)
"#pragma warning disable CS0618 // Disable warning about obsolete method\n"

OPEN_BLOCK_L2 INDENT3);
p_output.append(INDENT2 "set\n" OPEN_BLOCK_L2 INDENT3);

p_output.append(setter->proxy_name + "(");
if (p_iprop.index != -1) {
Expand All @@ -1912,12 +1897,7 @@ Error BindingsGenerator::_generate_cs_property(const BindingsGenerator::TypeInte
p_output.append(itos(p_iprop.index) + ", ");
}
}
p_output.append("value);\n"

CLOSE_BLOCK_L2

// TODO Remove this once we make accessor methods private/internal (they will no longer be marked as obsolete after that)
"#pragma warning restore CS0618\n");
p_output.append("value);\n" CLOSE_BLOCK_L2);
}

p_output.append(CLOSE_BLOCK_L1);
Expand Down Expand Up @@ -3056,12 +3036,10 @@ bool BindingsGenerator::_populate_object_type_interfaces() {

HashMap<StringName, StringName>::Iterator accessor = accessor_methods.find(imethod.cname);
if (accessor) {
const PropertyInterface *accessor_property = itype.find_property_by_name(accessor->value);

// We only deprecate 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_deprecated = true;
imethod.deprecation_message = imethod.proxy_name + " is deprecated. Use the " + accessor_property->proxy_name + " property instead.";
// We only make internal 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;
}

if (itype.class_doc) {
Expand Down