Mono friendly Type
authorMarek Safar <marek.safar@gmail.com>
Wed, 11 Mar 2015 09:04:58 +0000 (10:04 +0100)
committerMarek Safar <marek.safar@gmail.com>
Mon, 2 May 2016 22:08:01 +0000 (00:08 +0200)
mcs/class/referencesource/mscorlib/system/rttype.cs
mcs/class/referencesource/mscorlib/system/type.cs

index 80740fd95865cd9fb6a9642e3b5690f0d62be948..49ea48f404a1dfe8295a5c3d20beb29973304642 100644 (file)
@@ -34,15 +34,22 @@ using System.Runtime.Remoting.Messaging;
 using System.Runtime.Remoting.Activation;
 using System.Runtime.Remoting.Metadata;
 #endif
+#if !MONO
 using MdSigCallingConvention = System.Signature.MdSigCallingConvention;
 using RuntimeTypeCache = System.RuntimeType.RuntimeTypeCache;
+#endif
 using System.Runtime.InteropServices;
 using DebuggerStepThroughAttribute = System.Diagnostics.DebuggerStepThroughAttribute;
+#if !MONO
 using MdToken = System.Reflection.MetadataToken;
+#endif
 using System.Runtime.Versioning;
 using System.Diagnostics.Contracts;
 using System.Diagnostics.Tracing;
 
+#if MONO
+using CustomAttribute=System.MonoCustomAttrs;
+#endif
 
 namespace System 
 {
@@ -85,7 +92,7 @@ namespace System
     }
 
     [Serializable]
-    internal class RuntimeType : 
+    internal partial class RuntimeType :
 #if !FEATURE_CORECLR || FEATURE_NETCORE
         System.Reflection.TypeInfo, 
 #else
@@ -201,7 +208,7 @@ namespace System
                 _count++;
             }
         }
-
+#if !MONO
         internal class RuntimeTypeCache
         {
             private const int MAXNAMELEN = 1024;
@@ -1933,9 +1940,10 @@ namespace System
 
             #endregion
         }
+#endif
         #endregion
 
-#if FEATURE_REMOTING
+#if FEATURE_REMOTING && !MONO
         #region Legacy Remoting Cache
         // The size of CachedData is accounted for by BaseObjectWithCachedData in object.h.
         // This member is currently being used by Remoting for caching remoting data. If you
@@ -1968,6 +1976,7 @@ namespace System
         #region Static Members
 
         #region Internal
+#if !MONO
         internal static RuntimeType GetType(String typeName, bool throwOnError, bool ignoreCase, bool reflectionOnly,
             ref StackCrawlMark stackMark)
         {
@@ -2195,7 +2204,7 @@ namespace System
             Contract.Assume(false, "Unreachable code");
             throw new SystemException();
         }
-
+#endif
         private static void ThrowIfTypeNeverValidGenericArgument(RuntimeType type)
         {
             if (type.IsPointer || type.IsByRef || type == typeof(void))
@@ -2222,7 +2231,7 @@ namespace System
                 throw new ArgumentException(
                     Environment.GetResourceString("Argument_NotEnoughGenArguments", genericArguments.Length, genericParamters.Length));
         }
-        
+#if !MONO
         [System.Security.SecuritySafeCritical]  // auto-generated
         internal static void ValidateGenericArguments(MemberInfo definition, RuntimeType[] genericArguments, Exception e)
         {
@@ -2263,7 +2272,7 @@ namespace System
                 }
             }
         }
