Skip to content

Commit

Permalink
Organize & rename projects and assemblies (microsoft#37)
Browse files Browse the repository at this point in the history
  • Loading branch information
jasongin authored Mar 6, 2023
1 parent 6940ce6 commit 9b7f53d
Show file tree
Hide file tree
Showing 131 changed files with 1,442 additions and 1,225 deletions.
162 changes: 162 additions & 0 deletions Docs/NodeApi-Layers.drawio.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
25 changes: 25 additions & 0 deletions Docs/NodeApi-Layers.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@

## Node API Project Layers

![Node API Layer Diagram](./NodeApi-Layers.drawio.svg)

Solid lines separate assemblies; dotted lines separate namespaces within an assembly. Assemblies may depend only on other assemblies immediately below them. (Namespaces within an assembly may be inter-dependent.)

Note that while the native API layer could be split into a separate assembly from a layering perspective, it is better to keep it together with the main class library:
- Performance should be better: the native API layer includes many simple and frequently-called methods that are likely to be inlined by the compiler. But inlining isn't possible if they are in a separate assembly. Also loading an extra assembly contributes to startup time.
- Practically, the native API layer is not very useful on its own, so it would just be an inconvenience to always have to bundle it with the main class library.

Following is a description of the layered assemblies and namespaces, from the bottom up.

### Microsoft.JavaScript.NodeApi assembly (.NET & AOT)
- `Microsoft.JavaScript.NodeApi.Native` namespace - Exposes all the `napi_*` APIs for JavaScript / Node.js runtime interop.
- `Microsoft.JavaScript.NodeApi` namespace - Core JavaScript value types, collection types, along with supporting types like `JSException`, `JSExportAttribute`, `JSCallbackArgs`, `JSReference`, `JSPropertyDescriptor`.
- `Microsoft.JavaScript.NodeApi.Interop` namespace - Types that support richer interop between .NET and JavaScript, including `JSContext`, The `*Builder*` types, and `JSCallbackOverload`. Also includes threading support in `JSSynchronizationContext`, `JSAsyncScope`.
- `Microsoft.JavaScript.NodeApi.DotNetHost` namespace - Only the `NativeHost` class must be in the main assembly because it gets AOT-compiled. (The class doesn't need to have `public` accessibility though.)

### Microsoft.JavaScript.NodeApi.DotNetHost assembly (.NET only)
- `Microsoft.JavaScript.NodeApi.DotNetHost` namespace - Supports static binding to .NET assemblies built as Node API modules as well as dynamic binding to arbitrary .NET assemblies / APIs. Includes `ManagedHost`, `JSMarshaler`, and supporting types.

### Microsoft.JavaScript.NodeApi.Generator assembly (.NET only)
- `Microsoft.JavaScript.NodeApi.Generator.CSharp` namespace - A C# source generator that emits code at compile time that enables JavaScript to statically bind to .NET APIs in the compiled assembly.
- `Microsoft.JavaScript.NodeApi.Generator.TypeScript` - A command-line tool that generates TypeScript type definitions for either statically- or dynamically-bound .NET assemblies.
12 changes: 9 additions & 3 deletions napi-dotnet.sln → NodeApi.sln
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.0.31903.59
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NodeApi.Test", "Test\NodeApi.Test.csproj", "{24A49A30-7C49-4F7E-89C4-E18F40AAA23F}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NodeApi.Test", "test\NodeApi.Test.csproj", "{24A49A30-7C49-4F7E-89C4-E18F40AAA23F}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NodeApi.Runtime", "Runtime\NodeApi.Runtime.csproj", "{BBB30CEB-CCF6-4E5C-822F-FF73502D86B2}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NodeApi", "src\NodeApi\NodeApi.csproj", "{BBB30CEB-CCF6-4E5C-822F-FF73502D86B2}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NodeApi.Generator", "Generator\NodeApi.Generator.csproj", "{BCD164BC-9F26-4E44-888E-52B18C6670FD}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NodeApi.Generator", "src\NodeApi.Generator\NodeApi.Generator.csproj", "{BCD164BC-9F26-4E44-888E-52B18C6670FD}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Top Level Files", "Top Level Files", "{56FAAFF0-3EFF-4925-A9B6-5C9760D780DA}"
ProjectSection(SolutionItems) = preProject
Expand All @@ -27,6 +27,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "GitHub Workflows", "GitHub
.github\workflows\build.yml = .github\workflows\build.yml
EndProjectSection
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NodeApi.DotNetHost", "src\NodeApi.DotNetHost\NodeApi.DotNetHost.csproj", "{50F53625-D418-4A39-8B3D-842D38229D40}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -45,6 +47,10 @@ Global
{BCD164BC-9F26-4E44-888E-52B18C6670FD}.Debug|Any CPU.Build.0 = Debug|Any CPU
{BCD164BC-9F26-4E44-888E-52B18C6670FD}.Release|Any CPU.ActiveCfg = Release|Any CPU
{BCD164BC-9F26-4E44-888E-52B18C6670FD}.Release|Any CPU.Build.0 = Release|Any CPU
{50F53625-D418-4A39-8B3D-842D38229D40}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{50F53625-D418-4A39-8B3D-842D38229D40}.Debug|Any CPU.Build.0 = Debug|Any CPU
{50F53625-D418-4A39-8B3D-842D38229D40}.Release|Any CPU.ActiveCfg = Release|Any CPU
{50F53625-D418-4A39-8B3D-842D38229D40}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
Loading

0 comments on commit 9b7f53d

Please sign in to comment.