Skip to content
Prev Previous commit
Next Next commit
Fix tests
  • Loading branch information
xoofx committed Mar 30, 2024
commit 65474a57c3a4d7d3553ed2fa702f41a6066fb0f0
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,18 @@ public class Runtime_100437
[Fact]
public static int TestCollectibleEmptyArrayNotInFrozenHeap()
{
string assemblyPath = typeof(Runtime_100437).Assembly.Location
string assemblyPath = typeof(Runtime_100437).Assembly.Location;

// Skip this test for single file
if (string.IsNullOrEmpty(assemblyPath))
return;
return 100;

WeakReference[] wrs = new WeakReference[10];
for (int i = 0; i < wrs.Length; i++)
{
var alc = new MyAssemblyLoadContext();
var a = alc.LoadFromAssemblyPath(assemblyPath);
wrs[i] = (WeakReference)a.GetType("Runtime_100437").GetMethod("Work").Invoke(null, null);
wrs[i] = (WeakReference)a.GetType(nameof(Runtime_100437)).GetMethod(nameof(Work)).Invoke(null, null);
GC.Collect();
}

Expand All @@ -33,7 +33,7 @@ public static int TestCollectibleEmptyArrayNotInFrozenHeap()
// otherwise it will result in a random crash.
result += wr.Target?.ToString()?.GetHashCode() ?? 0;
}
return (result & 0) + 100;
return (result & 100) | 100;
}

public static WeakReference Work()
Expand Down