Skip to content

Commit

Permalink
Fix GetEffectiveNamespace not going up the tree properly (#1909)
Browse files Browse the repository at this point in the history
Also replaced recursion with while loop
  • Loading branch information
duckdoom5 authored Feb 6, 2025
1 parent e4979d1 commit cbaf344
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/Generator/Generators/CLI/CLITypeReferences.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,15 @@ public CLITypeReference GetTypeReference(Declaration decl)

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)
Expand Down

0 comments on commit cbaf344

Please sign in to comment.