Skip to content

Commit 8a26082

Browse files
authored
Update docs (#173)
1 parent 97acf74 commit 8a26082

7 files changed

Lines changed: 67 additions & 41 deletions

File tree

Docs/node-module.md

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
For a minimal example of this scenario, see
44
[../examples/dotnet-module/](../examples/dotnet-module/).
55

6-
1. Create a .NET Class library project that targets .NET 6 or later.
6+
1. Create a .NET Class library project that targets .NET 6 or later. (.NET 8 for AOT.)
77
```
88
mkdir ExampleModule
99
cd ExampleModule
@@ -20,13 +20,11 @@ For a minimal example of this scenario, see
2020
[build them from source](../README-DEV.md).<br>Then add the `out/pkg` directory as a local
2121
package source in your `NuGet.config`.
2222
23-
**Important**: Edit the project file so that both package reference elements include `PrivateAssets="all"`, and the generator reference includes `OutputItemType="Analyzer" ReferenceOutputAssembly="false"`:
23+
Afterward you should have the two references in your project file:
2424
```xml
2525
<ItemGroup>
26-
<PackageReference Include="Microsoft.JavaScript.NodeApi" Version="0.2.*-*"
27-
PrivateAssets="all" />
28-
<PackageReference Include="Microsoft.JavaScript.NodeApi.Generator" Version="0.2.*-*"
29-
PrivateAssets="all" OutputItemType="Analyzer" ReferenceOutputAssembly="false" />
26+
<PackageReference Include="Microsoft.JavaScript.NodeApi" Version="0.4.*-*" />
27+
<PackageReference Include="Microsoft.JavaScript.NodeApi.Generator" Version="0.4.*-*" />
3028
</ItemGroup>
3129
```
3230

Docs/presentation2.html

Lines changed: 43 additions & 30 deletions
Large diffs are not rendered by default.

Docs/presentation2.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,21 @@ new JSFunction("greeter", (JSValue person) =>
183183
- JS class can extend a .NET class, TS can implement a .NET interface
184184
- .NET class can implement a TS interface
185185

186+
---
187+
## Generics
188+
The JavaScript runtime lacks generics support;
189+
TypeScript generics are compile-time only!
190+
191+
.NET generic types and methods are projected to JS via special `$` functions that accept type args:
192+
```JavaScript
193+
System.Enum.Parse$(System.DayOfWeek)('Tuesday'); // Call generic method
194+
System.Comparer$(System.DateTime).Create(); // Call static method on generic class
195+
const TaskCompletionSourceOfDate = System.TaskCompletionSource$(System.DateTime);
196+
new TaskCompletionSourceOfDate(); // Create instance of generic class
197+
```
198+
199+
... except for generic collections, which are projected using TS generics: `IDictionary<string, int>` -> `Map<string, number>`
200+
186201
---
187202
## .NET Native AOT
188203
- AOT C# code uses .NET hosting APIs to load .NET in-proc.

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ Interop is high-performance and supports TypeScript type-definitions generation,
1010
it is compatible with any Node.js version (without recompiling) or other JavaScript runtime that
1111
supports Node API.
1212

13-
:warning: _**Status: In Development** - Core functionality works, but many things are incomplete,
14-
and it isn't yet all packaged up nicely in a way that can be easily consumed._
13+
:warning: _**Status: Public Preview** - Most functionality works well, though there are some known
14+
limitations around the edges, and there may still be minor breaking API changes._
1515

1616
[Instructions for getting started are below.](#getting-started)
1717

examples/aot-module/aot-module.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
</PropertyGroup>
1010

1111
<ItemGroup>
12-
<PackageReference Include="Microsoft.JavaScript.NodeApi" Version="0.4.*-*" PrivateAssets="none" />
12+
<PackageReference Include="Microsoft.JavaScript.NodeApi" Version="0.4.*-*" />
1313
<PackageReference Include="Microsoft.JavaScript.NodeApi.Generator" Version="0.4.*-*" />
1414
</ItemGroup>
1515

examples/aot-npm-package/lib/aot-npm-package.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
</PropertyGroup>
2121

2222
<ItemGroup>
23-
<PackageReference Include="Microsoft.JavaScript.NodeApi" Version="0.4.*-*" PrivateAssets="none" />
23+
<PackageReference Include="Microsoft.JavaScript.NodeApi" Version="0.4.*-*" />
2424
<PackageReference Include="Microsoft.JavaScript.NodeApi.Generator" Version="0.4.*-*" />
2525
</ItemGroup>
2626

examples/dotnet-module/dotnet-module.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
</PropertyGroup>
99

1010
<ItemGroup>
11-
<PackageReference Include="Microsoft.JavaScript.NodeApi" Version="0.4.*-*" PrivateAssets="all" />
11+
<PackageReference Include="Microsoft.JavaScript.NodeApi" Version="0.4.*-*" />
1212
<PackageReference Include="Microsoft.JavaScript.NodeApi.Generator" Version="0.4.*-*" />
1313
</ItemGroup>
1414

0 commit comments

Comments
 (0)