From 0484993121807a3ae47c93cf7c8f78d1cf804058 Mon Sep 17 00:00:00 2001 From: Raul Santos Date: Tue, 6 Jun 2023 12:08:07 +0200 Subject: [PATCH] C#: Add `[Obsolete]` attribute to deprecated members --- modules/mono/editor/bindings_generator.cpp | 24 ++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/modules/mono/editor/bindings_generator.cpp b/modules/mono/editor/bindings_generator.cpp index 6b52c8eaaff0..7c6328e922a2 100644 --- a/modules/mono/editor/bindings_generator.cpp +++ b/modules/mono/editor/bindings_generator.cpp @@ -1375,6 +1375,10 @@ Error BindingsGenerator::_generate_cs_type(const TypeInterface &itype, const Str output.append("/// \n"); } + + if (class_doc->is_deprecated) { + output.append("[Obsolete(\"This class is deprecated.\")]\n"); + } } // We generate a `GodotClassName` attribute if the engine class name is not the same as the @@ -1426,6 +1430,10 @@ Error BindingsGenerator::_generate_cs_type(const TypeInterface &itype, const Str output.append(INDENT1 "/// "); } + + if (iconstant.const_doc->is_deprecated) { + output.append(MEMBER_BEGIN "[Obsolete(\"This constant is deprecated.\")]"); + } } output.append(MEMBER_BEGIN "public const long "); @@ -1470,6 +1478,10 @@ Error BindingsGenerator::_generate_cs_type(const TypeInterface &itype, const Str output.append(INDENT2 "/// \n"); } + + if (iconstant.const_doc->is_deprecated) { + output.append(INDENT2 "[Obsolete(\"This enum member is deprecated.\")]\n"); + } } output.append(INDENT2); @@ -1867,6 +1879,10 @@ Error BindingsGenerator::_generate_cs_property(const BindingsGenerator::TypeInte p_output.append(INDENT1 "/// "); } + + if (p_iprop.prop_doc->is_deprecated) { + p_output.append(MEMBER_BEGIN "[Obsolete(\"This property is deprecated.\")]"); + } } p_output.append(MEMBER_BEGIN "public "); @@ -2102,6 +2118,10 @@ Error BindingsGenerator::_generate_cs_method(const BindingsGenerator::TypeInterf p_output.append(INDENT1 "/// "); } + + if (p_imethod.method_doc->is_deprecated) { + p_output.append(MEMBER_BEGIN "[Obsolete(\"This method is deprecated.\")]"); + } } if (default_args_doc.get_string_length()) { @@ -2314,6 +2334,10 @@ Error BindingsGenerator::_generate_cs_signal(const BindingsGenerator::TypeInterf p_output.append(INDENT1 "/// "); } + + if (p_isignal.method_doc->is_deprecated) { + p_output.append(MEMBER_BEGIN "[Obsolete(\"This signal is deprecated.\")]"); + } } if (p_isignal.is_deprecated) {