Browse Source

Restore mapping of two properties of the same name save for a prefix

Signed-off-by: Dimitar Dobrev <dpldobrev@protonmail.com>
pull/1261/head
Dimitar Dobrev 6 years ago
parent
commit
9d365a6b9a
  1. 8
      src/Generator/Passes/GetterSetterToPropertyPass.cs
  2. 1
      tests/Common/Common.Tests.cs
  3. 10
      tests/Common/Common.cpp
  4. 2
      tests/Common/Common.h

8
src/Generator/Passes/GetterSetterToPropertyPass.cs

@ -94,7 +94,7 @@ namespace CppSharp.Passes @@ -94,7 +94,7 @@ namespace CppSharp.Passes
{
string name = GetPropertyNameFromSetter(method.Name);
QualifiedType type = method.Parameters.First(p => p.Kind == ParameterKind.Regular).QualifiedType;
Property property = GetProperty(method, name, type);
Property property = GetProperty(method, name, type, true);
property.SetMethod = method;
newProperties.Add(property);
}
@ -103,14 +103,16 @@ namespace CppSharp.Passes @@ -103,14 +103,16 @@ namespace CppSharp.Passes
return newProperties;
}
private static Property GetProperty(Method method, string name, QualifiedType type)
private static Property GetProperty(Method method, string name,
QualifiedType type, bool isSetter = false)
{
Type underlyingType = GetUnderlyingType(type);
Class @class = (Class) method.Namespace;
Property property = @class.Properties.Find(
p => p.Field == null &&
(p.Name == name ||
(p.GetMethod != null && GetReadWritePropertyName(p.GetMethod, name) == name)) &&
(isSetter && p.GetMethod != null &&
GetReadWritePropertyName(p.GetMethod, name) == name)) &&
((p.GetMethod != null &&
GetUnderlyingType(p.GetMethod.OriginalReturnType).Equals(underlyingType)) ||
(p.SetMethod != null &&

1
tests/Common/Common.Tests.cs

@ -521,6 +521,7 @@ public class CommonTests : GeneratorTestFixture @@ -521,6 +521,7 @@ public class CommonTests : GeneratorTestFixture
Assert.That(prop.nestedEnum(55), Is.EqualTo(55));
Assert.That(prop.Get32Bit, Is.EqualTo(10));
Assert.That(prop.IsEmpty, Is.EqualTo(prop.Empty));
}
}

10
tests/Common/Common.cpp

@ -618,6 +618,16 @@ int TestProperties::get32Bit() @@ -618,6 +618,16 @@ int TestProperties::get32Bit()
return 10;
}
bool TestProperties::isEmpty()
{
return empty();
}
bool TestProperties::empty()
{
return false;
}
HasOverridenSetter::HasOverridenSetter()
{
}

2
tests/Common/Common.h

@ -612,6 +612,8 @@ public: @@ -612,6 +612,8 @@ public:
int nestedEnum(int i);
int get32Bit();
bool isEmpty();
bool empty();
private:
int FieldValue;
double _refToPrimitiveInSetter;

Loading…
Cancel
Save