System.Runtime.InteropServices.JavaScript Namespace

Contains JSImportAttribute and JSExportAttribute, which can be used to interop with JavaScript when running in the browser or other WASM architectures.

Classes

JSException

Represents an exception initiated from the JavaScript interop code.

JSExportAttribute

Indicates that a source generator should export the attributed method to JavaScript and create thunks necessary to marshal its arguments and any return value or thrown exception.

JSHost

Represents the JavaScript host environment where the .NET runtime is currently operating.

JSImportAttribute

Indicates that the JSImport source generator should create a managed wrapper to invoke a specific imported JavaScript function and marshal its arguments, return values, and exceptions.

JSMarshalAsAttribute<T>

Specifies the JavaScript type associated with a managed argument or return value. The JSImport generator will use this information to marshal data between the JavaScript and managed environments.

JSObject

Represents a reference to an object in the JavaScript host environment and enables interaction with it as a proxy.

JSType

Used as the generic argument for JSMarshalAsAttribute<T> to express the expected JavaScript type, which should be the source or result of argument marshalling.

JSType.Any

Dynamically selects the most appropriate JavaScript or managed type for each argument value at run time.

JSType.Array<T>

Marshals as a copy of the JavaScript Array or TypedArray type.

JSType.BigInt

Marshal as JavaScript BigInt type.

JSType.Boolean

Marshal as JavaScript Boolean type.

JSType.Date

Marshal as JavaScript Date type.

JSType.Discard

Suppresses marshalling of the JavaScript function's return value and discards it.

JSType.Error

Marshals as the JavaScript Error type.

JSType.Function

Marshals as the JavaScript Function type.

JSType.Function<T>

Marshals as the JavaScript Function type.

JSType.Function<T1,T2>

Marshals as the JavaScript Function type.

JSType.Function<T1,T2,T3>

Marshals as the JavaScript Function type.

JSType.Function<T1,T2,T3,T4>

Marshals as the JavaScript Function type.

JSType.MemoryView

Marshals a managed Span or ArraySegment as a JavaScript wrapper object that provides access to the managed memory.

JSType.Number

Marshal as JavaScript Number type.

JSType.Object

Marshal as JavaScript Object type.

JSType.Promise<T>

Marshal as JavaScript Promise type.

JSType.String

Marshal as JavaScript String type.

JSType.Void

Asserts that a JavaScript function should have no return value.