Skip to content

Commit 3cd7fde

Browse files
committed
Generate valid C# for implicit conversion to const char*
Signed-off-by: Dimitar Dobrev <[email protected]>
1 parent 5a92220 commit 3cd7fde

File tree

4 files changed

+17
-2
lines changed

4 files changed

+17
-2
lines changed

src/Generator/Generators/CSharp/CSharpSources.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2901,7 +2901,6 @@ public void GenerateFunctionCall(string functionName, List<Parameter> parameters
29012901
ArgName = Helpers.ReturnIdentifier,
29022902
ReturnVarName = Helpers.ReturnIdentifier,
29032903
ReturnType = returnType,
2904-
Parameter = operatorParam,
29052904
Function = function
29062905
};
29072906

tests/CSharp/CSharp.Tests.cs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1276,7 +1276,17 @@ public void TestConstCharStarRef()
12761276
}
12771277

12781278
[Test]
1279-
public void Test()
1279+
public void TestImplicitConversionToString()
1280+
{
1281+
using (Foo foo = new Foo())
1282+
{
1283+
string name = foo;
1284+
Assert.That(name, Is.EqualTo("test"));
1285+
}
1286+
}
1287+
1288+
[Test]
1289+
public void TestHasFunctionPointerField()
12801290
{
12811291
using (var hasFunctionPtrField = new HasFunctionPtrField())
12821292
{

tests/CSharp/CSharp.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,11 @@ int Foo::operator --()
104104
return 4;
105105
}
106106

107+
Foo::operator const char*() const
108+
{
109+
return "test";
110+
}
111+
107112
const Foo& Bar::operator[](int i) const
108113
{
109114
return m_foo;

tests/CSharp/CSharp.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ class DLL_API Foo
3838

3939
int operator ++();
4040
int operator --();
41+
operator const char*() const;
4142

4243
bool btest[5];
4344
QFlags<TestFlag> publicFieldMappedToEnum;

0 commit comments

Comments
 (0)