-
+#endif
         private static void SplitName(string fullname, out string name, out string ns)
         {
             name = null;
@@ -2517,12 +2526,12 @@ namespace System
             Contract.Requires(methodBase != null);
 
             bindingFlags ^= BindingFlags.DeclaredOnly;
-
+#if !MONO
             #region Apply Base Filter
             if ((bindingFlags & methodFlags) != methodFlags)
                 return false;
             #endregion
-
+#endif
             #region Check CallingConvention
             if ((callConv & CallingConventions.Any) == 0)
             {
@@ -2645,13 +2654,14 @@ namespace System
         #endregion
 
         #region Private Data Members
+#if !MONO
         private object m_keepalive; // This will be filled with a LoaderAllocator reference when this RuntimeType represents a collectible type
         private IntPtr m_cache;
         #if !FEATURE_CORECLR
         [System.Runtime.ForceTokenStabilization]
         #endif //!FEATURE_CORECLR
         internal IntPtr m_handle;
-
+#endif
 #if FEATURE_APPX
         private INVOCATION_FLAGS m_invocationFlags;
 
@@ -2726,6 +2736,7 @@ namespace System
         #endregion
 
         #region Private\Internal Members
+#if !MONO
         [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
         internal override bool CacheEquals(object o)
         {
@@ -2767,7 +2778,7 @@ namespace System
                 return cache;
             }
         }
-
+#endif
         internal bool IsSpecialSerializableType()
         {
             RuntimeType rt = this;
@@ -2785,7 +2796,7 @@ namespace System
 
             return false;
         }
-
+#if !MONO
         private string GetDefaultMemberName()
         {
             return Cache.GetDefaultMemberName();
@@ -2796,6 +2807,7 @@ namespace System
         {
             return Cache.GetSerializationCtor();
         }
+#endif
 #endif
         #endregion
 
@@ -2810,8 +2822,11 @@ namespace System
             MemberListType listType;
             RuntimeType.FilterHelper(bindingAttr, ref name, allowPrefixLookup, out prefixLookup, out ignoreCase, out listType);
 
+#if MONO
+            RuntimeMethodInfo[] cache = GetMethodsByName (name, bindingAttr, ignoreCase, this);
+#else
             RuntimeMethodInfo[] cache = Cache.GetMethodList(listType, name);
-
+#endif
             ListBuilder<MethodInfo> candidates = new ListBuilder<MethodInfo>(cache.Length);
             for (int i = 0; i < cache.Length; i++)
             {
@@ -2834,8 +2849,13 @@ namespace System
             MemberListType listType;
             RuntimeType.FilterHelper(bindingAttr, ref name, allowPrefixLookup, out prefixLookup, out ignoreCase, out listType);
 
+#if MONO
+            if (name != null && name != ConstructorInfo.ConstructorName && name != ConstructorInfo.TypeConstructorName)
+                return new ListBuilder<ConstructorInfo> (0);
+            RuntimeConstructorInfo[] cache = GetConstructors_internal (bindingAttr, this);
+#else
             RuntimeConstructorInfo[] cache = Cache.GetConstructorList(listType, name);
-
+#endif
             ListBuilder<ConstructorInfo> candidates = new ListBuilder<ConstructorInfo>(cache.Length);
             for (int i = 0; i < cache.Length; i++)
             {
@@ -2858,6 +2878,9 @@ namespace System
             MemberListType listType;
             RuntimeType.FilterHelper(bindingAttr, ref name, allowPrefixLookup, out prefixLookup, out ignoreCase, out listType);
 
+#if MONO
+            RuntimePropertyInfo[] cache = GetPropertiesByName (name, bindingAttr, ignoreCase, this);
+#else
 #if FEATURE_LEGACYNETCF
             // Dev11 466969 quirk
             IReadOnlyList<RuntimePropertyInfo> ambiguousProperties = null;
@@ -2865,7 +2888,7 @@ namespace System
 #else
             RuntimePropertyInfo[] cache = Cache.GetPropertyList(listType, name);
 #endif
-
+#endif
             bindingAttr ^= BindingFlags.DeclaredOnly;
 
             ListBuilder<PropertyInfo> candidates = new ListBuilder<PropertyInfo>(cache.Length);
@@ -2973,8 +2996,11 @@ namespace System
             MemberListType listType;
             RuntimeType.FilterHelper(bindingAttr, ref name, allowPrefixLookup, out prefixLookup, out ignoreCase, out listType);
 
+#if MONO
+            RuntimeEventInfo[] cache = GetEvents_internal (name, bindingAttr, this);
+#else
             RuntimeEventInfo[] cache = Cache.GetEventList(listType, name);
-
+#endif
             bindingAttr ^= BindingFlags.DeclaredOnly;
 
             ListBuilder<EventInfo> candidates = new ListBuilder<EventInfo>(cache.Length);
@@ -2997,8 +3023,11 @@ namespace System
             MemberListType listType;
             RuntimeType.FilterHelper(bindingAttr, ref name, allowPrefixLookup, out prefixLookup, out ignoreCase, out listType);
 
+#if MONO
+            RuntimeFieldInfo[] cache = GetFields_internal (name, bindingAttr, this);
+#else
             RuntimeFieldInfo[] cache = Cache.GetFieldList(listType, name);
-
+#endif
             bindingAttr ^= BindingFlags.DeclaredOnly;
 
             ListBuilder<FieldInfo> candidates = new ListBuilder<FieldInfo>(cache.Length);
@@ -3024,8 +3053,11 @@ namespace System
             SplitName(fullname, out name, out ns);            
             RuntimeType.FilterHelper(bindingAttr, ref name, allowPrefixLookup, out prefixLookup, out ignoreCase, out listType);
 
+#if MONO
+            RuntimeType[] cache = GetNestedTypes_internal (name, bindingAttr);
+#else
             RuntimeType[] cache = Cache.GetNestedTypeList(listType, name);
-
+#endif
             ListBuilder<Type> candidates = new ListBuilder<Type>(cache.Length);
             for (int i = 0; i < cache.Length; i++)
             {
@@ -3038,6 +3070,7 @@ namespace System
 
             return candidates;
         }
+
         #endregion
 
         #region Get All XXXInfos
@@ -3066,7 +3099,7 @@ namespace System
         {
             return GetFieldCandidates(null, bindingAttr, false).ToArray();
         }
-
+#if !MONO
         [System.Security.SecuritySafeCritical]  // auto-generated
         public override Type[] GetInterfaces()
         {
@@ -3077,7 +3110,7 @@ namespace System
 
               return interfaces;
         }
-
+#endif
         public override Type[] GetNestedTypes(BindingFlags bindingAttr)
         {
             return GetNestedTypeCandidates(null, bindingAttr, false).ToArray();
@@ -3112,7 +3145,7 @@ namespace System
 
             return members;
         }
-
+#if !MONO
         [System.Security.SecuritySafeCritical]  // auto-generated
         public override InterfaceMapping GetInterfaceMap(Type ifaceType)
         {
@@ -3172,6 +3205,7 @@ namespace System
 
             return im;
         }
+#endif
         #endregion
 
         #region Find XXXInfo
@@ -3180,7 +3214,6 @@ namespace System
             Type[] types, ParameterModifier[] modifiers) 
         {       
             ListBuilder<MethodInfo> candidates = GetMethodCandidates(name, bindingAttr, callConv, types, false);
-
             if (candidates.Count == 0) 
                 return null;
 
@@ -3285,7 +3318,6 @@ namespace System
             return binder.SelectProperty(bindingAttr, candidates.ToArray(), returnType, types, modifiers);
         }
 
-
         public override EventInfo GetEvent(String name, BindingFlags bindingAttr) 
         {
             if (name == null) throw new ArgumentNullException();
@@ -3294,8 +3326,12 @@ namespace System
             bool ignoreCase;
             MemberListType listType;
             RuntimeType.FilterHelper(bindingAttr, ref name, out ignoreCase, out listType);
-            
+
+#if MONO
+            RuntimeEventInfo[] cache = GetEvents_internal (name, bindingAttr, this);
+#else
             RuntimeEventInfo[] cache = Cache.GetEventList(listType, name);
+#endif
             EventInfo match = null;
 
             bindingAttr ^= BindingFlags.DeclaredOnly;
@@ -3324,7 +3360,11 @@ namespace System
             MemberListType listType;
             RuntimeType.FilterHelper(bindingAttr, ref name, out ignoreCase, out listType);
 
+#if MONO
+            RuntimeFieldInfo[] cache = GetFields_internal (name, bindingAttr, this); 
+#else
             RuntimeFieldInfo[] cache = Cache.GetFieldList(listType, name);
+#endif
             FieldInfo match = null;
 
             bindingAttr ^= BindingFlags.DeclaredOnly;
@@ -3372,8 +3412,25 @@ namespace System
             SplitName(fullname, out name, out ns);            
             RuntimeType.FilterHelper(bindingAttr, ref name, out ignoreCase, out listType);
 
-            RuntimeType[] cache = Cache.GetInterfaceList(listType, name);            
+#if MONO
+            List<RuntimeType> list = null;
+            foreach (RuntimeType t in GetInterfaces ()) {
+                if (t.Name != name)
+                    continue;
+
+                if (list == null)
+                    list = new List<RuntimeType> (2);
 
+                list.Add (t);
+            }
+
+            if (list == null)
+                return null;
+
+            var cache = list.ToArray ();
+#else
+            RuntimeType[] cache = Cache.GetInterfaceList(listType, name);
+#endif
             RuntimeType match = null;
 
             for (int i = 0; i < cache.Length; i++)
@@ -3402,9 +3459,11 @@ namespace System
             MemberListType listType;
             SplitName(fullname, out name, out ns);            
             RuntimeType.FilterHelper(bindingAttr, ref name, out ignoreCase, out listType);
-
+#if MONO
+            RuntimeType[] cache = GetNestedTypes_internal (name, bindingAttr);
+#else
             RuntimeType[] cache = Cache.GetNestedTypeList(listType, name);
-
+#endif
             RuntimeType match = null;
 
             for (int i = 0; i < cache.Length; i++)
@@ -3507,6 +3566,7 @@ namespace System
         #endregion
 
         #region Identity
+
         public override Module Module
         {
             get
@@ -3555,7 +3615,7 @@ namespace System
         {
             return new RuntimeTypeHandle(this);
         }
-
+#if !MONO
         [System.Security.SecuritySafeCritical]
         internal bool IsCollectible()
         {
@@ -3640,6 +3700,7 @@ namespace System
                 return GetMethodBase(RuntimeMethodHandle.GetDeclaringType(declaringMethod), declaringMethod);
             }
         }
+#endif
         #endregion
 
         #region Hierarchy
@@ -3811,7 +3872,7 @@ namespace System
             }
         }
         #endregion
-
+#if !MONO
         #region Name
         public override String FullName 
         {
@@ -3881,7 +3942,7 @@ namespace System
             }
         }
         #endregion
-
+#endif
         #region Attributes
         [System.Security.SecuritySafeCritical]  // auto-generated
 #if !FEATURE_CORECLR
@@ -3891,7 +3952,7 @@ namespace System
         {
             return RuntimeTypeHandle.GetAttributes(this);
         }
-
+#if !MONO
         public override Guid GUID 
         {
             [System.Security.SecuritySafeCritical]  // auto-generated
@@ -3907,7 +3968,7 @@ namespace System
         [ResourceExposure(ResourceScope.None)]
         [MethodImplAttribute(MethodImplOptions.InternalCall)]
         private extern void GetGUID(ref Guid result);
-
+#endif
         [System.Security.SecuritySafeCritical]  // auto-generated
         protected override bool IsContextfulImpl() 
         {
@@ -4024,14 +4085,18 @@ namespace System
                     throw new InvalidOperationException(Environment.GetResourceString("Arg_NotGenericParameter"));
                 Contract.EndContractBlock();
 
+#if MONO
+                return GetGenericParameterAttributes ();
+#else
                 GenericParameterAttributes attributes;
 
                 RuntimeTypeHandle.GetMetadataImport(this).GetGenericParamProps(MetadataToken, out attributes);
 
                 return attributes;
+#endif
             }
         }
-
+#if !MONO
         public override bool IsSecurityCritical 
         {
 #if !FEATURE_CORECLR
@@ -4053,6 +4118,7 @@ namespace System
 #endif
             get { return new RuntimeTypeHandle(this).IsSecurityTransparent(); }
         }
+#endif
         #endregion
 
         #region Arrays
@@ -4217,6 +4283,7 @@ namespace System
         #endregion
 
         #region Generics
+#if !MONO
         internal RuntimeType[] GetGenericArgumentsInternal()
         {
             return GetRootElementType().GetTypeHandleInternal().GetInstantiationInternal();
@@ -4285,7 +4352,7 @@ namespace System
 
             return ret;
         }
-
+#endif
         public override bool IsGenericTypeDefinition
         {
 #if !FEATURE_CORECLR
@@ -4309,8 +4376,11 @@ namespace System
                 if (!IsGenericParameter)
                     throw new InvalidOperationException(Environment.GetResourceString("Arg_NotGenericParameter"));
                 Contract.EndContractBlock();
-            
+#if MONO
+                return GetGenericParameterPosition ();
+#else
                 return new RuntimeTypeHandle(this).GetGenericVariableIndex(); 
+#endif
             }
         }
 
@@ -4338,7 +4408,7 @@ namespace System
         {
             get { return IsGenericType && !IsGenericTypeDefinition; }
         }
-
+#if !MONO
         public override bool ContainsGenericParameters
         {
 #if !FEATURE_CORECLR
@@ -4360,8 +4430,9 @@ namespace System
 
             return constraints;
         }
+#endif
         #endregion
-
+#if !MONO
         #region Misc
         [System.Security.SecuritySafeCritical]  // auto-generated
         public override Type MakePointerType() { return new RuntimeTypeHandle(this).MakePointer(); }
@@ -4384,7 +4455,7 @@ namespace System
             } 
         }
         #endregion
