Fixes https://github.com/mono/CppSharp/issues/1205.
@ -438,7 +438,11 @@ namespace CppSharp.AST
public override bool Equals(object obj)
{
var typedef = obj as TypedefType;
return Declaration.Type.Equals(typedef == null ? obj : typedef.Declaration.Type);
if (typedef == null)
return false;
return Declaration.OriginalName == typedef.Declaration.OriginalName &&
Declaration.Type.Equals(typedef.Declaration.Type);
}
public override int GetHashCode() =>
@ -253,7 +253,7 @@ namespace CppSharp.Generators.CSharp
var decl = typedef.Declaration;
TypeMap typeMap;
if (TypeMapDatabase.FindTypeMap(decl.Type, out typeMap))
if (TypeMapDatabase.FindTypeMap(typedef, out typeMap))
typeMap.Type = typedef;
@ -93,7 +93,7 @@ namespace CppSharp.Types
PrintLogicalNames = true
};
foreach (var resolveTypeDefs in new[] { true, false })
foreach (var resolveTypeDefs in new[] { false, true })
foreach (var typePrintScopeKind in
new[] { TypePrintScopeKind.Local, TypePrintScopeKind.Qualified })
@ -1285,4 +1285,10 @@ public unsafe class CSharpTests : GeneratorTestFixture
public override int Function() => 10;
[Test]
public void TestTypemapTypedefParam()
Assert.That(CSharp.CSharp.TakeTypemapTypedefParam(false), Is.False);
@ -1564,3 +1564,8 @@ const char*& takeConstCharStarRef(const char*& c)
return c;
boolean_t takeTypemapTypedefParam(boolean_t b)
return b;
@ -95,6 +95,24 @@ namespace CppSharp.Tests
#region Type Maps
[TypeMap("boolean_t")]
public class BooleanTypeMap : TypeMap
public override Type CSharpSignatureType(TypePrinterContext ctx)
return new BuiltinType(PrimitiveType.Bool);
public override void CSharpMarshalToNative(CSharpMarshalContext ctx)
ctx.Return.Write(ctx.Parameter.Name);
public override void CSharpMarshalToManaged(CSharpMarshalContext ctx)
ctx.Return.Write(ctx.ReturnVarName);
[TypeMap("QFlags")]
public class QFlags : TypeMap
@ -1321,3 +1321,7 @@ struct {
} example;
} root;
} kotlin;
typedef int boolean_t;
DLL_API boolean_t takeTypemapTypedefParam(boolean_t b);