From cbaf344398b4dcab35255748275be090eae68374 Mon Sep 17 00:00:00 2001 From: Jelle Date: Thu, 6 Feb 2025 16:35:00 +0000 Subject: [PATCH] Fix `GetEffectiveNamespace` not going up the tree properly (#1909) Also replaced recursion with while loop --- src/Generator/Generators/CLI/CLITypeReferences.cs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/Generator/Generators/CLI/CLITypeReferences.cs b/src/Generator/Generators/CLI/CLITypeReferences.cs index 885279e2..1ff72cf7 100644 --- a/src/Generator/Generators/CLI/CLITypeReferences.cs +++ b/src/Generator/Generators/CLI/CLITypeReferences.cs @@ -71,14 +71,15 @@ namespace CppSharp.Generators.CLI static Namespace GetEffectiveNamespace(Declaration decl) { - if (decl == null || decl.Namespace == null) + if (decl == null) return null; - var @namespace = decl.Namespace as Namespace; - if (@namespace != null) - return @namespace; + var declContext = decl.Namespace; - return GetEffectiveNamespace(@namespace); + while (declContext != null && declContext is not Namespace) + declContext = declContext.Namespace; + + return declContext as Namespace; } public void Process(Namespace @namespace, bool filterNamespaces = false)