2021-11-23 15:01:10 -08:00
|
|
|
#pragma warning disable 168
|
|
|
|
|
|
|
|
using System;
|
|
|
|
|
|
|
|
namespace Tests
|
|
|
|
{
|
|
|
|
class Reflection2
|
|
|
|
{
|
2021-11-24 13:27:39 -08:00
|
|
|
public typealias RemovePtr<T> = comptype(RemovePtr(typeof(T)));
|
|
|
|
|
|
|
|
[Comptime]
|
|
|
|
public static Type RemovePtr(Type type)
|
|
|
|
{
|
|
|
|
if (type.IsPointer)
|
|
|
|
return type.UnderlyingType;
|
|
|
|
|
|
|
|
return type;
|
|
|
|
}
|
|
|
|
|
2021-11-23 15:01:10 -08:00
|
|
|
[Test]
|
|
|
|
public static void TestBasics()
|
|
|
|
{
|
|
|
|
const Type t = typeof(StringView);
|
|
|
|
int fieldCount = t.FieldCount;
|
2021-11-24 13:27:39 -08:00
|
|
|
|
|
|
|
Test.Assert(typeof(RemovePtr<int32>) == typeof(int32));
|
|
|
|
Test.Assert(typeof(RemovePtr<uint32*>) == typeof(uint32));
|
2021-11-23 15:01:10 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|