From b658ff32f126ecde6fb56d36558d42af7a518c04 Mon Sep 17 00:00:00 2001 From: Ruben Tytgat Date: Fri, 26 Jul 2024 17:54:08 +0200 Subject: [PATCH] Fix issue #1283 (#1855) * Fixes issue #1283 * Add test for issue #1283 * Move test for issue #1283 to CSharp test suite * Fix typo --- src/Generator/Passes/GetterSetterToPropertyPass.cs | 2 +- tests/dotnet/CSharp/CSharp.cpp | 5 +++++ tests/dotnet/CSharp/CSharp.h | 13 +++++++++++++ 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/src/Generator/Passes/GetterSetterToPropertyPass.cs b/src/Generator/Passes/GetterSetterToPropertyPass.cs index 4d49a4a4a..6de31147e 100644 --- a/src/Generator/Passes/GetterSetterToPropertyPass.cs +++ b/src/Generator/Passes/GetterSetterToPropertyPass.cs @@ -40,7 +40,7 @@ private static Stream GetResourceStream(Assembly assembly) } public GetterSetterToPropertyPass() - => VisitOptions.ResetFlags(VisitFlags.ClassTemplateSpecializations); + => VisitOptions.ResetFlags(VisitFlags.ClassBases | VisitFlags.ClassTemplateSpecializations); public override bool VisitClassDecl(Class @class) { diff --git a/tests/dotnet/CSharp/CSharp.cpp b/tests/dotnet/CSharp/CSharp.cpp index 9a8beb618..4d8fd04b8 100644 --- a/tests/dotnet/CSharp/CSharp.cpp +++ b/tests/dotnet/CSharp/CSharp.cpp @@ -1282,6 +1282,11 @@ int HasConflictWithAbstractProperty::conflictWithProperty() return 0; } +int TestOverrideOfPropertyInNamespacedClass::property() +{ + return 0; +} + const char* HasVirtualTakesReturnsProblematicTypes::virtualTakesAndReturnsString(const char* c) { return c; diff --git a/tests/dotnet/CSharp/CSharp.h b/tests/dotnet/CSharp/CSharp.h index 885244693..bc61b21ba 100644 --- a/tests/dotnet/CSharp/CSharp.h +++ b/tests/dotnet/CSharp/CSharp.h @@ -1029,6 +1029,19 @@ class DLL_API HasConflictWithAbstractProperty virtual int getConflictWithProperty() = 0; }; +// https://github.com/mono/CppSharp/issues/1283 +namespace NamespaceWithVirtualPropertyClass { + class DLL_API HasOverriddenPropertyInNamespacedClass { + public: + virtual int property() = 0; + }; +} + +class DLL_API TestOverrideOfPropertyInNamespacedClass : public NamespaceWithVirtualPropertyClass::HasOverriddenPropertyInNamespacedClass { +public: + virtual int property() override; +}; + template class lowerCase {