diff --git a/src/NodeApi.Generator/ModuleGenerator.cs b/src/NodeApi.Generator/ModuleGenerator.cs index feb254b2..1aeb96fb 100644 --- a/src/NodeApi.Generator/ModuleGenerator.cs +++ b/src/NodeApi.Generator/ModuleGenerator.cs @@ -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)); } diff --git a/test/TestCases/napi-dotnet/ComplexTypes.cs b/test/TestCases/napi-dotnet/ComplexTypes.cs index 525e8a0b..324eaa14 100644 --- a/test/TestCases/napi-dotnet/ComplexTypes.cs +++ b/test/TestCases/napi-dotnet/ComplexTypes.cs @@ -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]