diff options
author | Paul Joannon <hello@pauljoannon.com> | 2024-03-09 17:05:23 +0100 |
---|---|---|
committer | Paul Joannon <hello@pauljoannon.com> | 2024-03-09 17:05:23 +0100 |
commit | 7290e7d7a54ab452d01c060a57b5b7c20d077338 (patch) | |
tree | fb69f2371fe7a768499a70f5fffcd1f1a61713e7 | |
parent | f28964805e44a5c068ce8fd9d1e00697fcd922dc (diff) | |
download | redot-engine-7290e7d7a54ab452d01c060a57b5b7c20d077338.tar.gz |
C#: Fix warnings
- Fix most CS0108 in generated glue
- Suppress CA1001 on `Variant`
-rw-r--r-- | modules/mono/editor/bindings_generator.cpp | 18 | ||||
-rw-r--r-- | modules/mono/glue/GodotSharp/GodotSharp/Core/Variant.cs | 3 |
2 files changed, 21 insertions, 0 deletions
diff --git a/modules/mono/editor/bindings_generator.cpp b/modules/mono/editor/bindings_generator.cpp index 5cb177676c..eb45ade285 100644 --- a/modules/mono/editor/bindings_generator.cpp +++ b/modules/mono/editor/bindings_generator.cpp @@ -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. @@ -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 "); } diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/Variant.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/Variant.cs index 036a26328a..c2d3050adc 100644 --- a/modules/mono/glue/GodotSharp/GodotSharp/Core/Variant.cs +++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/Variant.cs @@ -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; |