-
+#endif
         #region Invoke Member
         private const BindingFlags MemberBindingMask        = (BindingFlags)0x000000FF;
         private const BindingFlags InvocationMask           = (BindingFlags)0x0000FF00;
@@ -4398,7 +4469,7 @@ namespace System
             BindingFlags.InvokeMethod | BindingFlags.GetProperty | BindingFlags.SetProperty | 
             BindingFlags.PutDispProperty | BindingFlags.PutRefDispProperty;
         private static RuntimeType s_typedRef = (RuntimeType)typeof(TypedReference);
-
+#if !MONO
         [System.Security.SecurityCritical]  // auto-generated
         [ResourceExposure(ResourceScope.None)]
         [MethodImplAttribute(MethodImplOptions.InternalCall)]
@@ -4534,7 +4605,7 @@ namespace System
 
             throw new ArgumentException(String.Format(CultureInfo.CurrentUICulture, Environment.GetResourceString("Arg_ObjObjEx"), value.GetType(), this));
         }
-
+#endif
         // GetDefaultMembers
         // This will return a MemberInfo that has been marked with the [DefaultMemberAttribute]
         public override MemberInfo[] GetDefaultMembers()
@@ -5053,11 +5124,12 @@ namespace System
             return !object.ReferenceEquals(left, right);
         }
 #endif // !FEATURE_CORECLR
