Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ public static partial class Json
}
public static partial class JSRuntime
{
public static Microsoft.JSInterop.IJSRuntime Current { get { throw null; } }
public static void SetCurrentJSRuntime(Microsoft.JSInterop.IJSRuntime instance) { }
}
public abstract partial class JSRuntimeBase : Microsoft.JSInterop.IJSRuntime
Expand Down
8 changes: 2 additions & 6 deletions src/JSInterop/Microsoft.JSInterop/src/JSRuntime.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,9 @@ namespace Microsoft.JSInterop
/// </summary>
public static class JSRuntime
{
private static AsyncLocal<IJSRuntime> _currentJSRuntime
= new AsyncLocal<IJSRuntime>();
private static readonly AsyncLocal<IJSRuntime> _currentJSRuntime = new AsyncLocal<IJSRuntime>();

/// <summary>
/// Gets the current <see cref="IJSRuntime"/>, if any.
/// </summary>
public static IJSRuntime Current => _currentJSRuntime.Value;
internal static IJSRuntime Current => _currentJSRuntime.Value;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It says remove. But from looking at it, I can see that it is not removed.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed. Could the entire JSRuntime.cs file be removed?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not in any trivial way. It's used from a static context by DotnetNetDispatcher to notify of completion:

In addition, there's also some pretty gnarly coupling of the runtime \ SimpleJSON's serialization and object tracking. I was hoping not to mess around with the code here if it's meant to be cleaned up soon.


/// <summary>
/// Sets the current JS runtime to the supplied instance.
Expand Down