Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 25 additions & 28 deletions src/libraries/System.Runtime/tests/System/TypedReferenceTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,34 +78,31 @@ public static void MakeTypedReference_ToObjectTests()
Assert.Equal(structObj, TypedReference.ToObject(reference));
}

// These tests are currently crashing the Mono AOT compiler, so commenting them out (skipping them isn't enough)
//[Fact]
//[ActiveIssue("https://github.com/dotnet/runtime/issues/70091", TestRuntimes.Mono)]
//public static unsafe void MakeTypedReference_ToObjectTests_WithPointer()
//{
// float* pointer = (float*)(nuint)0x12345678;
// TypedReference reference = __makeref(pointer);
// object obj = TypedReference.ToObject(reference);
//
// // TypedReference-s over pointers use the UIntPtr type when boxing
// Assert.NotNull(obj);
// Assert.IsType<UIntPtr>(obj);
// Assert.Equal((nuint)0x12345678, (nuint)obj);
//}
//
//[Fact]
//[ActiveIssue("https://github.com/dotnet/runtime/issues/70091", TestRuntimes.Mono)]
//public static unsafe void MakeTypedReference_ToObjectTests_WithFunctionPointer()
//{
// delegate*<int, float, string> pointer = (delegate*<int, float, string>)(void*)(nuint)0x12345678;
// TypedReference reference = __makeref(pointer);
// object obj = TypedReference.ToObject(reference);
//
// // TypedReference-s over function pointers use the UIntPtr type when boxing
// Assert.NotNull(obj);
// Assert.IsType<UIntPtr>(obj);
// Assert.Equal((nuint)0x12345678, (nuint)obj);
//}
[Fact]
public static unsafe void MakeTypedReference_ToObjectTests_WithPointer()
{
float* pointer = (float*)(nuint)0x12345678;
TypedReference reference = __makeref(pointer);
object obj = TypedReference.ToObject(reference);

// TypedReference-s over pointers use the UIntPtr type when boxing
Assert.NotNull(obj);
Assert.IsType<UIntPtr>(obj);
Assert.Equal((nuint)0x12345678, (nuint)obj);
}

[Fact]
public static unsafe void MakeTypedReference_ToObjectTests_WithFunctionPointer()
{
delegate*<int, float, string> pointer = (delegate*<int, float, string>)(void*)(nuint)0x12345678;
TypedReference reference = __makeref(pointer);
object obj = TypedReference.ToObject(reference);

// TypedReference-s over function pointers use the UIntPtr type when boxing
Assert.NotNull(obj);
Assert.IsType<UIntPtr>(obj);
Assert.Equal((nuint)0x12345678, (nuint)obj);
}

[Fact]
public static void MakeTypedReference_ReadOnlyField_Succeeds()
Expand Down