-
+#if !MONO
         public override String ToString() 
         {
             return GetCachedName(TypeNameKind.ToString);
         }
+#endif
         #endregion
 
         #region ICloneable
@@ -5123,6 +5195,7 @@ namespace System
         #endregion
 
         #region MemberInfo Overrides
+#if !MONO
         public override String Name 
         {
 #if !FEATURE_CORECLR
@@ -5198,12 +5271,12 @@ namespace System
                 return typeName;
             }
         }
-        
+
         private string GetCachedName(TypeNameKind kind)
         {
             return Cache.GetName(kind);
         }
-
+#endif
         public override MemberTypes MemberType 
         {
             get 
@@ -5214,7 +5287,7 @@ namespace System
                     return MemberTypes.NestedType;
             }
         }
-
+#if !MONO
         public override Type DeclaringType 
         {
 #if !FEATURE_CORECLR
@@ -5225,7 +5298,7 @@ namespace System
                 return Cache.GetEnclosingType();
             }
         }
-
+#endif
         public override Type ReflectedType 
         {
             get 
@@ -5440,7 +5513,7 @@ namespace System
             //Console.WriteLine(server);
             return server;                                
         }
-
+#if !MONO
         // the cache entry
         class ActivatorCacheEntry
         {
@@ -5584,7 +5657,7 @@ namespace System
 
             return instance;
         }
