Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/corert.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichal Strehovský <michals@microsoft.com>2017-12-01 22:08:54 +0300
committerMichal Strehovský <michals@microsoft.com>2017-12-01 22:08:54 +0300
commit8710f2b396fbea554846bfb51e643e4e07ce3a9d (patch)
tree915c305db9a33e0034dc733d334295a913e380bd /src/Test.CoreLib
parent960759f69d0f3f73889ffbc04998d6505834b0a5 (diff)
Make it possible to use typeof() with Test.CoreLib
Diffstat (limited to 'src/Test.CoreLib')
-rw-r--r--src/Test.CoreLib/src/System/RuntimeTypeHandle.cs39
-rw-r--r--src/Test.CoreLib/src/System/Type.cs30
-rw-r--r--src/Test.CoreLib/src/Test.CoreLib.csproj5
3 files changed, 71 insertions, 3 deletions
diff --git a/src/Test.CoreLib/src/System/RuntimeTypeHandle.cs b/src/Test.CoreLib/src/System/RuntimeTypeHandle.cs
new file mode 100644
index 000000000..9292f899e
--- /dev/null
+++ b/src/Test.CoreLib/src/System/RuntimeTypeHandle.cs
@@ -0,0 +1,39 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+namespace System
+{
+ [StructLayout(LayoutKind.Sequential)]
+ public struct RuntimeTypeHandle
+ {
+ private EETypePtr _pEEType;
+
+ internal RuntimeTypeHandle(EETypePtr pEEType)
+ {
+ _pEEType = pEEType;
+ }
+
+ [Intrinsic]
+ internal static unsafe IntPtr GetValueInternal(RuntimeTypeHandle handle)
+ {
+ return (IntPtr)handle._pEEType.ToPointer();
+ }
+ }
+}
+
+namespace Internal.Runtime.CompilerHelpers
+{
+ // Needed by the compiler to lower LDTOKEN
+ internal static class LdTokenHelpers
+ {
+ private static RuntimeTypeHandle GetRuntimeTypeHandle(IntPtr pEEType)
+ {
+ return new RuntimeTypeHandle(new EETypePtr(pEEType));
+ }
+ }
+}
diff --git a/src/Test.CoreLib/src/System/Type.cs b/src/Test.CoreLib/src/System/Type.cs
new file mode 100644
index 000000000..eeed98f49
--- /dev/null
+++ b/src/Test.CoreLib/src/System/Type.cs
@@ -0,0 +1,30 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+// System.Type is only defined to support C# typeof. We shouldn't have it here since the semantic
+// is not very compatible.
+
+using System;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+namespace System
+{
+ public class Type
+ {
+ private readonly RuntimeTypeHandle _typeHandle;
+
+ private Type(RuntimeTypeHandle typeHandle)
+ {
+ _typeHandle = typeHandle;
+ }
+
+ public RuntimeTypeHandle TypeHandle => _typeHandle;
+
+ public static Type GetTypeFromHandle(RuntimeTypeHandle rh)
+ {
+ return new Type(rh);
+ }
+ }
+}
diff --git a/src/Test.CoreLib/src/Test.CoreLib.csproj b/src/Test.CoreLib/src/Test.CoreLib.csproj
index 29a2ff9f2..8af27e91e 100644
--- a/src/Test.CoreLib/src/Test.CoreLib.csproj
+++ b/src/Test.CoreLib/src/Test.CoreLib.csproj
@@ -156,9 +156,6 @@
<Compile Include="..\..\Runtime.Base\src\System\RuntimeHandles.cs">
<Link>System\RuntimeHandles.cs</Link>
</Compile>
- <Compile Include="..\..\Runtime.Base\src\System\RuntimeTypeHandle.cs">
- <Link>System\RuntimeTypeHandle.cs</Link>
- </Compile>
<Compile Include="..\..\Runtime.Base\src\System\Runtime\CompilerServices\EagerStaticClassConstructionAttribute.cs">
<Link>System\Runtime\CompilerServices\EagerStaticClassConstructionAttribute.cs</Link>
</Compile>
@@ -238,6 +235,8 @@
<Compile Include="System\Array.cs" />
<Compile Include="System\RuntimeExceptionHelpers.cs" />
<Compile Include="System\Object.cs" />
+ <Compile Include="System\Type.cs" />
+ <Compile Include="System\RuntimeTypeHandle.cs" />
<Compile Include="..\..\Common\src\Internal\Runtime\TypeManagerHandle.cs">
<Link>Internal\Runtime\TypeManagerHandle.cs</Link>
</Compile>