From aad3b7f18649f066702f4eaf995d1e3743279bfd Mon Sep 17 00:00:00 2001 From: Dimitar Dobrev Date: Thu, 28 Feb 2019 18:19:48 +0200 Subject: [PATCH] Fixed the renaming of properties with the same name as their owners. Signed-off-by: Dimitar Dobrev --- src/Generator/Passes/RenamePass.cs | 4 +--- tests/Common/Common.Tests.cs | 4 ++++ tests/Common/Common.cpp | 8 ++++++++ tests/Common/Common.h | 8 ++++++++ 4 files changed, 21 insertions(+), 3 deletions(-) diff --git a/src/Generator/Passes/RenamePass.cs b/src/Generator/Passes/RenamePass.cs index 316cd816..77c3eaf9 100644 --- a/src/Generator/Passes/RenamePass.cs +++ b/src/Generator/Passes/RenamePass.cs @@ -170,14 +170,12 @@ namespace CppSharp.Passes declarations.AddRange(decl.Namespace.Classes.Where(c => !c.IsIncomplete)); declarations.AddRange(decl.Namespace.Enums); declarations.AddRange(decl.Namespace.Events); + declarations.Add(decl.Namespace); var function = decl as Function; if (function != null) - { - declarations.Add(function.Namespace); // account for overloads declarations.AddRange(GetFunctionsWithTheSameParams(function)); - } else declarations.AddRange(decl.Namespace.Functions); diff --git a/tests/Common/Common.Tests.cs b/tests/Common/Common.Tests.cs index b41875a9..24d6cbc5 100644 --- a/tests/Common/Common.Tests.cs +++ b/tests/Common/Common.Tests.cs @@ -47,6 +47,10 @@ public class CommonTests : GeneratorTestFixture using (var hasProtectedEnum = new HasProtectedEnum()) { } + using (var hasPropertyNamedAsParent = new HasPropertyNamedAsParent()) + { + hasPropertyNamedAsParent.hasPropertyNamedAsParent.GetHashCode(); + } EnumWithUnderscores e = EnumWithUnderscores.lOWER_BEFORE_CAPITAL; e = EnumWithUnderscores.UnderscoreAtEnd; e = EnumWithUnderscores.CAPITALS_More; diff --git a/tests/Common/Common.cpp b/tests/Common/Common.cpp index de393597..e7684deb 100644 --- a/tests/Common/Common.cpp +++ b/tests/Common/Common.cpp @@ -999,6 +999,14 @@ AmbiguousParamNames::~AmbiguousParamNames() { } +HasPropertyNamedAsParent::HasPropertyNamedAsParent() +{ +} + +HasPropertyNamedAsParent::~HasPropertyNamedAsParent() +{ +} + void integerOverload(int i) { } diff --git a/tests/Common/Common.h b/tests/Common/Common.h index 7a31bf6d..b36f37c6 100644 --- a/tests/Common/Common.h +++ b/tests/Common/Common.h @@ -1401,6 +1401,14 @@ public: ~AmbiguousParamNames(); }; +class DLL_API HasPropertyNamedAsParent +{ +public: + HasPropertyNamedAsParent(); + ~HasPropertyNamedAsParent(); + int hasPropertyNamedAsParent; +}; + template void TemplatedFunction(T type) {