diff --git a/src/Generator/Passes/GetterSetterToPropertyPass.cs b/src/Generator/Passes/GetterSetterToPropertyPass.cs index a9e03a0e..1cf1a5e7 100644 --- a/src/Generator/Passes/GetterSetterToPropertyPass.cs +++ b/src/Generator/Passes/GetterSetterToPropertyPass.cs @@ -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 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 && diff --git a/tests/Common/Common.Tests.cs b/tests/Common/Common.Tests.cs index c5f90274..40f50985 100644 --- a/tests/Common/Common.Tests.cs +++ b/tests/Common/Common.Tests.cs @@ -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)); } } diff --git a/tests/Common/Common.cpp b/tests/Common/Common.cpp index c537efa8..094f4efe 100644 --- a/tests/Common/Common.cpp +++ b/tests/Common/Common.cpp @@ -618,6 +618,16 @@ int TestProperties::get32Bit() return 10; } +bool TestProperties::isEmpty() +{ + return empty(); +} + +bool TestProperties::empty() +{ + return false; +} + HasOverridenSetter::HasOverridenSetter() { } diff --git a/tests/Common/Common.h b/tests/Common/Common.h index 82e6a931..9e3153c8 100644 --- a/tests/Common/Common.h +++ b/tests/Common/Common.h @@ -612,6 +612,8 @@ public: int nestedEnum(int i); int get32Bit(); + bool isEmpty(); + bool empty(); private: int FieldValue; double _refToPrimitiveInSetter;