Skip to content

Commit e22ca46

Browse files
committed
rename JSHostImplementation.ThreadCsOwnedObjects
(used to be CsOwnedObjects) Rename to make it clear that it's objects owned by the current thread, not the runtime globally
1 parent 4671e03 commit e22ca46

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

src/libraries/System.Runtime.InteropServices.JavaScript/src/System/Runtime/InteropServices/JavaScript/Interop/LegacyExports.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ internal static void PreventTrimming()
3232

3333
public static void GetCSOwnedObjectByJSHandleRef(nint jsHandle, int shouldAddInflight, out JSObject? result)
3434
{
35-
if (JSHostImplementation.CsOwnedObjects.TryGetValue((int)jsHandle, out WeakReference<JSObject>? reference))
35+
if (JSHostImplementation.ThreadCsOwnedObjects.TryGetValue((int)jsHandle, out WeakReference<JSObject>? reference))
3636
{
3737
reference.TryGetTarget(out JSObject? jsObject);
3838
if (shouldAddInflight != 0)
@@ -74,7 +74,7 @@ public static void CreateCSOwnedProxyRef(nint jsHandle, LegacyHostImplementation
7474

7575
JSObject? res = null;
7676

77-
if (!JSHostImplementation.CsOwnedObjects.TryGetValue((int)jsHandle, out WeakReference<JSObject>? reference) ||
77+
if (!JSHostImplementation.ThreadCsOwnedObjects.TryGetValue((int)jsHandle, out WeakReference<JSObject>? reference) ||
7878
!reference.TryGetTarget(out res) ||
7979
res.IsDisposed)
8080
{
@@ -90,7 +90,7 @@ public static void CreateCSOwnedProxyRef(nint jsHandle, LegacyHostImplementation
9090
_ => throw new ArgumentOutOfRangeException(nameof(mappedType))
9191
};
9292
#pragma warning restore CS0612 // Type or member is obsolete
93-
JSHostImplementation.CsOwnedObjects[(int)jsHandle] = new WeakReference<JSObject>(res, trackResurrection: true);
93+
JSHostImplementation.ThreadCsOwnedObjects[(int)jsHandle] = new WeakReference<JSObject>(res, trackResurrection: true);
9494
}
9595
if (shouldAddInflight != 0)
9696
{

src/libraries/System.Runtime.InteropServices.JavaScript/src/System/Runtime/InteropServices/JavaScript/JSHostImplementation.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ internal static partial class JSHostImplementation
2020
#endif
2121
private static Dictionary<int, WeakReference<JSObject>>? s_csOwnedObjects;
2222

23-
public static Dictionary<int, WeakReference<JSObject>> CsOwnedObjects
23+
public static Dictionary<int, WeakReference<JSObject>> ThreadCsOwnedObjects
2424
{
2525
get
2626
{
@@ -37,7 +37,7 @@ public static void ReleaseCSOwnedObject(nint jsHandle)
3737
{
3838
if (jsHandle != IntPtr.Zero)
3939
{
40-
CsOwnedObjects.Remove((int)jsHandle);
40+
ThreadCsOwnedObjects.Remove((int)jsHandle);
4141
Interop.Runtime.ReleaseCSOwnedObject(jsHandle);
4242
}
4343
}
@@ -187,12 +187,12 @@ public static JSObject CreateCSOwnedProxy(nint jsHandle)
187187
{
188188
JSObject? res;
189189

190-
if (!CsOwnedObjects.TryGetValue((int)jsHandle, out WeakReference<JSObject>? reference) ||
190+
if (!ThreadCsOwnedObjects.TryGetValue((int)jsHandle, out WeakReference<JSObject>? reference) ||
191191
!reference.TryGetTarget(out res) ||
192192
res.IsDisposed)
193193
{
194194
res = new JSObject(jsHandle);
195-
CsOwnedObjects[(int)jsHandle] = new WeakReference<JSObject>(res, trackResurrection: true);
195+
ThreadCsOwnedObjects[(int)jsHandle] = new WeakReference<JSObject>(res, trackResurrection: true);
196196
}
197197
return res;
198198
}

src/libraries/System.Runtime.InteropServices.JavaScript/src/System/Runtime/InteropServices/JavaScript/Legacy/LegacyHostImplementation.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public static void ReleaseInFlight(object obj)
2121
[MethodImpl(MethodImplOptions.AggressiveInlining)]
2222
public static void RegisterCSOwnedObject(JSObject proxy)
2323
{
24-
JSHostImplementation.CsOwnedObjects[(int)proxy.JSHandle] = new WeakReference<JSObject>(proxy, trackResurrection: true);
24+
JSHostImplementation.ThreadCsOwnedObjects[(int)proxy.JSHandle] = new WeakReference<JSObject>(proxy, trackResurrection: true);
2525
}
2626

2727
public static MarshalType GetMarshalTypeFromType(Type type)

0 commit comments

Comments
 (0)