Skip to content

Commit 4c74553

Browse files
committed
added a test
1 parent 2504120 commit 4c74553

File tree

2 files changed

+68
-0
lines changed

2 files changed

+68
-0
lines changed
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
using System;
4+
using Xunit;
5+
using System.Threading.Tasks;
6+
7+
public interface I0
8+
{
9+
Task<bool> M8();
10+
}
11+
12+
public struct S1 : I0
13+
{
14+
#pragma warning disable CS1998 // Async method lacks 'await' operators and will run synchronously
15+
public async Task<bool> M8()
16+
#pragma warning restore CS1998 // Async method lacks 'await' operators and will run synchronously
17+
{
18+
return false;
19+
}
20+
}
21+
22+
public class Program
23+
{
24+
[Fact]
25+
public static int TestEntryPoint()
26+
{
27+
System.Runtime.Loader.AssemblyLoadContext alc = new CollectibleALC();
28+
System.Reflection.Assembly asm = alc.LoadFromAssemblyPath(System.Reflection.Assembly.GetExecutingAssembly().Location);
29+
System.Reflection.MethodInfo mi = asm.GetType(typeof(Program).FullName).GetMethod(nameof(MainInner));
30+
System.Type runtimeTy = asm.GetType(typeof(Runtime).FullName);
31+
mi.Invoke(null, new object[] { System.Activator.CreateInstance(runtimeTy) });
32+
33+
return 100;
34+
}
35+
36+
public static void MainInner(IRuntime rt)
37+
{
38+
bool vr1 = new S1().M8().GetAwaiter().GetResult();
39+
}
40+
}
41+
42+
public interface IRuntime
43+
{
44+
void WriteLine<T>(string site, T value);
45+
}
46+
47+
public class Runtime : IRuntime
48+
{
49+
public void WriteLine<T>(string site, T value) => System.Console.WriteLine(value);
50+
}
51+
52+
public class CollectibleALC : System.Runtime.Loader.AssemblyLoadContext
53+
{
54+
public CollectibleALC() : base(true)
55+
{
56+
}
57+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
<PropertyGroup>
3+
<CLRTestPriority>1</CLRTestPriority>
4+
</PropertyGroup>
5+
<ItemGroup>
6+
<Compile Include="test115667.cs" />
7+
</ItemGroup>
8+
<ItemGroup>
9+
<ProjectReference Include="$(TestSourceDir)Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" />
10+
</ItemGroup>
11+
</Project>

0 commit comments

Comments
 (0)