Skip to content

Commit 5f2de79

Browse files
committed
Generate valid C# when std::string is only used for public fields
Signed-off-by: Dimitar Dobrev <[email protected]>
1 parent 39d5828 commit 5f2de79

File tree

3 files changed

+14
-3
lines changed

3 files changed

+14
-3
lines changed

src/Generator/Passes/TrimSpecializationsPass.cs

+1-3
Original file line numberDiff line numberDiff line change
@@ -85,9 +85,7 @@ public override bool VisitFieldDecl(Field field)
8585
return true;
8686
}
8787

88-
TypeMap typeMap;
89-
if (!Context.TypeMaps.FindTypeMap(field.Type, out typeMap) &&
90-
!ASTUtils.CheckTypeForSpecialization(field.Type,
88+
if (!ASTUtils.CheckTypeForSpecialization(field.Type,
9189
field, AddSpecialization, Context.TypeMaps))
9290
CheckForInternalSpecialization(field, field.Type);
9391

tests/VTables/VTables.Tests.cs

+11
Original file line numberDiff line numberDiff line change
@@ -78,4 +78,15 @@ public void TestVirtualFuntionRetVal()
7878
var retBase = new ManagedDerivedClassVirtualRetBase();
7979
TestVirtualFunction(retBase, 10);
8080
}
81+
82+
[Test]
83+
public void TestStdStringInField()
84+
{
85+
using (var foo = new Foo())
86+
{
87+
Assert.That(foo.S, Is.Empty);
88+
foo.S = "test";
89+
Assert.That(foo.S, Is.EqualTo("test"));
90+
}
91+
}
8192
}

tests/VTables/VTables.h

+2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#include "../Tests.h"
2+
#include <string>
23

34
class DLL_API Foo
45
{
@@ -15,6 +16,7 @@ class DLL_API Foo
1516
virtual int append();
1617
virtual int append(int a);
1718
int callVirtualWithParameter(int a);
19+
std::string s;
1820
};
1921

2022
DLL_API int FooCallFoo(Foo* foo);

0 commit comments

Comments
 (0)