diff --git a/src/Generator/AST/ASTRecord.cs b/src/Generator/AST/ASTRecord.cs index cd880656..733a08f8 100644 --- a/src/Generator/AST/ASTRecord.cs +++ b/src/Generator/AST/ASTRecord.cs @@ -163,6 +163,18 @@ namespace CppSharp.Generators.AST return false; } + public static bool IsClassReturn(this ASTRecord record) + { + var ancestors = new Stack(); + if(!record.GetAncestors(ref ancestors)) + return false; + + var function = (Function)ancestors.Pop(); + var tagType = function.ReturnType.Type.Desugar() as TagType; + + return tagType?.Declaration is Class; + } + public static bool IsDelegate(this ASTRecord record) { var typedef = record.Object as TypedefDecl; diff --git a/src/Generator/Generators/CLI/CLITypeReferences.cs b/src/Generator/Generators/CLI/CLITypeReferences.cs index db222a2a..be472575 100644 --- a/src/Generator/Generators/CLI/CLITypeReferences.cs +++ b/src/Generator/Generators/CLI/CLITypeReferences.cs @@ -164,7 +164,7 @@ namespace CppSharp.Generators.CLI return false; return record.IsBaseClass() || record.IsFieldValueType() || record.IsDelegate() - || record.IsEnumNestedInClass(); + || record.IsEnumNestedInClass() || record.IsClassReturn(); } public override bool VisitDeclaration(Declaration decl)