Skip to content

Commit

Permalink
[wasm] add missing API xml doc (dotnet#76196)
Browse files Browse the repository at this point in the history
* add missing xml doc
Co-authored-by: Carlos Sanchez <[email protected]>
  • Loading branch information
pavelsavara authored Oct 3, 2022
1 parent 200f533 commit ff8ac3b
Show file tree
Hide file tree
Showing 30 changed files with 370 additions and 81 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ public static class JSHost
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
public sealed class JSFunctionBinding
{
internal JSFunctionBinding() { throw null; }
public static void InvokeJS(JSFunctionBinding signature, Span<JSMarshalerArgument> arguments) { throw null; }
public static JSFunctionBinding BindJSFunction(string functionName, string moduleName, ReadOnlySpan<JSMarshalerType> signatures) { throw null; }
public static JSFunctionBinding BindManagedFunction(string fullyQualifiedName, int signatureHash, ReadOnlySpan<JSMarshalerType> signatures) { throw null; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
namespace System.Runtime.InteropServices.JavaScript
{
/// <summary>
/// Represents an Exception initiated from the JavaScript interop code.
/// Represents an exception initiated from the JavaScript interop code.
/// </summary>
[SupportedOSPlatform("browser")] // @kg: Do we really need to platform-lock JSException?
public sealed class JSException : Exception
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
namespace System.Runtime.InteropServices.JavaScript
{
/// <summary>
/// Attribute used to indicate a source generator should export a method to JavaScript and create thunks necessary to marshal its arguments along with any return value or thrown exception.
/// For marshaling arguments of complex types <seealso cref="JSMarshalAsAttribute{T}"/>.
/// 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.
/// </summary>
/// <remarks>
/// For marshaling arguments of complex types <see cref="JSMarshalAsAttribute{T}" />.
/// This attribute is meaningless if the source generator associated with it is not enabled.
/// The current built-in source generator only supports C# and only supplies an implementation when
/// The current built-in source generator only supports C# and only supplies an implementation when applied to static, non-partial, or non-generic methods.
/// applied to static, non-partial, non-generic methods.
/// Exported methods cannot be trimmed by the linker.
/// </remarks>
Expand All @@ -20,7 +20,7 @@ namespace System.Runtime.InteropServices.JavaScript
public sealed class JSExportAttribute : Attribute
{
/// <summary>
/// Initializes a new instance of the <see cref="JSExportAttribute"/>.
/// Initializes a new instance of the <see cref="JSExportAttribute" /> class.
/// </summary>
public JSExportAttribute()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,13 @@ namespace System.Runtime.InteropServices.JavaScript
[CLSCompliant(false)]
[SupportedOSPlatform("browser")]
[EditorBrowsable(EditorBrowsableState.Never)]
public sealed partial class JSFunctionBinding
public sealed class JSFunctionBinding
{
/// <summary>
/// This API supports JSImport infrastructure and is not intended to be used directly from your code.
/// </summary>
internal JSFunctionBinding() { }

#region intentionally opaque internal structure
internal unsafe JSBindingHeader* Header;
internal unsafe JSBindingType* Sigs;// points to first arg, not exception, not result
Expand Down Expand Up @@ -118,6 +123,8 @@ internal unsafe JSBindingType this[int position]
/// Invokes a previously bound JavaScript function using the provided span to transport argument and return values.
/// This API supports JSImport infrastructure and is not intended to be used directly from your code.
/// </summary>
/// <param name="signature">Generated metadata about the method signature used for marshaling.</param>
/// <param name="arguments">The intermediate buffer with marshalled arguments.</param>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void InvokeJS(JSFunctionBinding signature, Span<JSMarshalerArgument> arguments)
{
Expand All @@ -128,6 +135,11 @@ public static void InvokeJS(JSFunctionBinding signature, Span<JSMarshalerArgumen
/// Locates and binds a JavaScript function given name and module so that it can later be invoked by managed callers.
/// This API supports JSImport infrastructure and is not intended to be used directly from your code.
/// </summary>
/// <param name="functionName">The name of the exported JavaScript function.</param>
/// <param name="moduleName">The name of the ES6 module.</param>
/// <param name="signatures">The metadata about the signature of the marshaled parameters.</param>
/// <returns>The method metadata.</returns>
/// <exception cref="PlatformNotSupportedException">The method is executed on an architecture other than WebAssembly.</exception>
// JavaScriptExports need to be protected from trimming because they are used from C/JS code which IL linker can't see
[DynamicDependency(DynamicallyAccessedMemberTypes.PublicMethods, "System.Runtime.InteropServices.JavaScript.JavaScriptExports", "System.Runtime.InteropServices.JavaScript")]
// TODO make this DynamicDependency conditional
Expand All @@ -144,6 +156,11 @@ public static JSFunctionBinding BindJSFunction(string functionName, string modul
/// Binds a specific managed function wrapper so that it can later be invoked by JavaScript callers.
/// This API supports JSImport infrastructure and is not intended to be used directly from your code.
/// </summary>
/// <param name="fullyQualifiedName">The fully qualified name of the exported method.</param>
/// <param name="signatureHash">The hash of the signature metadata.</param>
/// <param name="signatures">The metadata about the signature of the marshaled parameters.</param>
/// <returns>The method metadata.</returns>
/// <exception cref="PlatformNotSupportedException">The method is executed on architecture other than WebAssembly.</exception>
public static JSFunctionBinding BindManagedFunction(string fullyQualifiedName, int signatureHash, ReadOnlySpan<JSMarshalerType> signatures)
{
if (RuntimeInformation.OSArchitecture != Architecture.Wasm)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ namespace System.Runtime.InteropServices.JavaScript
public static partial class JSHost
{
/// <summary>
/// Returns a proxy for the <see href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/globalThis">globalThis</see> JavaScript host object.
/// Returns a proxy for the <see href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/globalThis">globalThis</see> JavaScript host object.
/// </summary>
public static JSObject GlobalThis
{
Expand All @@ -37,8 +37,8 @@ public static JSObject DotnetInstance
}

/// <summary>
/// Download and instantiate an ES6 module from the provided URL, via the JavaScript host's <see href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/import">dynamic import API</see>.
/// If a module with the provided <paramref name="moduleName"/> has previously been instantiated, it will be returned instead.
/// Downloads and instantiates an ES6 module from the provided URL, via the JavaScript host's <see href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Operators/import">dynamic import API</see>.
/// If a module with the provided <paramref name="moduleName" /> has previously been instantiated, it will be returned instead.
/// </summary>
/// <param name="moduleName">Globally unique identifier of the ES6 module, which is used by <see cref="JSImportAttribute(string, string)"/>.</param>
/// <param name="moduleUrl">The location of the module file.</param>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,11 @@ namespace System.Runtime.InteropServices.JavaScript
{
/// <summary>
/// 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.
/// To configure the marshaling behavior for specific values, <seealso cref="JSMarshalAsAttribute{T}"/>.
/// To configure the marshalling behavior for specific values, <see cref="JSMarshalAsAttribute{T}" />.
/// </summary>
/// <remarks>
/// This attribute is meaningless if the source generator associated with it is not enabled.
/// The current built-in source generator only supports C# and only supplies an implementation when
/// applied to static, partial, non-generic methods.
/// The current built-in source generator only supports C# and only supplies an implementation when applied to static, partial, non-generic methods.
/// </remarks>
/// <example>
/// <code>
Expand All @@ -29,34 +28,34 @@ namespace System.Runtime.InteropServices.JavaScript
public sealed class JSImportAttribute : Attribute
{
/// <summary>
/// The name of the target JavaScript function. This name will be used as a key to locate the function in the module.
/// Functions nested inside of objects can be referred to by using the dot operator to connect one or more names.
/// Gets the name of the target JavaScript function. This name will be used as a key to locate the function in the module.
/// </summary>
/// <remarks>Functions nested inside of objects can be referred to by using the dot operator to connect one or more names.</remarks>
public string FunctionName { get; }

/// <summary>
/// Globally unique identifier of the ES6 module, if any, that contains the function. The module must be loaded via <see cref="JSHost.ImportAsync(string, string, Threading.CancellationToken)"/> before any attempt to invoke the function.
/// Gets the globally unique identifier of the ES6 module, if any, that contains the function. The module must be loaded via <see cref="JSHost.ImportAsync(string, string, Threading.CancellationToken)" /> before any attempt to invoke the function.
/// </summary>
public string? ModuleName { get; }

/// <summary>
/// Initializes a new instance of the <see cref="JSImportAttribute"/>.
/// Initializes a new instance of the <see cref="JSImportAttribute" /> class.
/// </summary>
/// <param name="functionName">Name of the function to be bound in the module. It allows dots for nested objects.</param>
/// <param name="functionName">The name of the function to be bound in the module. Use dots for nested objects.</param>
public JSImportAttribute(string functionName)
{
FunctionName = functionName;
}

/// <summary>
/// Initializes a new instance of the <see cref="JSImportAttribute"/>.
/// Initializes a new instance of the <see cref="JSImportAttribute" /> class.
/// </summary>
/// <param name="functionName">
/// The name of the target JavaScript function. This name will be used as a key to locate the function in the module.
/// Functions nested inside of objects can be referred to by using the dot operator to connect one or more names.
/// </param>
/// <param name="moduleName">
/// Globally unique identifier of the ES6 module, if any, that contains the function. The module must be loaded via <see cref="JSHost.ImportAsync(string, string, Threading.CancellationToken)"/> before any attempt to invoke the function.
/// Globally unique identifier of the ES6 module, if any, that contains the function. The module must be loaded via <see cref="JSHost.ImportAsync(string, string, Threading.CancellationToken)" /> before any attempt to invoke the function.
/// </param>
public JSImportAttribute(string functionName, string moduleName)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace System.Runtime.InteropServices.JavaScript
/// 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.
/// </summary>
/// <typeparam name="T">One of the types defined in <see cref="JSType"/>, for example <see cref="JSType.MemoryView"/></typeparam>
/// <typeparam name="T">One of the types defined in <see cref="JSType" />, for example <see cref="JSType.MemoryView" />.</typeparam>
/// <example>
/// <code>
/// [JSImport("createFunction", "my-math-helper")]
Expand All @@ -22,7 +22,7 @@ namespace System.Runtime.InteropServices.JavaScript
public sealed class JSMarshalAsAttribute<T> : Attribute where T : JSType
{
/// <summary>
/// Create a <see cref="JSMarshalAsAttribute{T}" /> configured by generic parameters of <see cref="JSType" />.
/// Initializes a new instance of <see cref="JSMarshalAsAttribute{T}" /> configured by generic parameters of <see cref="JSType" />.
/// </summary>
public JSMarshalAsAttribute() { }
}
Expand Down
Loading

0 comments on commit ff8ac3b

Please sign in to comment.