Skip to content

Commit

Permalink
Fix generator bug with non-public nested types (#374)
Browse files Browse the repository at this point in the history
  • Loading branch information
jasongin authored Sep 4, 2024
1 parent 1e6eea5 commit 772064b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/NodeApi.Generator/ModuleGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,8 @@ private void ExportType(
$"{nameof(JSPropertyAttributes)}.{nameof(JSPropertyAttributes.Enumerable)}";

// Declare nested types first, so they can be exported as static properties of this type.
foreach (INamedTypeSymbol nestedType in type.GetTypeMembers())
foreach (INamedTypeSymbol nestedType in type.GetTypeMembers()
.Where((t) => t.DeclaredAccessibility == Accessibility.Public))
{
ExportType(ref s, nestedType, GetExportName(nestedType));
}
Expand Down
5 changes: 5 additions & 0 deletions test/TestCases/napi-dotnet/ComplexTypes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,11 @@ public NestedClass(string value)

public string Value { get; set; }
}

// Non-public nested types should not be exported.
internal class PrivateNestedClass
{
}
}

[JSExport]
Expand Down

0 comments on commit 772064b

Please sign in to comment.