Browse Source

Fixed a possible ambiguity when generating properties.

Signed-off-by: Dimitar Dobrev <dpldobrev@protonmail.com>
pull/661/head
Dimitar Dobrev 10 years ago
parent
commit
18406b8c53
  1. 16
      src/Generator/Passes/GetterSetterToPropertyAdvancedPass.cs
  2. 7
      tests/CSharp/CSharp.h

16
src/Generator/Passes/GetterSetterToPropertyAdvancedPass.cs

@ -135,16 +135,17 @@ namespace CppSharp.Passes @@ -135,16 +135,17 @@ namespace CppSharp.Passes
private static void GenerateProperty(DeclarationContext context, Method getter, Method setter = null)
{
var type = (Class) context;
if (type.Properties.All(p => getter.Name != p.Name ||
p.ExplicitInterfaceImpl != getter.ExplicitInterfaceImpl))
{
var name = GetPropertyName(getter.Name);
if (type.Properties.Any(p => p.Name == name &&
p.ExplicitInterfaceImpl == getter.ExplicitInterfaceImpl))
return;
var property = new Property
{
Access = getter.Access == AccessSpecifier.Public ||
(setter != null && setter.Access == AccessSpecifier.Public)
? AccessSpecifier.Public
: AccessSpecifier.Protected,
Name = GetPropertyName(getter.Name),
(setter != null && setter.Access == AccessSpecifier.Public) ?
AccessSpecifier.Public : AccessSpecifier.Protected,
Name = name,
Namespace = type,
QualifiedType = getter.OriginalReturnType,
OriginalNamespace = getter.OriginalNamespace
@ -175,7 +176,6 @@ namespace CppSharp.Passes @@ -175,7 +176,6 @@ namespace CppSharp.Passes
if (setter != null)
setter.GenerationKind = GenerationKind.Internal;
}
}
private static RawComment CombineComments(Declaration getter, Declaration setter)
{

7
tests/CSharp/CSharp.h

@ -913,3 +913,10 @@ protected: @@ -913,3 +913,10 @@ protected:
private:
virtual int property();
};
class HasConflictWithProperty
{
public:
int conflictWithProperty();
int getConflictWithProperty();
};

Loading…
Cancel
Save