-
Notifications
You must be signed in to change notification settings - Fork 10k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update JSCallResultTypeHelper.cs (#25628)
* Update JSCallResultTypeHelper.cs and PublicAPI.Unshipped.txt * CR feedback. * Removed exception message
- Loading branch information
1 parent
43ef580
commit 8f46188
Showing
1 changed file
with
18 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,28 @@ | ||
// 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. | ||
|
||
using System.Reflection; | ||
|
||
namespace Microsoft.JSInterop | ||
{ | ||
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>() | ||
=> typeof(TResult) == typeof(IJSObjectReference) | ||
|| typeof(TResult) == typeof(IJSInProcessObjectReference) | ||
|| typeof(TResult) == typeof(IJSUnmarshalledObjectReference) ? | ||
JSCallResultType.JSObjectReference : | ||
JSCallResultType.Default; | ||
{ | ||
if (typeof(TResult).Assembly == _currentAssembly | ||
&& (typeof(TResult) == typeof(IJSObjectReference) | ||
|| typeof(TResult) == typeof(IJSInProcessObjectReference) | ||
|| typeof(TResult) == typeof(IJSUnmarshalledObjectReference))) | ||
{ | ||
return JSCallResultType.JSObjectReference; | ||
} | ||
else | ||
{ | ||
return JSCallResultType.Default; | ||
} | ||
} | ||
} | ||
} |