Skip to content

Commit

Permalink
[mono] Support function pointer reflection introspection API (#89712)
Browse files Browse the repository at this point in the history
Fixes #71095
  • Loading branch information
ivanpovazan authored Aug 11, 2023
1 parent e8c46c2 commit 5d30e6d
Show file tree
Hide file tree
Showing 21 changed files with 470 additions and 102 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ public partial class FunctionPointerCallingConventionTests
[Theory]
[InlineData(true)]
[InlineData(false)]
[ActiveIssue("https://github.com/dotnet/runtime/issues/71095", TestRuntimes.Mono)]
public static unsafe void ManagedCallingConvention(bool modified)
{
Type t = typeof(FunctionPointerHolder).Project();
Expand All @@ -36,7 +35,6 @@ public static unsafe void ManagedCallingConvention(bool modified)
[InlineData(nameof(FunctionPointerHolder.MethodCallConv_Stdcall))]
[InlineData(nameof(FunctionPointerHolder.MethodCallConv_Thiscall))]
[InlineData(nameof(FunctionPointerHolder.MethodCallConv_Fastcall))]
[ActiveIssue("https://github.com/dotnet/runtime/issues/71095", TestRuntimes.Mono)]
public static unsafe void UnmanagedCallConv_Param_Unmodified(string methodName)
{
Type t = typeof(FunctionPointerHolder).Project();
Expand All @@ -54,7 +52,6 @@ public static unsafe void UnmanagedCallConv_Param_Unmodified(string methodName)
[InlineData(nameof(FunctionPointerHolder.MethodCallConv_Stdcall), typeof(CallConvStdcall))]
[InlineData(nameof(FunctionPointerHolder.MethodCallConv_Thiscall), typeof(CallConvThiscall))]
[InlineData(nameof(FunctionPointerHolder.MethodCallConv_Fastcall), typeof(CallConvFastcall))]
[ActiveIssue("https://github.com/dotnet/runtime/issues/71095", TestRuntimes.Mono)]
public static unsafe void UnmanagedCallConv_Param_Modified(string methodName, Type callingConventionRuntime)
{
Type callingConvention = callingConventionRuntime.Project();
Expand All @@ -71,7 +68,7 @@ public static unsafe void UnmanagedCallConv_Param_Modified(string methodName, Ty
}

[Fact]
[ActiveIssue("https://github.com/dotnet/runtime/issues/71095", TestRuntimes.Mono)]
[ActiveIssue("https://github.com/dotnet/runtime/issues/90308", TestRuntimes.Mono)]
public static unsafe void UnmanagedCallConvs_Return_Unmodified()
{
Type t = typeof(FunctionPointerHolder).Project();
Expand All @@ -91,7 +88,6 @@ public static unsafe void UnmanagedCallConvs_Return_Unmodified()
}

[Fact]
[ActiveIssue("https://github.com/dotnet/runtime/issues/71095", TestRuntimes.Mono)]
public static unsafe void UnmanagedCallConvs_Return_Modified()
{
Type t = typeof(FunctionPointerHolder).Project();
Expand All @@ -118,7 +114,6 @@ public static unsafe void UnmanagedCallConvs_Return_Modified()
[InlineData(nameof(FunctionPointerHolder.MethodCallConv_Stdcall_SuppressGCTransition))]
[InlineData(nameof(FunctionPointerHolder.MethodCallConv_Thiscall_SuppressGCTransition))]
[InlineData(nameof(FunctionPointerHolder.MethodCallConv_Fastcall_SuppressGCTransition))]
[ActiveIssue("https://github.com/dotnet/runtime/issues/71095", TestRuntimes.Mono)]
public static unsafe void UnmanagedCallConv_PhysicalModifiers_Unmodified(string methodName)
{
Type t = typeof(FunctionPointerHolder).Project();
Expand All @@ -137,7 +132,6 @@ public static unsafe void UnmanagedCallConv_PhysicalModifiers_Unmodified(string
[InlineData(nameof(FunctionPointerHolder.MethodCallConv_Stdcall_SuppressGCTransition), typeof(CallConvStdcall))]
[InlineData(nameof(FunctionPointerHolder.MethodCallConv_Thiscall_SuppressGCTransition), typeof(CallConvThiscall))]
[InlineData(nameof(FunctionPointerHolder.MethodCallConv_Fastcall_SuppressGCTransition), typeof(CallConvFastcall))]
[ActiveIssue("https://github.com/dotnet/runtime/issues/71095", TestRuntimes.Mono)]
public static unsafe void UnmanagedCallConv_PhysicalModifiers_Modified(string methodName, Type callingConventionRuntime)
{
Type suppressGcTransitionType = typeof(CallConvSuppressGCTransition).Project();
Expand All @@ -161,7 +155,6 @@ public static unsafe void UnmanagedCallConv_PhysicalModifiers_Modified(string me
}

[Fact]
[ActiveIssue("https://github.com/dotnet/runtime/issues/71095", TestRuntimes.Mono)]
public static unsafe void GenericTypeParameter()
{
Type holder = typeof(FunctionPointerHolder).Project();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ public partial class FunctionPointerEqualityTests
private const BindingFlags Bindings = BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Static | BindingFlags.DeclaredOnly;

[Fact]
[ActiveIssue("https://github.com/dotnet/runtime/issues/71095", TestRuntimes.Mono)]
public static unsafe void DifferentReturnValue()
{
Type t = typeof(FunctionPointerHolder).Project();
Expand All @@ -31,7 +30,6 @@ public static unsafe void DifferentReturnValue()
}

[Fact]
[ActiveIssue("https://github.com/dotnet/runtime/issues/71095", TestRuntimes.Mono)]
public static unsafe void ObjectEquals_ModifiedTypes()
{
Type holder = typeof(FunctionPointerHolder).Project();
Expand All @@ -47,7 +45,6 @@ public static unsafe void ObjectEquals_ModifiedTypes()
}

[Fact]
[ActiveIssue("https://github.com/dotnet/runtime/issues/71095", TestRuntimes.Mono)]
public static unsafe void ObjectEquals_OneSideModifiedType()
{
Type holder = typeof(FunctionPointerHolder).Project();
Expand All @@ -65,7 +62,7 @@ public static unsafe void ObjectEquals_OneSideModifiedType()
[InlineData(nameof(FunctionPointerHolder.MethodCallConv_Cdecl), nameof(FunctionPointerHolder.MethodCallConv_Stdcall))]
[InlineData(nameof(FunctionPointerHolder.MethodCallConv_Cdecl), nameof(FunctionPointerHolder.MethodCallConv_Thiscall))]
[InlineData(nameof(FunctionPointerHolder.MethodCallConv_Cdecl), nameof(FunctionPointerHolder.MethodCallConv_Fastcall))]
[ActiveIssue("https://github.com/dotnet/runtime/issues/71095", TestRuntimes.Mono)]
[ActiveIssue("https://github.com/dotnet/runtime/issues/90308", TestRuntimes.Mono)]
public static unsafe void CallingConvention_Unmodified(string methodName1, string methodName2)
{
Type t = typeof(FunctionPointerHolder).Project();
Expand All @@ -83,7 +80,6 @@ public static unsafe void CallingConvention_Unmodified(string methodName1, strin
[InlineData(nameof(FunctionPointerHolder.MethodCallConv_Cdecl), nameof(FunctionPointerHolder.MethodCallConv_Stdcall))]
[InlineData(nameof(FunctionPointerHolder.MethodCallConv_Cdecl), nameof(FunctionPointerHolder.MethodCallConv_Thiscall))]
[InlineData(nameof(FunctionPointerHolder.MethodCallConv_Cdecl), nameof(FunctionPointerHolder.MethodCallConv_Fastcall))]
[ActiveIssue("https://github.com/dotnet/runtime/issues/71095", TestRuntimes.Mono)]
public static unsafe void CallingConvention_Modified(string methodName1, string methodName2)
{
Type t = typeof(FunctionPointerHolder).Project();
Expand Down
8 changes: 0 additions & 8 deletions src/libraries/Common/tests/System/FunctionPointerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ public partial class FunctionPointerTests
private const BindingFlags Bindings = BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Static | BindingFlags.DeclaredOnly;

[Fact]
[ActiveIssue("https://github.com/dotnet/runtime/issues/71095", TestRuntimes.Mono)]
public static unsafe void TypeMembers()
{
// Get an arbitrary function pointer
Expand Down Expand Up @@ -116,7 +115,6 @@ public static unsafe void TypeMembers()
}

[Fact]
[ActiveIssue("https://github.com/dotnet/runtime/issues/71095", TestRuntimes.Mono)]
public static unsafe void NonFunctionPointerThrows()
{
Assert.Throws<InvalidOperationException>(() => typeof(int).GetFunctionPointerCallingConventions());
Expand All @@ -125,7 +123,6 @@ public static unsafe void NonFunctionPointerThrows()
}

[Fact]
[ActiveIssue("https://github.com/dotnet/runtime/issues/71095", TestRuntimes.Mono)]
public static unsafe void TestToString()
{
// Function pointer types are inline in metadata and can't be loaded independently so they do not support the
Expand All @@ -146,7 +143,6 @@ public static unsafe void TestToString()
}

[Fact]
[ActiveIssue("https://github.com/dotnet/runtime/issues/71095", TestRuntimes.Mono)]
public static unsafe void FunctionPointerReturn()
{
Type t = typeof(FunctionPointerHolder).Project();
Expand All @@ -163,7 +159,6 @@ public static unsafe void FunctionPointerReturn()
}

[Fact]
[ActiveIssue("https://github.com/dotnet/runtime/issues/71095", TestRuntimes.Mono)]
public static unsafe void RequiredModifiers()
{
Type t = typeof(FunctionPointerHolder).Project();
Expand All @@ -188,7 +183,6 @@ public static unsafe void RequiredModifiers()
"Double",
"System.Double(System.String, System.Boolean*&, System.Tests.Types.FunctionPointerTests+FunctionPointerHolder+MyClass, System.Tests.Types.FunctionPointerTests+FunctionPointerHolder+MyStruct&)",
"String", "Boolean*&", "MyClass", "MyStruct&")]
[ActiveIssue("https://github.com/dotnet/runtime/issues/71095", TestRuntimes.Mono)]
public static unsafe void MethodInfo(
string methodName,
string methodToStringPostfix,
Expand Down Expand Up @@ -216,7 +210,6 @@ public static unsafe void MethodInfo(
[Theory]
[InlineData(nameof(FunctionPointerHolder.Prop_Int), "System.Int32()")]
[InlineData(nameof(FunctionPointerHolder.Prop_MyClass), "System.Tests.Types.FunctionPointerTests+FunctionPointerHolder+MyClass()")]
[ActiveIssue("https://github.com/dotnet/runtime/issues/71095", TestRuntimes.Mono)]
public static unsafe void Property(string name, string expectedToString)
{
Type t = typeof(FunctionPointerHolder).Project();
Expand All @@ -235,7 +228,6 @@ public static unsafe void Property(string name, string expectedToString)
[Theory]
[InlineData(nameof(FunctionPointerHolder.Field_Int), "System.Int32()")]
[InlineData(nameof(FunctionPointerHolder.Field_MyClass), "System.Tests.Types.FunctionPointerTests+FunctionPointerHolder+MyClass()")]
[ActiveIssue("https://github.com/dotnet/runtime/issues/71095", TestRuntimes.Mono)]
public static unsafe void Field(string name, string expectedToString)
{
Type t = typeof(FunctionPointerHolder).Project();
Expand Down
Loading

0 comments on commit 5d30e6d

Please sign in to comment.