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
{
}
[Serializable]
- internal class RuntimeType :
+ internal partial class RuntimeType :
#if !FEATURE_CORECLR || FEATURE_NETCORE
System.Reflection.TypeInfo,
#else
_count++;
}
}
-
+#if !MONO
internal class RuntimeTypeCache
{
private const int MAXNAMELEN = 1024;
#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
#region Static Members
#region Internal
+#if !MONO
internal static RuntimeType GetType(String typeName, bool throwOnError, bool ignoreCase, bool reflectionOnly,
ref StackCrawlMark stackMark)
{
Contract.Assume(false, "Unreachable code");
throw new SystemException();
}
-
+#endif
private static void ThrowIfTypeNeverValidGenericArgument(RuntimeType type)
{
if (type.IsPointer || type.IsByRef || type == typeof(void))
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)
{
}
}
}
-
+#endif
private static void SplitName(string fullname, out string name, out string ns)
{
name = null;
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)
{
#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;
#endregion
#region Private\Internal Members
+#if !MONO
[ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
internal override bool CacheEquals(object o)
{
return cache;
}
}
-
+#endif
internal bool IsSpecialSerializableType()
{
RuntimeType rt = this;
return false;
}
-
+#if !MONO
private string GetDefaultMemberName()
{
return Cache.GetDefaultMemberName();
{
return Cache.GetSerializationCtor();
}
+#endif
#endif
#endregion
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++)
{
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++)
{
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;
#else
RuntimePropertyInfo[] cache = Cache.GetPropertyList(listType, name);
#endif
-
+#endif
bindingAttr ^= BindingFlags.DeclaredOnly;
ListBuilder<PropertyInfo> candidates = new ListBuilder<PropertyInfo>(cache.Length);
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);
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);
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++)
{
return candidates;
}
+
#endregion
#region Get All XXXInfos
{
return GetFieldCandidates(null, bindingAttr, false).ToArray();
}
-
+#if !MONO
[System.Security.SecuritySafeCritical] // auto-generated
public override Type[] GetInterfaces()
{
return interfaces;
}
-
+#endif
public override Type[] GetNestedTypes(BindingFlags bindingAttr)
{
return GetNestedTypeCandidates(null, bindingAttr, false).ToArray();
return members;
}
-
+#if !MONO
[System.Security.SecuritySafeCritical] // auto-generated
public override InterfaceMapping GetInterfaceMap(Type ifaceType)
{
return im;
}
+#endif
#endregion
#region Find XXXInfo
Type[] types, ParameterModifier[] modifiers)
{
ListBuilder<MethodInfo> candidates = GetMethodCandidates(name, bindingAttr, callConv, types, false);
-
if (candidates.Count == 0)
return null;
return binder.SelectProperty(bindingAttr, candidates.ToArray(), returnType, types, modifiers);
}
-
public override EventInfo GetEvent(String name, BindingFlags bindingAttr)
{
if (name == null) throw new ArgumentNullException();
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;
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;
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++)
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++)
#endregion
#region Identity
+
public override Module Module
{
get
{
return new RuntimeTypeHandle(this);
}
-
+#if !MONO
[System.Security.SecuritySafeCritical]
internal bool IsCollectible()
{
return GetMethodBase(RuntimeMethodHandle.GetDeclaringType(declaringMethod), declaringMethod);
}
}
+#endif
#endregion
#region Hierarchy
}
}
#endregion
-
+#if !MONO
#region Name
public override String FullName
{
}
}
#endregion
-
+#endif
#region Attributes
[System.Security.SecuritySafeCritical] // auto-generated
#if !FEATURE_CORECLR
{
return RuntimeTypeHandle.GetAttributes(this);
}
-
+#if !MONO
public override Guid GUID
{
[System.Security.SecuritySafeCritical] // auto-generated
[ResourceExposure(ResourceScope.None)]
[MethodImplAttribute(MethodImplOptions.InternalCall)]
private extern void GetGUID(ref Guid result);
-
+#endif
[System.Security.SecuritySafeCritical] // auto-generated
protected override bool IsContextfulImpl()
{
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
#endif
get { return new RuntimeTypeHandle(this).IsSecurityTransparent(); }
}
+#endif
#endregion
#region Arrays
#endregion
#region Generics
+#if !MONO
internal RuntimeType[] GetGenericArgumentsInternal()
{
return GetRootElementType().GetTypeHandleInternal().GetInstantiationInternal();
return ret;
}
-
+#endif
public override bool IsGenericTypeDefinition
{
#if !FEATURE_CORECLR
if (!IsGenericParameter)
throw new InvalidOperationException(Environment.GetResourceString("Arg_NotGenericParameter"));
Contract.EndContractBlock();
-
+#if MONO
+ return GetGenericParameterPosition ();
+#else
return new RuntimeTypeHandle(this).GetGenericVariableIndex();
+#endif
}
}
{
get { return IsGenericType && !IsGenericTypeDefinition; }
}
-
+#if !MONO
public override bool ContainsGenericParameters
{
#if !FEATURE_CORECLR
return constraints;
}
+#endif
#endregion
-
+#if !MONO
#region Misc
[System.Security.SecuritySafeCritical] // auto-generated
public override Type MakePointerType() { return new RuntimeTypeHandle(this).MakePointer(); }
}
}
#endregion
-
+#endif
#region Invoke Member
private const BindingFlags MemberBindingMask = (BindingFlags)0x000000FF;
private const BindingFlags InvocationMask = (BindingFlags)0x0000FF00;
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)]
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()
return !object.ReferenceEquals(left, right);
}
#endif // !FEATURE_CORECLR
-
+#if !MONO
public override String ToString()
{
return GetCachedName(TypeNameKind.ToString);
}
+#endif
#endregion
#region ICloneable
#endregion
#region MemberInfo Overrides
+#if !MONO
public override String Name
{
#if !FEATURE_CORECLR
return typeName;
}
}
-
+
private string GetCachedName(TypeNameKind kind)
{
return Cache.GetName(kind);
}
-
+#endif
public override MemberTypes MemberType
{
get
return MemberTypes.NestedType;
}
}
-
+#if !MONO
public override Type DeclaringType
{
#if !FEATURE_CORECLR
return Cache.GetEnclosingType();
}
}
-
+#endif
public override Type ReflectedType
{
get
//Console.WriteLine(server);
return server;
}
-
+#if !MONO
// the cache entry
class ActivatorCacheEntry
{
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
{
if (GetType() == typeof(ReflectionOnlyType))
throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_NotAllowedInReflectionOnly"));
-
+#if !MONO
ActivatorCache activatorCache = s_ActivatorCache;
if (activatorCache != null)
{
return instance;
}
}
+#endif
return CreateInstanceSlow(publicOnly, skipCheckThis, fillCache, ref stackMark);
}
-
+#if !MONO
internal void InvalidateCachedNestedType()
{
Cache.InvalidateCachedNestedType();
{
return RuntimeTypeHandle.IsComObject(this, true);
}
+#endif
#endregion
-
+#if !MONO
#region Legacy Static Internal
[System.Security.SecurityCritical]
[ResourceExposure(ResourceScope.None)]
#endif
#endregion
-
+#endif
#region COM
#if FEATURE_COMINTEROP && FEATURE_REMOTING
[System.Security.SecuritySafeCritical] // auto-generated
}
}
-
+#if !MONO
#region Library
internal unsafe struct Utf8String
{
}
}
#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
}
}
}
+#endif
#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
{
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;
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());
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());
return t;
}
-
+#endif
#if !FEATURE_CORECLR
[MethodImplAttribute(MethodImplOptions.NoInlining)] // Methods containing StackCrawlMark local var has to be marked non-inlineable
public static Type GetType(
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
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]
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)]
[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 {
get {return IsCOMObjectImpl();}
}
-#if FEATURE_COMINTEROP
+#if FEATURE_COMINTEROP || MONO_COM
internal bool IsWindowsRuntimeObject {
[Pure]
get { return IsWindowsRuntimeObjectImpl(); }
// 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();
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]
[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")]