-
+#endif
         // Helper to invoke the default (parameterless) ctor.
         // fillCache is set in the SL2/3 compat mode or when called from Marshal.PtrToStructure.
         [System.Security.SecuritySafeCritical]  // auto-generated
@@ -5594,7 +5667,7 @@ namespace System
         {
             if (GetType() == typeof(ReflectionOnlyType))
                 throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_NotAllowedInReflectionOnly"));
-
+#if !MONO
             ActivatorCache activatorCache = s_ActivatorCache;
             if (activatorCache != null)
             {
@@ -5635,9 +5708,10 @@ namespace System
                     return instance;
                 }
             }
+#endif
             return CreateInstanceSlow(publicOnly, skipCheckThis, fillCache, ref stackMark);
         }
-
+#if !MONO
         internal void InvalidateCachedNestedType()
         {
             Cache.InvalidateCachedNestedType();
@@ -5648,8 +5722,9 @@ namespace System
         {
             return RuntimeTypeHandle.IsComObject(this, true);
         }
+#endif
         #endregion
-
+#if !MONO
         #region Legacy Static Internal
         [System.Security.SecurityCritical]
         [ResourceExposure(ResourceScope.None)]
@@ -5693,7 +5768,7 @@ namespace System
 #endif
 
         #endregion
-
+#endif
         #region COM
 #if FEATURE_COMINTEROP && FEATURE_REMOTING
         [System.Security.SecuritySafeCritical]  // auto-generated
@@ -5929,7 +6004,7 @@ namespace System
         }
 
     }
