Update JSCallResultTypeHelper.cs (#25628)

* Update JSCallResultTypeHelper.cs and PublicAPI.Unshipped.txt

* CR feedback.

* Removed exception message
This commit is contained in:
Mackinnon Buck 2020-09-09 13:33:47 -07:00 committed by GitHub
parent 43ef580773
commit 8f461884c9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 18 additions and 5 deletions

View File

@ -1,15 +1,28 @@
// Copyright (c) .NET Foundation. All rights reserved. // Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System.Reflection;
namespace Microsoft.JSInterop namespace Microsoft.JSInterop
{ {
internal static class JSCallResultTypeHelper internal static class JSCallResultTypeHelper
{ {
// We avoid using Assembly.GetExecutingAssembly() because this is shared code.
private static readonly Assembly _currentAssembly = typeof(JSCallResultType).Assembly;
public static JSCallResultType FromGeneric<TResult>() public static JSCallResultType FromGeneric<TResult>()
=> typeof(TResult) == typeof(IJSObjectReference) {
|| typeof(TResult) == typeof(IJSInProcessObjectReference) if (typeof(TResult).Assembly == _currentAssembly
|| typeof(TResult) == typeof(IJSUnmarshalledObjectReference) ? && (typeof(TResult) == typeof(IJSObjectReference)
JSCallResultType.JSObjectReference : || typeof(TResult) == typeof(IJSInProcessObjectReference)
JSCallResultType.Default; || typeof(TResult) == typeof(IJSUnmarshalledObjectReference)))
{
return JSCallResultType.JSObjectReference;
}
else
{
return JSCallResultType.Default;
}
}
} }
} }