summaryrefslogtreecommitdiff
path: root/src/mscorlib/src/System/RuntimeHandles.cs
diff options
context:
space:
mode:
Diffstat (limited to 'src/mscorlib/src/System/RuntimeHandles.cs')
-rw-r--r--src/mscorlib/src/System/RuntimeHandles.cs98
1 files changed, 21 insertions, 77 deletions
diff --git a/src/mscorlib/src/System/RuntimeHandles.cs b/src/mscorlib/src/System/RuntimeHandles.cs
index ab125e741e..ceda5abfee 100644
--- a/src/mscorlib/src/System/RuntimeHandles.cs
+++ b/src/mscorlib/src/System/RuntimeHandles.cs
@@ -23,7 +23,6 @@ namespace System
using System.Diagnostics.Contracts;
using StackCrawlMark = System.Threading.StackCrawlMark;
- [Serializable]
public unsafe struct RuntimeTypeHandle : ISerializable
{
// Returns handle for interop with EE. The handle is guaranteed to be non-null.
@@ -127,6 +126,24 @@ namespace System
m_type = type;
}
+ internal static bool IsTypeDefinition(RuntimeType type)
+ {
+ CorElementType corElemType = GetCorElementType(type);
+ if (!((corElemType >= CorElementType.Void && corElemType < CorElementType.Ptr) ||
+ corElemType == CorElementType.ValueType ||
+ corElemType == CorElementType.Class ||
+ corElemType == CorElementType.TypedByRef ||
+ corElemType == CorElementType.I ||
+ corElemType == CorElementType.U ||
+ corElemType == CorElementType.Object))
+ return false;
+
+ if (HasInstantiation(type) && !IsGenericTypeDefinition(type))
+ return false;
+
+ return true;
+ }
+
internal static bool IsPrimitive(RuntimeType type)
{
CorElementType corElemType = GetCorElementType(type);
@@ -653,30 +670,9 @@ namespace System
return new MetadataImport(_GetMetadataImport(type), type);
}
- private RuntimeTypeHandle(SerializationInfo info, StreamingContext context)
- {
- if (info == null)
- throw new ArgumentNullException(nameof(info));
- Contract.EndContractBlock();
-
- RuntimeType m = (RuntimeType)info.GetValue("TypeObj", typeof(RuntimeType));
-
- m_type = m;
-
- if (m_type == null)
- throw new SerializationException(SR.Serialization_InsufficientState);
- }
-
public void GetObjectData(SerializationInfo info, StreamingContext context)
{
- if (info == null)
- throw new ArgumentNullException(nameof(info));
- Contract.EndContractBlock();
-
- if (m_type == null)
- throw new SerializationException(SR.Serialization_InvalidFieldState);
-
- info.AddValue("TypeObj", m_type, typeof(RuntimeType));
+ throw new PlatformNotSupportedException();
}
}
@@ -766,7 +762,6 @@ namespace System
}
}
- [Serializable]
public unsafe struct RuntimeMethodHandle : ISerializable
{
// Returns handle for interop with EE. The handle is guaranteed to be non-null.
@@ -796,33 +791,9 @@ namespace System
}
// ISerializable interface
- private RuntimeMethodHandle(SerializationInfo info, StreamingContext context)
- {
- if (info == null)
- throw new ArgumentNullException(nameof(info));
- Contract.EndContractBlock();
-
- MethodBase m = (MethodBase)info.GetValue("MethodObj", typeof(MethodBase));
-
- m_value = m.MethodHandle.m_value;
-
- if (m_value == null)
- throw new SerializationException(SR.Serialization_InsufficientState);
- }
-
public void GetObjectData(SerializationInfo info, StreamingContext context)
{
- if (info == null)
- throw new ArgumentNullException(nameof(info));
- Contract.EndContractBlock();
-
- if (m_value == null)
- throw new SerializationException(SR.Serialization_InvalidFieldState);
-
- // This is either a RuntimeMethodInfo or a RuntimeConstructorInfo
- MethodBase methodInfo = RuntimeType.GetMethodBase(m_value);
-
- info.AddValue("MethodObj", methodInfo, typeof(MethodBase));
+ throw new PlatformNotSupportedException();
}
public IntPtr Value
@@ -1149,7 +1120,6 @@ namespace System
}
}
- [Serializable]
public unsafe struct RuntimeFieldHandle : ISerializable
{
// Returns handle for interop with EE. The handle is guaranteed to be non-null.
@@ -1297,35 +1267,9 @@ namespace System
internal static extern void CheckAttributeAccess(RuntimeFieldHandle fieldHandle, RuntimeModule decoratedTarget);
// ISerializable interface
- private RuntimeFieldHandle(SerializationInfo info, StreamingContext context)
- {
- if (info == null)
- throw new ArgumentNullException(nameof(info));
- Contract.EndContractBlock();
-
- FieldInfo f = (RuntimeFieldInfo)info.GetValue("FieldObj", typeof(RuntimeFieldInfo));
-
- if (f == null)
- throw new SerializationException(SR.Serialization_InsufficientState);
-
- m_ptr = f.FieldHandle.m_ptr;
-
- if (m_ptr == null)
- throw new SerializationException(SR.Serialization_InsufficientState);
- }
-
public void GetObjectData(SerializationInfo info, StreamingContext context)
{
- if (info == null)
- throw new ArgumentNullException(nameof(info));
- Contract.EndContractBlock();
-
- if (m_ptr == null)
- throw new SerializationException(SR.Serialization_InvalidFieldState);
-
- RuntimeFieldInfo fldInfo = (RuntimeFieldInfo)RuntimeType.GetFieldInfo(this.GetRuntimeFieldInfo());
-
- info.AddValue("FieldObj", fldInfo, typeof(RuntimeFieldInfo));
+ throw new PlatformNotSupportedException();
}
}