Browse Source

Fixed a regression causing public fields of type specialization to be ignored.

Signed-off-by: Dimitar Dobrev <dpldobrev@protonmail.com>
pull/1033/head
Dimitar Dobrev 8 years ago
parent
commit
1e6c881bdc
  1. 6
      src/Generator/Passes/TrimSpecializationsPass.cs
  2. 14
      tests/CSharp/CSharp.Tests.cs
  3. 2
      tests/CSharp/CSharpTemplates.h

6
src/Generator/Passes/TrimSpecializationsPass.cs

@ -78,7 +78,11 @@ namespace CppSharp.Passes @@ -78,7 +78,11 @@ namespace CppSharp.Passes
if (!base.VisitDeclaration(field))
return false;
CheckForInternalSpecialization(field, field.Type);
if (field.Access == AccessSpecifier.Private ||
!ASTUtils.CheckTypeForSpecialization(field.Type,
field, AddSpecialization, Context.TypeMaps))
CheckForInternalSpecialization(field, field.Type);
return true;
}

14
tests/CSharp/CSharp.Tests.cs

@ -871,6 +871,20 @@ public unsafe class CSharpTests : GeneratorTestFixture @@ -871,6 +871,20 @@ public unsafe class CSharpTests : GeneratorTestFixture
}
}
[Test]
public void TestFieldWithSpecializationType()
{
using (var virtualTemplate = new VirtualTemplate<int>())
{
using (var dependentValueFields = new DependentValueFields<float>())
{
dependentValueFields.DependentValue = 15;
virtualTemplate.FieldWithSpecializationType = dependentValueFields;
Assert.That(virtualTemplate.FieldWithSpecializationType.DependentValue, Is.EqualTo(15));
}
}
}
[Test]
public void TestAbstractImplementatonsInPrimaryAndSecondaryBases()
{

2
tests/CSharp/CSharpTemplates.h

@ -388,6 +388,7 @@ public: @@ -388,6 +388,7 @@ public:
VirtualTemplate(OptionalTemplateArgs<T> optionalTemplateArgs);
virtual ~VirtualTemplate();
virtual int function();
DependentValueFields<float> fieldWithSpecializationType;
};
template <typename T>
@ -569,6 +570,7 @@ template class DLL_API IndependentFields<T1>; @@ -569,6 +570,7 @@ template class DLL_API IndependentFields<T1>;
template class DLL_API IndependentFields<std::string>;
template class DLL_API Base<int>;
template class DLL_API DependentValueFields<int>;
template class DLL_API DependentValueFields<float>;
template class DLL_API VirtualTemplate<int>;
template class DLL_API VirtualTemplate<bool>;
template class DLL_API HasDefaultTemplateArgument<int, int>;

Loading…
Cancel
Save