Skip to content

Commit

Permalink
Fix NRE in source generator for methods with arrays (#278)
Browse files Browse the repository at this point in the history
  • Loading branch information
jasongin authored Apr 16, 2024
1 parent c0667b5 commit 154d3d0
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/NodeApi.Generator/SourceGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,15 @@ public enum DiagnosticId
public static string GetNamespace(ISymbol symbol)
{
string ns = string.Empty;

// ContainingNamespace may be null for constructed types like arrays.
for (INamespaceSymbol s = symbol.ContainingNamespace;
!s.IsGlobalNamespace;
s?.IsGlobalNamespace == false;
s = s.ContainingNamespace)
{
ns = s.Name + (ns.Length > 0 ? "." + ns : string.Empty);
}

return ns;
}

Expand Down

0 comments on commit 154d3d0

Please sign in to comment.