Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
173b84d
Add reflection introspection support for function pointers
steveharter May 31, 2022
e546ee2
Fix compiler issue; test MLC to NetFramework
steveharter Jan 23, 2023
36e07d6
Fix compile issue; prep for review
steveharter Jan 23, 2023
e755c1c
Compile issue with MLC under certain conditions
steveharter Jan 23, 2023
b3b64ff
compile issue cont'd; lazy load mods on root
steveharter Jan 23, 2023
3aef789
compile issues cont'd; prepare for review
steveharter Jan 24, 2023
f76c75d
Remove Node back reference; fix edge case test failure
steveharter Jan 24, 2023
73b15b3
Increase test coverage; add missing recursive check
steveharter Jan 24, 2023
1361142
Various feedback; support mods on generic type parameters
steveharter Jan 26, 2023
520a3f5
Merge branch 'main' of https://github.com/steveharter/runtime into Fc…
steveharter Jan 26, 2023
64a987e
Fix MLC edge case; Native AOT test enable\disable
steveharter Jan 26, 2023
5f8a81e
Native AOT test enable\disable; add a generic test
steveharter Jan 26, 2023
2df9d2b
Native AOT test enable\disable; fix missing overload
steveharter Jan 26, 2023
0a6ff32
Add TODOs based on review discussion; MLC field optimization
steveharter Jan 27, 2023
784df92
Merge branch 'main' into FcnPtr
jkotas Feb 1, 2023
8c06d3c
Replace nested signature indices by TypeSignature type
jkotas Jan 31, 2023
f40e506
Move tests into separate classes; other misc non-functional
steveharter Feb 13, 2023
4610e93
Throw NSE for modified type members than may return an unmodified type
steveharter Feb 14, 2023
ca45bd8
Merge branch 'main' of https://github.com/dotnet/runtime into FcnPtr
steveharter Feb 14, 2023
70529f0
Throw NSE on modified type Equals() and GetHashCode()
steveharter Feb 15, 2023
9770a2d
Fix tests for WASI
steveharter Feb 15, 2023
14a9007
Remove unnecessary high overhead tests
steveharter Feb 16, 2023
69ccd75
Merge branch 'main' of https://github.com/dotnet/runtime into FcnPtr
steveharter Feb 16, 2023
f76331c
Fix merge error
steveharter Feb 16, 2023
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
Prev Previous commit
Next Next commit
Native AOT test enable\disable; fix missing overload
  • Loading branch information
steveharter committed Jan 26, 2023
commit 2df9d2b161bdfd6fc02e58f5805158c18e47dc1e
85 changes: 44 additions & 41 deletions src/libraries/Common/tests/System/ModifiedTypeTests.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System.Collections.Generic;
using System.Reflection;
using System.Reflection.Tests;
using System.Runtime.CompilerServices;
Expand Down Expand Up @@ -54,53 +55,54 @@ void Verify(Type type)
}
}

[Fact]
[ActiveIssue("https://github.com/dotnet/runtime/issues/71095", TestRuntimes.Mono)]
[ActiveIssue("https://github.com/dotnet/runtime/issues/71883", typeof(PlatformDetection), nameof(PlatformDetection.IsNativeAot))]
public static unsafe void Fields_Generic_Unmodified()
{
Type arrayGenericFcnPtr = typeof(ModifiedTypeHolder).Project().GetField(nameof(ModifiedTypeHolder._arrayGenericFcnPtr), Bindings).FieldType;
Assert.True(arrayGenericFcnPtr.IsGenericType);
Assert.False(arrayGenericFcnPtr.IsGenericTypeDefinition);
Assert.False(IsModifiedType(arrayGenericFcnPtr));
// NOTE: the below tests commented out due to compiler issue on NativeAOT: #81117

Type genericParam = arrayGenericFcnPtr.GetGenericArguments()[0];
Assert.False(IsModifiedType(genericParam));
//[Fact]
//[ActiveIssue("https://github.com/dotnet/runtime/issues/71095", TestRuntimes.Mono)]
//[ActiveIssue("https://github.com/dotnet/runtime/issues/71883", typeof(PlatformDetection), nameof(PlatformDetection.IsNativeAot))]
//public static unsafe void Fields_Generic_Unmodified()
//{
// Type arrayGenericFcnPtr = typeof(ModifiedTypeHolder).Project().GetField(nameof(ModifiedTypeHolder._arrayGenericFcnPtr), Bindings).FieldType;
// Assert.True(arrayGenericFcnPtr.IsGenericType);
// Assert.False(arrayGenericFcnPtr.IsGenericTypeDefinition);
// Assert.False(IsModifiedType(arrayGenericFcnPtr));

Type fcnPtr = genericParam.GetElementType();
Assert.True(fcnPtr.IsFunctionPointer);
Assert.False(IsModifiedType(fcnPtr));
// Type genericParam = arrayGenericFcnPtr.GetGenericArguments()[0];
// Assert.False(IsModifiedType(genericParam));

Assert.Equal(1, fcnPtr.GetFunctionPointerParameterTypes().Length);
Type paramType = fcnPtr.GetFunctionPointerParameterTypes()[0];
Assert.False(IsModifiedType(paramType));
}
// Type fcnPtr = genericParam.GetElementType();
// Assert.True(fcnPtr.IsFunctionPointer);
// Assert.False(IsModifiedType(fcnPtr));

