Skip to content

Commit e2a23b8

Browse files
committed
Fixed the generated C# when returning a non-const char*.
Signed-off-by: Dimitar Dobrev <[email protected]>
1 parent c688330 commit e2a23b8

File tree

4 files changed

+16
-1
lines changed

4 files changed

+16
-1
lines changed

src/AST/Type.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -447,7 +447,8 @@ public override bool Equals(object obj)
447447
return Declaration.Type.Equals(typedef == null ? obj : typedef.Declaration.Type);
448448
}
449449

450-
public override int GetHashCode() => Declaration.Type.GetHashCode();
450+
public override int GetHashCode() =>
451+
Declaration.OriginalName.GetHashCode() ^ Declaration.Type.GetHashCode();
451452
}
452453

453454
/// <summary>

tests/CSharp/CSharp.Tests.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,8 @@ public void TestUncompilableCode()
9494
{
9595
}
9696

97+
CSharp.CSharp.ReturnCharPointer();
98+
9799
#pragma warning restore 0168
98100
#pragma warning restore 0219
99101
}

tests/CSharp/CSharp.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1542,3 +1542,12 @@ void InterfaceTester::setInterface(SimpleInterface* i)
15421542
{
15431543
interface = i;
15441544
}
1545+
1546+
void va_listFunction(va_list v)
1547+
{
1548+
}
1549+
1550+
char* returnCharPointer()
1551+
{
1552+
return 0;
1553+
}

tests/CSharp/CSharp.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1298,3 +1298,6 @@ class DLL_API InterfaceTester
12981298
private:
12991299
SimpleInterface* interface;
13001300
};
1301+
1302+
DLL_API void va_listFunction(va_list v);
1303+
DLL_API char* returnCharPointer();

0 commit comments

Comments
 (0)