Skip to content

Commit 0164174

Browse files
committed
Adding a regression test covering an interface method with a function pointer parameter
1 parent e105e23 commit 0164174

File tree

4 files changed

+78
-0
lines changed

4 files changed

+78
-0
lines changed
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
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+
4+
using Mono.Linker.Tests.Cases.Expectations.Assertions;
5+
using Mono.Linker.Tests.Cases.Expectations.Metadata;
6+
7+
namespace Mono.Linker.Tests.Cases.FunctionPointers
8+
{
9+
[SetupCompileArgument ("/unsafe")]
10+
unsafe class CanCompileInterfaceWithFunctionPointerParameter
11+
{
12+
public static void Main()
13+
{
14+
new CanCompileInterfaceWithFunctionPointerParameter.B ().Method (null);
15+
}
16+
17+
[KeptMember (".ctor()")]
18+
class B : I
19+
{
20+
public void Unused (delegate* unmanaged<void> fnptr)
21+
{
22+
}
23+
24+
[Kept]
25+
public void Method (delegate* unmanaged<void> fnptr)
26+
{
27+
}
28+
}
29+
30+
interface I
31+
{
32+
void Unused (delegate* unmanaged<void> fnptr);
33+
34+
void Method (delegate* unmanaged<void> fnptr);
35+
}
36+
}
37+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
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+
4+
using Mono.Linker.Tests.Cases.Expectations.Assertions;
5+
using Mono.Linker.Tests.Cases.Expectations.Metadata;
6+
7+
namespace Mono.Linker.Tests.Cases.FunctionPointers
8+
{
9+
[SetupCompileArgument ("/unsafe")]
10+
unsafe class CanCompileMethodWithFunctionPointerParameter
11+
{
12+
public static void Main()
13+
{
14+
new CanCompileMethodWithFunctionPointerParameter.B ().Method (null);
15+
}
16+
17+
[KeptMember (".ctor()")]
18+
class B
19+
{
20+
public void Unused (delegate* unmanaged<void> fnptr)
21+
{
22+
}
23+
24+
[Kept]
25+
public void Method (delegate* unmanaged<void> fnptr)
26+
{
27+
}
28+
}
29+
}
30+
}

test/Mono.Linker.Tests/TestCases/TestDatabase.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,11 @@ public static IEnumerable<TestCaseData> FeatureSettingsTests ()
8686
return NUnitCasesBySuiteName ("FeatureSettings");
8787
}
8888

89+
public static IEnumerable<TestCaseData> FunctionPointersTests ()
90+
{
91+
return NUnitCasesBySuiteName ("FunctionPointers");
92+
}
93+
8994
public static IEnumerable<TestCaseData> GenericsTests ()
9095
{
9196
return NUnitCasesBySuiteName ("Generics");

test/Mono.Linker.Tests/TestCases/TestSuites.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,12 @@ public void FeatureSettingsTests (TestCase testCase)
103103
Run (testCase);
104104
}
105105

106+
[TestCaseSource (typeof (TestDatabase), nameof (TestDatabase.FunctionPointersTests))]
107+
public void FunctionPointerTests (TestCase testCase)
108+
{
109+
Run (testCase);
110+
}
111+
106112
[TestCaseSource (typeof (TestDatabase), nameof (TestDatabase.GenericsTests))]
107113
public void GenericsTests (TestCase testCase)
108114
{

0 commit comments

Comments
 (0)