JSInterop nullability PR feedback (#25114)
This commit is contained in:
parent
ecf2a23d3d
commit
50815ed598
|
|
@ -15,6 +15,6 @@ namespace Microsoft.JSInterop
|
|||
/// <param name="identifier">An identifier for the function to invoke. For example, the value <c>"someScope.someFunction"</c> will invoke the function <c>window.someScope.someFunction</c>.</param>
|
||||
/// <param name="args">JSON-serializable arguments.</param>
|
||||
/// <returns>An instance of <typeparamref name="T"/> obtained by JSON-deserializing the return value.</returns>
|
||||
T Invoke<T>(string identifier, params object[] args);
|
||||
T Invoke<T>(string identifier, params object?[]? args);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ namespace Microsoft.JSInterop
|
|||
/// <param name="identifier">An identifier for the function to invoke. For example, the value <c>"someScope.someFunction"</c> will invoke the function <c>window.someScope.someFunction</c>.</param>
|
||||
/// <param name="args">JSON-serializable arguments.</param>
|
||||
/// <returns>An instance of <typeparamref name="TValue"/> obtained by JSON-deserializing the return value.</returns>
|
||||
ValueTask<TValue> InvokeAsync<TValue>(string identifier, object[] args);
|
||||
ValueTask<TValue> InvokeAsync<TValue>(string identifier, object?[]? args);
|
||||
|
||||
/// <summary>
|
||||
/// Invokes the specified JavaScript function asynchronously.
|
||||
|
|
@ -35,6 +35,6 @@ namespace Microsoft.JSInterop
|
|||
/// </param>
|
||||
/// <param name="args">JSON-serializable arguments.</param>
|
||||
/// <returns>An instance of <typeparamref name="TValue"/> obtained by JSON-deserializing the return value.</returns>
|
||||
ValueTask<TValue> InvokeAsync<TValue>(string identifier, CancellationToken cancellationToken, object[] args);
|
||||
ValueTask<TValue> InvokeAsync<TValue>(string identifier, CancellationToken cancellationToken, object?[]? args);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -136,7 +136,7 @@ namespace Microsoft.JSInterop.Infrastructure
|
|||
Type[] parameterTypes;
|
||||
if (objectReference is null)
|
||||
{
|
||||
assemblyKey = new AssemblyKey(assemblyName);
|
||||
assemblyKey = new AssemblyKey(assemblyName!);
|
||||
(methodInfo, parameterTypes) = GetCachedMethodInfo(assemblyKey, methodIdentifier);
|
||||
}
|
||||
else
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ namespace Microsoft.JSInterop.Infrastructure
|
|||
/// <param name="methodIdentifier">The identifier of the method to be invoked.</param>
|
||||
/// <param name="dotNetObjectId">The object identifier for instance method calls.</param>
|
||||
/// <param name="callId">The call identifier.</param>
|
||||
public DotNetInvocationInfo(string assemblyName, string methodIdentifier, long dotNetObjectId, string callId)
|
||||
public DotNetInvocationInfo(string? assemblyName, string methodIdentifier, long dotNetObjectId, string? callId)
|
||||
{
|
||||
CallId = callId;
|
||||
AssemblyName = assemblyName;
|
||||
|
|
@ -27,7 +27,7 @@ namespace Microsoft.JSInterop.Infrastructure
|
|||
/// Gets the name of the assembly containing the method.
|
||||
/// Only one of <see cref="DotNetObjectId"/> or <see cref="AssemblyName"/> may be specified.
|
||||
/// </summary>
|
||||
public string AssemblyName { get; }
|
||||
public string? AssemblyName { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the identifier of the method to be invoked. This is the value specified in the <see cref="JSInvokableAttribute"/>.
|
||||
|
|
@ -43,6 +43,6 @@ namespace Microsoft.JSInterop.Infrastructure
|
|||
/// <summary>
|
||||
/// Gets the call identifier. This value is <see langword="null"/> when the client does not expect a value to be returned.
|
||||
/// </summary>
|
||||
public string CallId { get; }
|
||||
public string? CallId { get; }
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ namespace Microsoft.JSInterop
|
|||
/// <param name="args">JSON-serializable arguments.</param>
|
||||
/// <returns>An instance of <typeparamref name="TValue"/> obtained by JSON-deserializing the return value.</returns>
|
||||
[return: MaybeNull]
|
||||
public TValue Invoke<TValue>(string identifier, params object[] args)
|
||||
public TValue Invoke<TValue>(string identifier, params object?[]? args)
|
||||
{
|
||||
var resultJson = InvokeJS(identifier, JsonSerializer.Serialize(args, JsonSerializerOptions));
|
||||
if (resultJson is null)
|
||||
|
|
|
|||
|
|
@ -62,7 +62,7 @@ namespace Microsoft.JSInterop
|
|||
/// <param name="identifier">An identifier for the function to invoke. For example, the value <c>"someScope.someFunction"</c> will invoke the function <c>window.someScope.someFunction</c>.</param>
|
||||
/// <param name="args">JSON-serializable arguments.</param>
|
||||
/// <returns>An instance of <typeparamref name="TValue"/> obtained by JSON-deserializing the return value.</returns>
|
||||
public async ValueTask<TValue> InvokeAsync<TValue>(string identifier, object[] args)
|
||||
public async ValueTask<TValue> InvokeAsync<TValue>(string identifier, object?[]? args)
|
||||
{
|
||||
if (DefaultAsyncTimeout.HasValue)
|
||||
{
|
||||
|
|
@ -85,7 +85,7 @@ namespace Microsoft.JSInterop
|
|||
/// </param>
|
||||
/// <param name="args">JSON-serializable arguments.</param>
|
||||
/// <returns>An instance of <typeparamref name="TValue"/> obtained by JSON-deserializing the return value.</returns>
|
||||
public ValueTask<TValue> InvokeAsync<TValue>(string identifier, CancellationToken cancellationToken, object[] args)
|
||||
public ValueTask<TValue> InvokeAsync<TValue>(string identifier, CancellationToken cancellationToken, object?[]? args)
|
||||
{
|
||||
var taskId = Interlocked.Increment(ref _nextPendingTaskId);
|
||||
var tcs = new TaskCompletionSource<TValue>(TaskContinuationOptions.RunContinuationsAsynchronously);
|
||||
|
|
|
|||
Loading…
Reference in New Issue