Skip to content

Commit

Permalink
Update docs (#173)
Browse files Browse the repository at this point in the history
  • Loading branch information
jasongin authored Nov 10, 2023
1 parent 97acf74 commit 8a26082
Show file tree
Hide file tree
Showing 7 changed files with 67 additions and 41 deletions.
10 changes: 4 additions & 6 deletions Docs/node-module.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
For a minimal example of this scenario, see
[../examples/dotnet-module/](../examples/dotnet-module/).

1. Create a .NET Class library project that targets .NET 6 or later.
1. Create a .NET Class library project that targets .NET 6 or later. (.NET 8 for AOT.)
```
mkdir ExampleModule
cd ExampleModule
Expand All @@ -20,13 +20,11 @@ For a minimal example of this scenario, see
[build them from source](../README-DEV.md).<br>Then add the `out/pkg` directory as a local
package source in your `NuGet.config`.
**Important**: Edit the project file so that both package reference elements include `PrivateAssets="all"`, and the generator reference includes `OutputItemType="Analyzer" ReferenceOutputAssembly="false"`:
Afterward you should have the two references in your project file:
```xml
<ItemGroup>
<PackageReference Include="Microsoft.JavaScript.NodeApi" Version="0.2.*-*"
PrivateAssets="all" />
<PackageReference Include="Microsoft.JavaScript.NodeApi.Generator" Version="0.2.*-*"
PrivateAssets="all" OutputItemType="Analyzer" ReferenceOutputAssembly="false" />
<PackageReference Include="Microsoft.JavaScript.NodeApi" Version="0.4.*-*" />
<PackageReference Include="Microsoft.JavaScript.NodeApi.Generator" Version="0.4.*-*" />
</ItemGroup>
```
Expand Down
73 changes: 43 additions & 30 deletions Docs/presentation2.html

Large diffs are not rendered by default.

15 changes: 15 additions & 0 deletions Docs/presentation2.md
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,21 @@ new JSFunction("greeter", (JSValue person) =>
- JS class can extend a .NET class, TS can implement a .NET interface
- .NET class can implement a TS interface

---
## Generics
The JavaScript runtime lacks generics support;
TypeScript generics are compile-time only!

.NET generic types and methods are projected to JS via special `$` functions that accept type args:
```JavaScript
System.Enum.Parse$(System.DayOfWeek)('Tuesday'); // Call generic method
System.Comparer$(System.DateTime).Create(); // Call static method on generic class
const TaskCompletionSourceOfDate = System.TaskCompletionSource$(System.DateTime);
new TaskCompletionSourceOfDate(); // Create instance of generic class
```

... except for generic collections, which are projected using TS generics: `IDictionary<string, int>` -> `Map<string, number>`

---
## .NET Native AOT
- AOT C# code uses .NET hosting APIs to load .NET in-proc.
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ Interop is high-performance and supports TypeScript type-definitions generation,
it is compatible with any Node.js version (without recompiling) or other JavaScript runtime that
supports Node API.

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

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

Expand Down
2 changes: 1 addition & 1 deletion examples/aot-module/aot-module.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.JavaScript.NodeApi" Version="0.4.*-*" PrivateAssets="none" />
<PackageReference Include="Microsoft.JavaScript.NodeApi" Version="0.4.*-*" />
<PackageReference Include="Microsoft.JavaScript.NodeApi.Generator" Version="0.4.*-*" />
</ItemGroup>

Expand Down
2 changes: 1 addition & 1 deletion examples/aot-npm-package/lib/aot-npm-package.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.JavaScript.NodeApi" Version="0.4.*-*" PrivateAssets="none" />
<PackageReference Include="Microsoft.JavaScript.NodeApi" Version="0.4.*-*" />
<PackageReference Include="Microsoft.JavaScript.NodeApi.Generator" Version="0.4.*-*" />
</ItemGroup>

Expand Down
2 changes: 1 addition & 1 deletion examples/dotnet-module/dotnet-module.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.JavaScript.NodeApi" Version="0.4.*-*" PrivateAssets="all" />
<PackageReference Include="Microsoft.JavaScript.NodeApi" Version="0.4.*-*" />
<PackageReference Include="Microsoft.JavaScript.NodeApi.Generator" Version="0.4.*-*" />
</ItemGroup>

Expand Down

0 comments on commit 8a26082

Please sign in to comment.