From 7ead06e1a64685493d553944902895410ba9f19f Mon Sep 17 00:00:00 2001 From: Ruben Tytgat Date: Fri, 26 Jul 2024 14:42:47 +0200 Subject: [PATCH] Add test for issue #1283 --- src/Generator.Tests/Passes/TestPasses.cs | 11 +++++++++++ tests/dotnet/Native/Passes.h | 13 +++++++++++++ 2 files changed, 24 insertions(+) diff --git a/src/Generator.Tests/Passes/TestPasses.cs b/src/Generator.Tests/Passes/TestPasses.cs index bc3e145ecf..a09d1c14d7 100644 --- a/src/Generator.Tests/Passes/TestPasses.cs +++ b/src/Generator.Tests/Passes/TestPasses.cs @@ -452,6 +452,17 @@ public void TestFlattenAnonymousTypesToFields() Assert.AreEqual(AccessSpecifier.Protected, @protected.Access); } + [Test] + public void TestGetterSetterToPropertyPassHandlesBaseClassesFirst() + { + var @class = AstContext.Class("TestOverridingVirtualPropertyInNamespacedClass"); + + passBuilder.AddPass(new GetterSetterToPropertyPass()); + passBuilder.RunPasses(pass => pass.VisitASTContext(AstContext)); + + Assert.IsNotEmpty(@class.Properties); + } + private PassBuilder passBuilder; } } diff --git a/tests/dotnet/Native/Passes.h b/tests/dotnet/Native/Passes.h index be83d5236f..6d8b51f586 100644 --- a/tests/dotnet/Native/Passes.h +++ b/tests/dotnet/Native/Passes.h @@ -141,3 +141,16 @@ class TestExtractInterfacePass public: void DoSomething(); }; + +// https://github.com/mono/CppSharp/issues/1283 +namespace NamespaceWithVirtualPropertyClass { + class TestNamespacedClassWithVirtualProperty { + public: + virtual int property(); + }; +} + +class TestOverridingVirtualPropertyInNamespacedClass : public NamespaceWithVirtualPropertyClass::TestNamespacedClassWithVirtualProperty { +public: + virtual int property() override; +};