Permalink
Browse files

Fixed a regression of overridden setters not turning into properties.

Signed-off-by: Dimitar Dobrev <dpldobrev@protonmail.com>
  • Loading branch information...
ddobrev committed Jul 11, 2017
1 parent 54f3af1 commit 9f4d501d0be971f7c56e3a746b9a865c33e1b5f8
@@ -85,7 +85,8 @@ private void GenerateProperties(IEnumerable<Method> settersToUse, bool readOnly)
if (!type.IsInterface && baseProperty != null && baseProperty.IsVirtual && setter.IsVirtual)
{
bool isReadOnly = baseProperty.SetMethod == null;
GenerateProperty(setter.Namespace, baseProperty.GetMethod,
var name = GetReadWritePropertyName(baseProperty.GetMethod, afterSet);
GenerateProperty(name, setter.Namespace, baseProperty.GetMethod,
readOnly || isReadOnly ? null : setter);
}
next:
@@ -1,4 +1,5 @@
using System;
using System.Reflection;
using CommonTest;
using CppSharp.Utils;
using NUnit.Framework;
@@ -775,4 +776,13 @@ public void TestVirtualFuncWithStringParams()
Assert.That(VirtFuncWithStringParam.VirtualFunctionWithStringParam("anyRandomString").Equals(5));
}
}
[Test]
public void TestOverriddenSetter()
{
var propertyInfo = typeof(HasOverridenSetter).GetProperty("Virtual",
BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly);
Assert.That(propertyInfo, Is.Not.Null);
Assert.That(propertyInfo.CanWrite);
}
}
@@ -489,6 +489,37 @@ std::string& HasStdString::getStdString()
return s;
}
TestProperties::TestProperties() : Field(0)
{
}
int TestProperties::getFieldValue()
{
return Field;
}
void TestProperties::setFieldValue(int Value)
{
Field = Value;
}
bool TestProperties::isVirtual()
{
return false;
}
void TestProperties::setVirtual(bool value)
{
}
HasOverridenSetter::HasOverridenSetter()
{
}
void HasOverridenSetter::setVirtual(bool value)
{
}
TypeMappedIndex::TypeMappedIndex()
{
}
@@ -780,4 +811,4 @@ void ImplementsVirtualFunctionsWithStringParams::PureVirtualFunctionWithStringPa
int HasVirtualFunctionsWithStringParams::VirtualFunctionWithStringParam(std::string testString)
{
return 5;
}
}
@@ -578,13 +578,19 @@ struct DLL_API TestProperties
int getFieldValue();
void setFieldValue(int Value);
bool isVirtual();
virtual void setVirtual(bool value);
private:
int FieldValue;
};
TestProperties::TestProperties() : Field(0) {}
int TestProperties::getFieldValue() { return Field; }
void TestProperties::setFieldValue(int Value) { Field = Value; }
class DLL_API HasOverridenSetter : public TestProperties
{
public:
HasOverridenSetter();
void setVirtual(bool value);
};
class DLL_API TypeMappedIndex
{
@@ -1297,4 +1303,4 @@ class DLL_API ImplementsVirtualFunctionsWithStringParams : public HasVirtualFunc
ImplementsVirtualFunctionsWithStringParams();
~ImplementsVirtualFunctionsWithStringParams();
virtual void PureVirtualFunctionWithStringParams(std::string testString);
};
};

0 comments on commit 9f4d501

Please sign in to comment.