[Fact]
[ActiveIssue("https://github.com/dotnet/runtime/issues/71095", TestRuntimes.Mono)]
[ActiveIssue("https://github.com/dotnet/runtime/issues/71883", typeof(PlatformDetection), nameof(PlatformDetection.IsNativeAot))]
public static unsafe void Fields_Generic_Modified()
{
Type arrayGenericFcnPtr = typeof(ModifiedTypeHolder).Project().GetField(nameof(ModifiedTypeHolder._arrayGenericFcnPtr), Bindings).GetModifiedFieldType();
Assert.True(IsModifiedType(arrayGenericFcnPtr));
Assert.True(arrayGenericFcnPtr.IsGenericType);
Assert.False(arrayGenericFcnPtr.IsGenericTypeDefinition);
// Assert.Equal(1, fcnPtr.GetFunctionPointerParameterTypes().Length);
// Type paramType = fcnPtr.GetFunctionPointerParameterTypes()[0];
// Assert.False(IsModifiedType(paramType));
//}

Type genericParam = arrayGenericFcnPtr.GetGenericArguments()[0];
Assert.True(IsModifiedType(genericParam));
//[Fact]
//[ActiveIssue("https://github.com/dotnet/runtime/issues/71095", TestRuntimes.Mono)]
//[ActiveIssue("https://github.com/dotnet/runtime/issues/71883", typeof(PlatformDetection), nameof(PlatformDetection.IsNativeAot))]
//public static unsafe void Fields_Generic_Modified()
//{
// Type arrayGenericFcnPtr = typeof(ModifiedTypeHolder).Project().GetField(nameof(ModifiedTypeHolder._arrayGenericFcnPtr), Bindings).GetModifiedFieldType();
// Assert.True(IsModifiedType(arrayGenericFcnPtr));
// Assert.True(arrayGenericFcnPtr.IsGenericType);
// Assert.False(arrayGenericFcnPtr.IsGenericTypeDefinition);

Type fcnPtr = genericParam.GetElementType();
Assert.True(fcnPtr.IsFunctionPointer);
Assert.True(IsModifiedType(fcnPtr));
// Type genericParam = arrayGenericFcnPtr.GetGenericArguments()[0];
// Assert.True(IsModifiedType(genericParam));

Assert.Equal(1, fcnPtr.GetFunctionPointerParameterTypes().Length);
Type paramType = fcnPtr.GetFunctionPointerParameterTypes()[0];
Assert.True(IsModifiedType(paramType));
Assert.Equal(1, paramType.GetRequiredCustomModifiers().Length);
Assert.Equal(typeof(OutAttribute).Project(), paramType.GetRequiredCustomModifiers()[0]);
}
// Type fcnPtr = genericParam.GetElementType();
// Assert.True(fcnPtr.IsFunctionPointer);
// Assert.True(IsModifiedType(fcnPtr));

// Assert.Equal(1, fcnPtr.GetFunctionPointerParameterTypes().Length);
// Type paramType = fcnPtr.GetFunctionPointerParameterTypes()[0];
// Assert.True(IsModifiedType(paramType));
// Assert.Equal(1, paramType.GetRequiredCustomModifiers().Length);
// Assert.Equal(typeof(OutAttribute).Project(), paramType.GetRequiredCustomModifiers()[0]);
//}

// NOTE: commented out due to compiler issue on NativeAOT: #81117
//[Fact]
//[ActiveIssue("https://github.com/dotnet/runtime/issues/71095", TestRuntimes.Mono)]
//[ActiveIssue("https://github.com/dotnet/runtime/issues/71883", typeof(PlatformDetection), nameof(PlatformDetection.IsNativeAot))]
Expand Down Expand Up @@ -592,7 +594,8 @@ public ModifiedTypeHolder(delegate*<out int, void> d) { }

// Although function pointer types can't be used as generic parameters, they can be used indirectly
// as an array element type.
public static volatile Tuple<delegate*<out bool, void>[]> _arrayGenericFcnPtr;
// NOTE: commented out due to compiler issue on NativeAOT: #81117
//public static volatile Tuple<delegate*<out bool, void>[]> _arrayGenericFcnPtr;

public static int** _ptr_ptr_int;
public static int*[] _array_ptr_int;
Expand Down Expand Up @@ -647,7 +650,7 @@ public static delegate*
>
>,
delegate*<sbyte> // ret
> _fcnPtr_complex;
> _fcnPtr_complex;
}
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -135,11 +135,7 @@ public override Type[] GetOptionalCustomModifiers()
}

// TypeDelegator doesn't forward these the way we want:
public override Type UnderlyingSystemType => typeImpl; // We don't want to forward to typeImpl.UnderlyingSystemType.
public override bool IsGenericType => typeImpl.IsGenericType; // Not forwarded.
public override Type GetGenericTypeDefinition() => typeImpl.GetGenericTypeDefinition(); // not forwarded; we don't wrap
public override string ToString() => UnderlyingSystemType.ToString(); // Not forwarded.
public override int GetHashCode() => UnderlyingSystemType.GetHashCode(); // Not forwarded.
public override bool ContainsGenericParameters => typeImpl.ContainsGenericParameters; // not forwarded.
public override bool Equals(Type? other) // Not forwarded.
{
if (other is ModifiedType otherModifiedType)
Expand All @@ -149,6 +145,11 @@ public override bool Equals(Type? other) // Not forwarded.

return false;
}
public override int GetHashCode() => UnderlyingSystemType.GetHashCode(); // Not forwarded.
public override Type GetGenericTypeDefinition() => typeImpl.GetGenericTypeDefinition(); // not forwarded.
public override bool IsGenericType => typeImpl.IsGenericType; // Not forwarded.
public override string ToString() => UnderlyingSystemType.ToString(); // Not forwarded.
public override Type UnderlyingSystemType => typeImpl; // We don't want to forward to typeImpl.UnderlyingSystemType.

public static T[] CloneArray<T>(T[] original, int start = 0)
{
Expand Down