Skip to content

Commit 50815ed

Browse files
authored
JSInterop nullability PR feedback (#25114)
1 parent ecf2a23 commit 50815ed

File tree

6 files changed

+10
-10
lines changed

6 files changed

+10
-10
lines changed

src/JSInterop/Microsoft.JSInterop/src/IJSInProcessRuntime.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,6 @@ public interface IJSInProcessRuntime : IJSRuntime
1515
/// <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>
1616
/// <param name="args">JSON-serializable arguments.</param>
1717
/// <returns>An instance of <typeparamref name="T"/> obtained by JSON-deserializing the return value.</returns>
18-
T Invoke<T>(string identifier, params object[] args);
18+
T Invoke<T>(string identifier, params object?[]? args);
1919
}
2020
}

src/JSInterop/Microsoft.JSInterop/src/IJSRuntime.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public interface IJSRuntime
2222
/// <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>
2323
/// <param name="args">JSON-serializable arguments.</param>
2424
/// <returns>An instance of <typeparamref name="TValue"/> obtained by JSON-deserializing the return value.</returns>
25-
ValueTask<TValue> InvokeAsync<TValue>(string identifier, object[] args);
25+
ValueTask<TValue> InvokeAsync<TValue>(string identifier, object?[]? args);
2626

2727
/// <summary>
2828
/// Invokes the specified JavaScript function asynchronously.
@@ -35,6 +35,6 @@ public interface IJSRuntime
3535
/// </param>
3636
/// <param name="args">JSON-serializable arguments.</param>
3737
/// <returns>An instance of <typeparamref name="TValue"/> obtained by JSON-deserializing the return value.</returns>
38-
ValueTask<TValue> InvokeAsync<TValue>(string identifier, CancellationToken cancellationToken, object[] args);
38+
ValueTask<TValue> InvokeAsync<TValue>(string identifier, CancellationToken cancellationToken, object?[]? args);
3939
}
4040
}

src/JSInterop/Microsoft.JSInterop/src/Infrastructure/DotNetDispatcher.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ public static void BeginInvokeDotNet(JSRuntime jsRuntime, DotNetInvocationInfo i
136136
Type[] parameterTypes;
137137
if (objectReference is null)
138138
{
139-
assemblyKey = new AssemblyKey(assemblyName);
139+
assemblyKey = new AssemblyKey(assemblyName!);
140140
(methodInfo, parameterTypes) = GetCachedMethodInfo(assemblyKey, methodIdentifier);
141141
}
142142
else

src/JSInterop/Microsoft.JSInterop/src/Infrastructure/DotNetInvocationInfo.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ public readonly struct DotNetInvocationInfo
1515
/// <param name="methodIdentifier">The identifier of the method to be invoked.</param>
1616
/// <param name="dotNetObjectId">The object identifier for instance method calls.</param>
1717
/// <param name="callId">The call identifier.</param>
18-
public DotNetInvocationInfo(string assemblyName, string methodIdentifier, long dotNetObjectId, string callId)
18+
public DotNetInvocationInfo(string? assemblyName, string methodIdentifier, long dotNetObjectId, string? callId)
1919
{
2020
CallId = callId;
2121
AssemblyName = assemblyName;
@@ -27,7 +27,7 @@ public DotNetInvocationInfo(string assemblyName, string methodIdentifier, long d
2727
/// Gets the name of the assembly containing the method.
2828
/// Only one of <see cref="DotNetObjectId"/> or <see cref="AssemblyName"/> may be specified.
2929
/// </summary>
30-
public string AssemblyName { get; }
30+
public string? AssemblyName { get; }
3131

3232
/// <summary>
3333
/// Gets the identifier of the method to be invoked. This is the value specified in the <see cref="JSInvokableAttribute"/>.
@@ -43,6 +43,6 @@ public DotNetInvocationInfo(string assemblyName, string methodIdentifier, long d
4343
/// <summary>
4444
/// Gets the call identifier. This value is <see langword="null"/> when the client does not expect a value to be returned.
4545
/// </summary>
46-
public string CallId { get; }
46+
public string? CallId { get; }
4747
}
4848
}

src/JSInterop/Microsoft.JSInterop/src/JSInProcessRuntime.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public abstract class JSInProcessRuntime : JSRuntime, IJSInProcessRuntime
1919
/// <param name="args">JSON-serializable arguments.</param>
2020
/// <returns>An instance of <typeparamref name="TValue"/> obtained by JSON-deserializing the return value.</returns>
2121
[return: MaybeNull]
22-
public TValue Invoke<TValue>(string identifier, params object[] args)
22+
public TValue Invoke<TValue>(string identifier, params object?[]? args)
2323
{
2424
var resultJson = InvokeJS(identifier, JsonSerializer.Serialize(args, JsonSerializerOptions));
2525
if (resultJson is null)

src/JSInterop/Microsoft.JSInterop/src/JSRuntime.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ protected JSRuntime()
6262
/// <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>
6363
/// <param name="args">JSON-serializable arguments.</param>
6464
/// <returns>An instance of <typeparamref name="TValue"/> obtained by JSON-deserializing the return value.</returns>
65-
public async ValueTask<TValue> InvokeAsync<TValue>(string identifier, object[] args)
65+
public async ValueTask<TValue> InvokeAsync<TValue>(string identifier, object?[]? args)
6666
{
6767
if (DefaultAsyncTimeout.HasValue)
6868
{
@@ -85,7 +85,7 @@ public async ValueTask<TValue> InvokeAsync<TValue>(string identifier, object[] a
8585
/// </param>
8686
/// <param name="args">JSON-serializable arguments.</param>
8787
/// <returns>An instance of <typeparamref name="TValue"/> obtained by JSON-deserializing the return value.</returns>
88-
public ValueTask<TValue> InvokeAsync<TValue>(string identifier, CancellationToken cancellationToken, object[] args)
88+
public ValueTask<TValue> InvokeAsync<TValue>(string identifier, CancellationToken cancellationToken, object?[]? args)
8989
{
9090
var taskId = Interlocked.Increment(ref _nextPendingTaskId);
9191
var tcs = new TaskCompletionSource<TValue>(TaskContinuationOptions.RunContinuationsAsynchronously);

0 commit comments

Comments
 (0)