Skip to content

Commit 9d365a6

Browse files
committed
Restore mapping of two properties of the same name save for a prefix
Signed-off-by: Dimitar Dobrev <[email protected]>
1 parent d2ebabb commit 9d365a6

File tree

4 files changed

+18
-3
lines changed

4 files changed

+18
-3
lines changed

src/Generator/Passes/GetterSetterToPropertyPass.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ protected virtual HashSet<Property> GenerateProperties(Class @class)
9494
{
9595
string name = GetPropertyNameFromSetter(method.Name);
9696
QualifiedType type = method.Parameters.First(p => p.Kind == ParameterKind.Regular).QualifiedType;
97-
Property property = GetProperty(method, name, type);
97+
Property property = GetProperty(method, name, type, true);
9898
property.SetMethod = method;
9999
newProperties.Add(property);
100100
}
@@ -103,14 +103,16 @@ protected virtual HashSet<Property> GenerateProperties(Class @class)
103103
return newProperties;
104104
}
105105

106-
private static Property GetProperty(Method method, string name, QualifiedType type)
106+
private static Property GetProperty(Method method, string name,
107+
QualifiedType type, bool isSetter = false)
107108
{
108109
Type underlyingType = GetUnderlyingType(type);
109110
Class @class = (Class) method.Namespace;
110111
Property property = @class.Properties.Find(
111112
p => p.Field == null &&
112113
(p.Name == name ||
113-
(p.GetMethod != null && GetReadWritePropertyName(p.GetMethod, name) == name)) &&
114+
(isSetter && p.GetMethod != null &&
115+
GetReadWritePropertyName(p.GetMethod, name) == name)) &&
114116
((p.GetMethod != null &&
115117
GetUnderlyingType(p.GetMethod.OriginalReturnType).Equals(underlyingType)) ||
116118
(p.SetMethod != null &&

tests/Common/Common.Tests.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -521,6 +521,7 @@ public void TestProperties()
521521
Assert.That(prop.nestedEnum(55), Is.EqualTo(55));
522522

523523
Assert.That(prop.Get32Bit, Is.EqualTo(10));
524+
Assert.That(prop.IsEmpty, Is.EqualTo(prop.Empty));
524525
}
525526
}
526527

tests/Common/Common.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -618,6 +618,16 @@ int TestProperties::get32Bit()
618618
return 10;
619619
}
620620

621+
bool TestProperties::isEmpty()
622+
{
623+
return empty();
624+
}
625+
626+
bool TestProperties::empty()
627+
{
628+
return false;
629+
}
630+
621631
HasOverridenSetter::HasOverridenSetter()
622632
{
623633
}

tests/Common/Common.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -612,6 +612,8 @@ struct DLL_API TestProperties
612612
int nestedEnum(int i);
613613

614614
int get32Bit();
615+
bool isEmpty();
616+
bool empty();
615617
private:
616618
int FieldValue;
617619
double _refToPrimitiveInSetter;

0 commit comments

Comments
 (0)