Skip to content

Commit

Permalink
Changes per PR comments
Browse files Browse the repository at this point in the history
  • Loading branch information
pranavkm committed Aug 14, 2019
1 parent 92d2321 commit 8e4f4f7
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/JSInterop/Microsoft.JSInterop/src/DotNetDispatcher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ namespace Microsoft.JSInterop
/// </summary>
public static class DotNetDispatcher
{
private const string DisposeDotNetObjectReferenceMethodName = "__Dispose";
internal static readonly JsonEncodedText DotNetObjectRefKey = JsonEncodedText.Encode("__dotNetObject");

private static readonly ConcurrentDictionary<AssemblyKey, IReadOnlyDictionary<string, (MethodInfo, Type[])>> _cachedMethodsByAssembly
Expand Down Expand Up @@ -141,7 +142,7 @@ private static object InvokeSynchronously(string assemblyName, string methodIden
throw new ArgumentException($"For instance method calls, '{nameof(assemblyName)}' should be null. Value received: '{assemblyName}'.");
}

if (string.Equals("__Dispose", methodIdentifier, StringComparison.Ordinal))
if (string.Equals(DisposeDotNetObjectReferenceMethodName, methodIdentifier, StringComparison.Ordinal))
{
// The client executed dotNetObjectReference.dispose(). Dispose the reference and exit.
objectReference.Dispose();
Expand All @@ -151,13 +152,13 @@ private static object InvokeSynchronously(string assemblyName, string methodIden
assemblyKey = new AssemblyKey(objectReference.Value.GetType().Assembly);
}


var (methodInfo, parameterTypes) = GetCachedMethodInfo(assemblyKey, methodIdentifier);

var suppliedArgs = ParseArguments(methodIdentifier, argsJson, parameterTypes);

try
{
// objectReference will be null if this call invokes a static JSInvokable method.
return methodInfo.Invoke(objectReference?.Value, suppliedArgs);
}
catch (TargetInvocationException tie) // Avoid using exception filters for AOT runtime support
Expand Down

0 comments on commit 8e4f4f7

Please sign in to comment.