You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -90,7 +90,7 @@ assembly). The source generator also enables building ahead-of-time compiled lib
90
90
can be called by JavaScript without depending on the .NET Runtime. (More on that below.)
91
91
92
92
### Optionally work directly with JS types in C#
93
-
The class library includes an object model of for JavaScript type system. `JSValue` represents a
93
+
The class library includes an object model for the JavaScript type system. `JSValue` represents a
94
94
value of any type, and there are more types like `JSObject`, `JSArray`, `JSMap`, `JSPromise`, etc.
95
95
C# code can work directly with those types if desired:
96
96
@@ -111,14 +111,16 @@ public static JSPromise JSAsyncExample(JSValue input)
111
111
### Automatic efficient marshaling
112
112
There are two ways to get automatic marshaling between C# and JavaScript types:
113
113
1. Compile a C# class library with `[JSExport]` attributes like the examples above. The source
114
-
generator generates marshaling code that is compiled with the assembly.
114
+
generator produces marshaling code that is compiled with the assembly.
115
115
116
116
2. Load a pre-built .NET assembly, as in the earlier examples. The loader will use reflection to
117
117
scan the APIs, then emit marshaling code on-demand for each type that is referenced by JS. The
118
-
code is logically equivalent to that from the source generator, but is instead emitted as IL
119
-
using the [.NET System.Reflection.Emit APIs](https://learn.microsoft.com/en-us/dotnet/framework/reflection-and-codedom/emitting-dynamic-methods-and-assemblies). So there is a small startup cost
120
-
from that reflection and IL emitting, but subsequent calls to the same APIs may be just as fast
121
-
as the pre-compiled marshaling code (and are just as likely to be JITted).
118
+
dynamic marshalling code is derived from the same expression trees that are used for compile-time
119
+
source-generation, but is generated and at runtime and compiled with
| API compatibility | Broad compatibility with .NET APIs | Limited compatibility with APIs designed to support AOT |
158
160
| Ease of deployment | Requires a matching version of .NET to be installed on the target system | A .NET installation is not required (though some platform libs may be required on Linux/Mac)
159
-
| Size of deployment | Compact - only IL assemblies need to be deployed | Larger due to building necessary runtime code - minimum 3 MB on Windows, ~13 MB on Linux|
161
+
| Size of deployment | Compact - only IL assemblies need to be deployed | Larger due to bundling necessary runtime code - minimum ~3 MB per platform|
0 commit comments