diff --git a/src/AST/ASTVisitor.cs b/src/AST/ASTVisitor.cs index 5ff6fd24..1cb847f4 100644 --- a/src/AST/ASTVisitor.cs +++ b/src/AST/ASTVisitor.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Linq; namespace CppSharp.AST { @@ -308,7 +309,7 @@ namespace CppSharp.AST VisitFieldDecl(field); if (VisitOptions.VisitClassProperties) - foreach (var property in @class.Properties) + foreach (var property in @class.Properties.OrderByDescending(p => p.Access)) VisitProperty(property); if (VisitOptions.VisitClassMethods) diff --git a/src/Generator/Passes/RenamePass.cs b/src/Generator/Passes/RenamePass.cs index 7710b70a..0f0fe590 100644 --- a/src/Generator/Passes/RenamePass.cs +++ b/src/Generator/Passes/RenamePass.cs @@ -138,11 +138,15 @@ namespace CppSharp.Passes if (result) return true; - var method = decl as Method; - if (method == null || !method.IsGenerated) - return false; + if (decl is Method && decl.IsGenerated) + return ((Class) decl.Namespace).GetPropertyByName(newName) != null; - return ((Class) method.Namespace).GetPropertyByName(newName) != null; + var property = decl as Property; + if (property != null && property.Field != null) + return ((Class) decl.Namespace).Properties.FirstOrDefault( + p => p != decl && p.Name == newName) != null; + + return false; } private static IEnumerable GetFunctionsWithTheSameParams(Function function) diff --git a/tests/CSharp/CSharp.h b/tests/CSharp/CSharp.h index e670b062..4a0ed377 100644 --- a/tests/CSharp/CSharp.h +++ b/tests/CSharp/CSharp.h @@ -30,6 +30,7 @@ public: protected: int P; + int _method; TemplateInAnotherUnit templateInAnotherUnit; };