Skip to content

Commit

Permalink
Merge pull request #89317 from paulloz/dotnet/almost-there-with-the-w…
Browse files Browse the repository at this point in the history
…arnings

C#: Fix warnings in GodotSharp
  • Loading branch information
akien-mga committed Mar 9, 2024
2 parents 0322436 + 7290e7d commit 611ae19
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
18 changes: 18 additions & 0 deletions modules/mono/editor/bindings_generator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,20 @@ const Vector<String> ignored_types = {};
// Don't check against all C# reserved words, as many cases are GDScript-specific.
const Vector<String> langword_check = { "true", "false", "null" };

// The following properties currently need to be defined with `new` to avoid warnings. We treat
// them as a special case instead of silencing the warnings altogether, to be warned if more
// shadowing appears.
const Vector<String> prop_allowed_inherited_member_hiding = {
"ArrayMesh.BlendShapeMode",
"Button.TextDirection",
"Label.TextDirection",
"LineEdit.TextDirection",
"LinkButton.TextDirection",
"MenuBar.TextDirection",
"RichTextLabel.TextDirection",
"TextEdit.TextDirection",
};

void BindingsGenerator::TypeInterface::postsetup_enum_type(BindingsGenerator::TypeInterface &r_enum_itype) {
// C interface for enums is the same as that of 'uint32_t'. Remember to apply
// any of the changes done here to the 'uint32_t' type interface as well.
Expand Down Expand Up @@ -2569,6 +2583,10 @@ Error BindingsGenerator::_generate_cs_property(const BindingsGenerator::TypeInte

p_output.append(MEMBER_BEGIN "public ");

if (prop_allowed_inherited_member_hiding.has(p_itype.proxy_name + "." + p_iprop.proxy_name)) {
p_output.append("new ");
}

if (p_itype.is_singleton) {
p_output.append("static ");
}
Expand Down
3 changes: 3 additions & 0 deletions modules/mono/glue/GodotSharp/GodotSharp/Core/Variant.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@ namespace Godot;

#nullable enable

// TODO: Disabled because it is a false positive, see https://github.com/dotnet/roslyn-analyzers/issues/6151
#pragma warning disable CA1001 // Types that own disposable fields should be disposable
public partial struct Variant : IDisposable
#pragma warning restore CA1001
{
internal godot_variant.movable NativeVar;
private object? _obj;
Expand Down

0 comments on commit 611ae19

Please sign in to comment.