-
+#if !MONO
     #region Library
     internal unsafe struct Utf8String
     {
@@ -6053,8 +6128,9 @@ namespace System
         }
     }
     #endregion
+#endif
 }
-
+#if !MONO
 namespace System.Reflection
 {
     // Reliable hashtable thread safe for multiple readers and single writer. Note that the reliability goes together with thread
@@ -6216,3 +6292,4 @@ namespace System.Reflection
         }
     }
 }
+#endif
index 38d9d6abff08eeb100c221a583753baa8a756705..a265f6d31f44177ebbdca95b2c8b4b1eefd31151 100644 (file)
@@ -39,7 +39,7 @@ namespace System {
 #if CONTRACTS_FULL
     [ContractClass(typeof(TypeContracts))]
 #endif
-    public abstract class Type : MemberInfo, _Type, IReflect
+    public abstract partial class Type : MemberInfo, _Type, IReflect
     {
         //
         // System.Type is appdomain agile type. Appdomain agile types cannot have precise static constructors. Make
@@ -94,7 +94,7 @@ namespace System {
         {
             return base.GetType();
         }
-
+#if !MONO
         [MethodImplAttribute(MethodImplOptions.NoInlining)] // Methods containing StackCrawlMark local var has to be marked non-inlineable
         public static Type GetType(String typeName, bool throwOnError, bool ignoreCase) {
             StackCrawlMark stackMark = StackCrawlMark.LookForMyCaller;
@@ -106,7 +106,7 @@ namespace System {
             StackCrawlMark stackMark = StackCrawlMark.LookForMyCaller;
             Type t = RuntimeType.GetType(typeName, throwOnError, false, false, ref stackMark);
 
-#if !FEATURE_CORECLR           
+#if !FEATURE_CORECLR && !MONO
             if (FrameworkEventSource.IsInitialized && FrameworkEventSource.Log.IsEnabled(EventLevel.Informational, FrameworkEventSource.Keywords.DynamicTypeUsage) && t != null)
             {
                 FrameworkEventSource.Log.TypeGetType(t.GetFullNameForEtw());
@@ -120,7 +120,7 @@ namespace System {
             StackCrawlMark stackMark = StackCrawlMark.LookForMyCaller;
             Type t = RuntimeType.GetType(typeName, false, false, false, ref stackMark);
 
-#if !FEATURE_CORECLR
+#if !FEATURE_CORECLR && !MONO
             if (FrameworkEventSource.IsInitialized && FrameworkEventSource.Log.IsEnabled(EventLevel.Informational, FrameworkEventSource.Keywords.DynamicTypeUsage) && t != null)
             {
                 FrameworkEventSource.Log.TypeGetType(t.GetFullNameForEtw());
@@ -129,7 +129,7 @@ namespace System {
 
             return t;
         }
-
+#endif
 #if !FEATURE_CORECLR
         [MethodImplAttribute(MethodImplOptions.NoInlining)] // Methods containing StackCrawlMark local var has to be marked non-inlineable
         public static Type GetType(
@@ -164,21 +164,21 @@ namespace System {
             return TypeNameParser.GetType(typeName, assemblyResolver, typeResolver, throwOnError, ignoreCase, ref stackMark);
         }
 #endif //!FEATURE_CORECLR
-
+#if !MONO
         [MethodImplAttribute(MethodImplOptions.NoInlining)] // Methods containing StackCrawlMark local var has to be marked non-inlineable
         public static Type ReflectionOnlyGetType(String typeName, bool throwIfNotFound, bool ignoreCase) 
         {
             StackCrawlMark stackMark = StackCrawlMark.LookForMyCaller;
             return RuntimeType.GetType(typeName, throwIfNotFound, ignoreCase, true /*reflectionOnly*/, ref stackMark);
         }
-
+#endif
         public virtual Type MakePointerType() { throw new NotSupportedException(); }
         public virtual StructLayoutAttribute StructLayoutAttribute { get { throw new NotSupportedException(); } }
         public virtual Type MakeByRefType() { throw new NotSupportedException(); }
         public virtual Type MakeArrayType() { throw new NotSupportedException(); }
         public virtual Type MakeArrayType(int rank) { throw new NotSupportedException(); }
 
-#if FEATURE_COMINTEROP
+#if FEATURE_COMINTEROP || MONO_COM
         ////////////////////////////////////////////////////////////////////////////////
         // This will return a class based upon the progID.  This is provided for 
         // COM classic support.  Program ID's are not used in COM+ because they 
@@ -341,11 +341,18 @@ namespace System {
             return InvokeMember(name,invokeAttr,binder,target,args,null,null,null);
         }
 
-
+#if MONO
+        // Workaround for JIT bug with bad VTable lookup
+        //
+        //      MemberInfo mi = typeof (System.DBNull);
+        //      System.Console.WriteLine (mi.Module);
+        //
+        public override abstract Module Module { get; }
+#else
         // Module Property associated with a class.
         // _Type.Module
         public new abstract Module Module { get; }
-
+#endif
         // Assembly Property associated with a class.
         public abstract Assembly Assembly {
             [Pure]
@@ -377,7 +384,7 @@ namespace System {
 
             return new RuntimeTypeHandle((RuntimeType)o.GetType());
         }
-
+#if !MONO
         // Given a class handle, this will return the class for that handle.
         [System.Security.SecurityCritical]
         [ResourceExposure(ResourceScope.None)]
@@ -389,7 +396,7 @@ namespace System {
         [ResourceExposure(ResourceScope.None)]
         [MethodImpl(MethodImplOptions.InternalCall)]
         public static extern Type GetTypeFromHandle(RuntimeTypeHandle handle);
-
+#endif
 
         // Return the fully qualified name.  The name does contain the namespace.
         public abstract String FullName {
@@ -1284,7 +1291,7 @@ namespace System {
             get {return IsCOMObjectImpl();}
         }
 
-#if FEATURE_COMINTEROP
+#if FEATURE_COMINTEROP || MONO_COM
         internal bool IsWindowsRuntimeObject {
             [Pure]
             get { return IsWindowsRuntimeObjectImpl(); }
@@ -1351,7 +1358,7 @@ namespace System {
         // Protected routine to determine if this class represents a COM object
         abstract protected bool IsCOMObjectImpl();
 
-#if FEATURE_COMINTEROP
+#if FEATURE_COMINTEROP || MONO_COM
         // Protected routine to determine if this class represents a Windows Runtime object
         virtual internal bool IsWindowsRuntimeObjectImpl() {
             throw new NotImplementedException();
@@ -1854,6 +1861,17 @@ namespace System {
             return (Object.ReferenceEquals(this.UnderlyingSystemType, o.UnderlyingSystemType));
         }
 
+#if MONO
+        public static bool operator == (Type left, Type right)
+        {
+            return object.ReferenceEquals (left, right);
+        }
+
+        public static bool operator != (Type left, Type right)
+        {
+            return !object.ReferenceEquals (left, right);
+        }
+#else
 #if !FEATURE_CORECLR
         [System.Security.SecuritySafeCritical]
         [Pure]
@@ -1867,6 +1885,7 @@ namespace System {
         [MethodImplAttribute(MethodImplOptions.InternalCall)]
         public static extern bool operator !=(Type left, Type right);
 #endif // !FEATURE_CORECLR
+#endif
 
 #if !FEATURE_CORECLR
         [TargetedPatchingOptOut("Performance critical to inline across NGen image boundaries")]