Browse Source

Fixed invalid C# code when wrapping a constant of type std::string.

Signed-off-by: Dimitar Dobrev <dpldobrev@protonmail.com>
pull/681/head
Dimitar Dobrev 9 years ago
parent
commit
6a0069f9c2
  1. 6
      src/Generator/Generators/CSharp/CSharpTextTemplate.cs
  2. 1
      tests/CSharp/AnotherUnit.cpp
  3. 2
      tests/CSharp/AnotherUnit.h
  4. 8
      tests/CSharp/CSharp.Tests.cs
  5. 3
      tests/Common/Common.Tests.cs

6
src/Generator/Generators/CSharp/CSharpTextTemplate.cs

@ -1188,7 +1188,13 @@ namespace CppSharp.Generators.CSharp @@ -1188,7 +1188,13 @@ namespace CppSharp.Generators.CSharp
if (!string.IsNullOrWhiteSpace(marshal.Context.SupportBefore))
Write(marshal.Context.SupportBefore);
if (ctx.HasCodeBlock)
PushIndent();
WriteLine("return {0};", marshal.Context.Return);
if (ctx.HasCodeBlock)
WriteCloseBraceIndent();
}
WriteCloseBraceIndent();

1
tests/CSharp/AnotherUnit.cpp

@ -7,4 +7,5 @@ void functionInAnotherUnit() @@ -7,4 +7,5 @@ void functionInAnotherUnit()
namespace HasFreeConstant
{
extern const int DLL_API FREE_CONSTANT_IN_NAMESPACE = 5;
// extern const std::string DLL_API STD_STRING_CONSTANT = "test";
}

2
tests/CSharp/AnotherUnit.h

@ -1,4 +1,5 @@ @@ -1,4 +1,5 @@
#include "../Tests.h"
//#include <string>
void DLL_API functionInAnotherUnit();
@ -15,4 +16,5 @@ class ForwardInOtherUnitButSameModule @@ -15,4 +16,5 @@ class ForwardInOtherUnitButSameModule
namespace HasFreeConstant
{
extern const int DLL_API FREE_CONSTANT_IN_NAMESPACE;
// extern const std::string DLL_API STD_STRING_CONSTANT;
}

8
tests/CSharp/CSharp.Tests.cs

@ -520,6 +520,14 @@ public unsafe class CSharpTests : GeneratorTestFixture @@ -520,6 +520,14 @@ public unsafe class CSharpTests : GeneratorTestFixture
}
}
[Test, Ignore("We need symbols for std::string to invoke and auto-compilation of exported templates is not added yet.")]
public void TestStdStringConstant()
{
//Assert.That(CSharp.HasFreeConstant.AnotherUnit.STD_STRING_CONSTANT, Is.EqualTo("test"));
// check a second time to ensure it hasn't been improperly freed
//Assert.That(CSharp.HasFreeConstant.AnotherUnit.STD_STRING_CONSTANT, Is.EqualTo("test"));
}
// HACK: the completion of types is temporarily suspended because of problems with QtWidgets
[Test, Ignore]
public void TestTemplateInternals()

3
tests/Common/Common.Tests.cs

@ -633,8 +633,7 @@ public class CommonTests : GeneratorTestFixture @@ -633,8 +633,7 @@ public class CommonTests : GeneratorTestFixture
}
}
// ignored until we add automatic compilation for templates
[Test, Ignore]
[Test, Ignore("We need symbols for std::string to invoke and auto-compilation of exported templates is not added yet.")]
public void TestStdString()
{
using (var hasStdString = new HasStdString())

Loading…
Cancel
Save