-
Notifications
You must be signed in to change notification settings - Fork 10.4k
Description
Background and Motivation
Currently we serialize return results for a InvokeVoidAsync
call from .NET to JS. Given .NET is expecting a void
result, we have no need to serialize these results. Removing this reduces data overhead and avoids issues with unserializable results (ex. window
due to circular references).
This proposal adds a new enum value and empty interface which allows us to indicate return values from JS aren't to be serialized.
Proposed API
namespace Microsoft.JSInterop
{
/// <summary>
/// Describes the type of result expected from a JS interop call.
/// </summary>
public enum JSCallResultType : int
{
Default = 0,
JSObjectReference = 1,
JSStreamReference = 2,
+ JSVoidResult = 3,
}
}
namespace Microsoft.JSInterop
{
+ public interface IJSVoidResult
+ {
+ }
}
Usage Examples
This wouldn't change developer interaction with the code, the changes are primarily internal. Public APIs are needed for testability and cross-project (src/Components) accessibility.
Alternative Designs
Using a public sealed class JSVoidResult
, however we'd still need to make the constructor public (or at the very least non-private) for use in testing / mocking given it's a sealed class. Also by going the interface route, we maintain consistency with the other JSResultTypes which each have associated interfaces.
Risks
Minor change mostly to deal with how the framework internally handles InvokeVoidAsync
.