Skip to content

Commit 772064b

Browse files
authored
Fix generator bug with non-public nested types (#374)
1 parent 1e6eea5 commit 772064b

2 files changed

Lines changed: 7 additions & 1 deletion

File tree

src/NodeApi.Generator/ModuleGenerator.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -475,7 +475,8 @@ private void ExportType(
475475
$"{nameof(JSPropertyAttributes)}.{nameof(JSPropertyAttributes.Enumerable)}";
476476

477477
// Declare nested types first, so they can be exported as static properties of this type.
478-
foreach (INamedTypeSymbol nestedType in type.GetTypeMembers())
478+
foreach (INamedTypeSymbol nestedType in type.GetTypeMembers()
479+
.Where((t) => t.DeclaredAccessibility == Accessibility.Public))
479480
{
480481
ExportType(ref s, nestedType, GetExportName(nestedType));
481482
}

test/TestCases/napi-dotnet/ComplexTypes.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,11 @@ public NestedClass(string value)
199199

200200
public string Value { get; set; }
201201
}
202+
203+
// Non-public nested types should not be exported.
204+
internal class PrivateNestedClass
205+
{
206+
}
202207
}
203208

204209
[JSExport]

0 commit comments

Comments
 (0)