From b902878514d3141640ae65b7fa543fee088f8a53 Mon Sep 17 00:00:00 2001 From: ds5678 <49847914+ds5678@users.noreply.github.com> Date: Tue, 28 Oct 2025 12:31:22 -0700 Subject: [PATCH 1/2] Fix infinite recursion in IsType --- sources/ClangSharp.PInvokeGenerator/PInvokeGenerator.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sources/ClangSharp.PInvokeGenerator/PInvokeGenerator.cs b/sources/ClangSharp.PInvokeGenerator/PInvokeGenerator.cs index 37e070a4..9c7903ef 100644 --- a/sources/ClangSharp.PInvokeGenerator/PInvokeGenerator.cs +++ b/sources/ClangSharp.PInvokeGenerator/PInvokeGenerator.cs @@ -5521,7 +5521,8 @@ private static bool IsType(Cursor? cursor, Type type, [MaybeNullWhen(false)] } else if (templateSpecializationType.TemplateName.AsTemplateDecl is TemplateDecl templateDecl) { - if (templateDecl.TemplatedDecl is TypeDecl typeDecl) + // We exclude InjectedClassNameType here to avoid infinite recursion. + if (templateDecl.TemplatedDecl is TypeDecl { TypeForDecl: not InjectedClassNameType } typeDecl) { return IsType(cursor, typeDecl.TypeForDecl, out value); } From 4567ec9d889bde81cd47425fbd54bc9e6f9ab917 Mon Sep 17 00:00:00 2001 From: Jeremy Pritts <49847914+ds5678@users.noreply.github.com> Date: Tue, 28 Oct 2025 13:40:30 -0700 Subject: [PATCH 2/2] Update sources/ClangSharp.PInvokeGenerator/PInvokeGenerator.cs Co-authored-by: Tanner Gooding --- sources/ClangSharp.PInvokeGenerator/PInvokeGenerator.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sources/ClangSharp.PInvokeGenerator/PInvokeGenerator.cs b/sources/ClangSharp.PInvokeGenerator/PInvokeGenerator.cs index 9c7903ef..0d2fc680 100644 --- a/sources/ClangSharp.PInvokeGenerator/PInvokeGenerator.cs +++ b/sources/ClangSharp.PInvokeGenerator/PInvokeGenerator.cs @@ -5522,7 +5522,7 @@ private static bool IsType(Cursor? cursor, Type type, [MaybeNullWhen(false)] else if (templateSpecializationType.TemplateName.AsTemplateDecl is TemplateDecl templateDecl) { // We exclude InjectedClassNameType here to avoid infinite recursion. - if (templateDecl.TemplatedDecl is TypeDecl { TypeForDecl: not InjectedClassNameType } typeDecl) + if ((templateDecl.TemplatedDecl is TypeDecl typeDecl) && (typeDecl.TypeForDecl is not InjectedClassNameType )) { return IsType(cursor, typeDecl.TypeForDecl, out value); }