2011-01-13 13:44:44 +03:00
|
|
|
|
/*
|
|
|
|
|
Copyright (C) 2011 Jeroen Frijters
|
|
|
|
|
|
|
|
|
|
This software is provided 'as-is', without any express or implied
|
|
|
|
|
warranty. In no event will the authors be held liable for any damages
|
|
|
|
|
arising from the use of this software.
|
|
|
|
|
|
|
|
|
|
Permission is granted to anyone to use this software for any purpose,
|
|
|
|
|
including commercial applications, and to alter it and redistribute it
|
|
|
|
|
freely, subject to the following restrictions:
|
|
|
|
|
|
|
|
|
|
1. The origin of this software must not be misrepresented; you must not
|
|
|
|
|
claim that you wrote the original software. If you use this software
|
|
|
|
|
in a product, an acknowledgment in the product documentation would be
|
|
|
|
|
appreciated but is not required.
|
|
|
|
|
2. Altered source versions must be plainly marked as such, and must not be
|
|
|
|
|
misrepresented as being the original software.
|
|
|
|
|
3. This notice may not be removed or altered from any source distribution.
|
|
|
|
|
|
|
|
|
|
Jeroen Frijters
|
|
|
|
|
jeroen@frijters.net
|
|
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
using System;
|
2011-01-26 09:59:57 +03:00
|
|
|
|
using System.Text;
|
2011-01-13 13:44:44 +03:00
|
|
|
|
using System.Collections.Generic;
|
2011-01-13 17:47:21 +03:00
|
|
|
|
using System.Runtime.InteropServices;
|
2011-01-13 13:44:44 +03:00
|
|
|
|
|
|
|
|
|
namespace IKVM.Reflection
|
|
|
|
|
{
|
2011-01-13 17:33:02 +03:00
|
|
|
|
[Serializable]
|
|
|
|
|
public sealed class MissingAssemblyException : InvalidOperationException
|
|
|
|
|
{
|
|
|
|
|
[NonSerialized]
|
|
|
|
|
private readonly MissingAssembly assembly;
|
|
|
|
|
|
|
|
|
|
internal MissingAssemblyException(MissingAssembly assembly)
|
|
|
|
|
: base("Assembly '" + assembly.FullName + "' is a missing assembly and does not support the requested operation.")
|
|
|
|
|
{
|
|
|
|
|
this.assembly = assembly;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private MissingAssemblyException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context)
|
|
|
|
|
: base(info, context)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Assembly Assembly
|
|
|
|
|
{
|
|
|
|
|
get { return assembly; }
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Serializable]
|
|
|
|
|
public sealed class MissingModuleException : InvalidOperationException
|
|
|
|
|
{
|
|
|
|
|
[NonSerialized]
|
|
|
|
|
private readonly MissingModule module;
|
|
|
|
|
|
|
|
|
|
internal MissingModuleException(MissingModule module)
|
|
|
|
|
: base("Module from missing assembly '" + module.Assembly.FullName + "' does not support the requested operation.")
|
|
|
|
|
{
|
|
|
|
|
this.module = module;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private MissingModuleException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context)
|
|
|
|
|
: base(info, context)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Module Module
|
|
|
|
|
{
|
|
|
|
|
get { return module; }
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Serializable]
|
|
|
|
|
public sealed class MissingMemberException : InvalidOperationException
|
|
|
|
|
{
|
|
|
|
|
[NonSerialized]
|
|
|
|
|
private readonly MemberInfo member;
|
|
|
|
|
|
|
|
|
|
internal MissingMemberException(MemberInfo member)
|
|
|
|
|
: base("Member '" + member + "' is a missing member and does not support the requested operation.")
|
|
|
|
|
{
|
|
|
|
|
this.member = member;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private MissingMemberException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context)
|
|
|
|
|
: base(info, context)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public MemberInfo MemberInfo
|
|
|
|
|
{
|
|
|
|
|
get { return member; }
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2011-01-13 13:44:44 +03:00
|
|
|
|
sealed class MissingAssembly : Assembly
|
|
|
|
|
{
|
|
|
|
|
private readonly MissingModule module;
|
|
|
|
|
private readonly string name;
|
|
|
|
|
|
|
|
|
|
internal MissingAssembly(Universe universe, string name)
|
|
|
|
|
: base(universe)
|
|
|
|
|
{
|
|
|
|
|
module = new MissingModule(this);
|
|
|
|
|
this.name = name;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override Type[] GetTypes()
|
|
|
|
|
{
|
2011-01-13 17:33:02 +03:00
|
|
|
|
throw new MissingAssemblyException(this);
|
2011-01-13 13:44:44 +03:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override string FullName
|
|
|
|
|
{
|
|
|
|
|
get { return name; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override AssemblyName GetName()
|
|
|
|
|
{
|
|
|
|
|
return new AssemblyName(name);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override string ImageRuntimeVersion
|
|
|
|
|
{
|
2011-01-13 17:33:02 +03:00
|
|
|
|
get { throw new MissingAssemblyException(this); }
|
2011-01-13 13:44:44 +03:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override Module ManifestModule
|
|
|
|
|
{
|
|
|
|
|
get { return module; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override MethodInfo EntryPoint
|
|
|
|
|
{
|
2011-01-13 17:33:02 +03:00
|
|
|
|
get { throw new MissingAssemblyException(this); }
|
2011-01-13 13:44:44 +03:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override string Location
|
|
|
|
|
{
|
2011-01-13 17:33:02 +03:00
|
|
|
|
get { throw new MissingAssemblyException(this); }
|
2011-01-13 13:44:44 +03:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override AssemblyName[] GetReferencedAssemblies()
|
|
|
|
|
{
|
2011-01-13 17:33:02 +03:00
|
|
|
|
throw new MissingAssemblyException(this);
|
2011-01-13 13:44:44 +03:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override Module[] GetModules(bool getResourceModules)
|
|
|
|
|
{
|
2011-01-13 17:33:02 +03:00
|
|
|
|
throw new MissingAssemblyException(this);
|
2011-01-13 13:44:44 +03:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override Module[] GetLoadedModules(bool getResourceModules)
|
|
|
|
|
{
|
2011-01-13 17:33:02 +03:00
|
|
|
|
throw new MissingAssemblyException(this);
|
2011-01-13 13:44:44 +03:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override Module GetModule(string name)
|
|
|
|
|
{
|
2011-01-13 17:33:02 +03:00
|
|
|
|
throw new MissingAssemblyException(this);
|
2011-01-13 13:44:44 +03:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override string[] GetManifestResourceNames()
|
|
|
|
|
{
|
2011-01-13 17:33:02 +03:00
|
|
|
|
throw new MissingAssemblyException(this);
|
2011-01-13 13:44:44 +03:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override ManifestResourceInfo GetManifestResourceInfo(string resourceName)
|
|
|
|
|
{
|
2011-01-13 17:33:02 +03:00
|
|
|
|
throw new MissingAssemblyException(this);
|
2011-01-13 13:44:44 +03:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override System.IO.Stream GetManifestResourceStream(string resourceName)
|
|
|
|
|
{
|
2011-01-13 17:33:02 +03:00
|
|
|
|
throw new MissingAssemblyException(this);
|
2011-01-13 13:44:44 +03:00
|
|
|
|
}
|
|
|
|
|
|
2011-01-13 18:44:28 +03:00
|
|
|
|
public override bool __IsMissing
|
|
|
|
|
{
|
|
|
|
|
get { return true; }
|
|
|
|
|
}
|
|
|
|
|
|
2011-01-20 08:38:11 +03:00
|
|
|
|
internal override Type FindType(TypeName typeName)
|
2011-01-13 13:44:44 +03:00
|
|
|
|
{
|
2011-01-20 08:38:11 +03:00
|
|
|
|
return null;
|
2011-01-13 13:44:44 +03:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
internal override IList<CustomAttributeData> GetCustomAttributesData(Type attributeType)
|
|
|
|
|
{
|
2011-01-13 17:33:02 +03:00
|
|
|
|
throw new MissingAssemblyException(this);
|
2011-01-13 13:44:44 +03:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
sealed class MissingModule : Module
|
|
|
|
|
{
|
|
|
|
|
private readonly MissingAssembly assembly;
|
|
|
|
|
|
|
|
|
|
internal MissingModule(MissingAssembly assembly)
|
|
|
|
|
: base(assembly.universe)
|
|
|
|
|
{
|
|
|
|
|
this.assembly = assembly;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override int MDStreamVersion
|
|
|
|
|
{
|
2011-01-13 17:33:02 +03:00
|
|
|
|
get { throw new MissingModuleException(this); }
|
2011-01-13 13:44:44 +03:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override Assembly Assembly
|
|
|
|
|
{
|
|
|
|
|
get { return assembly; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override string FullyQualifiedName
|
|
|
|
|
{
|
2011-01-13 17:33:02 +03:00
|
|
|
|
get { throw new MissingModuleException(this); }
|
2011-01-13 13:44:44 +03:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override string Name
|
|
|
|
|
{
|
2011-01-13 17:33:02 +03:00
|
|
|
|
get { throw new MissingModuleException(this); }
|
2011-01-13 13:44:44 +03:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override Guid ModuleVersionId
|
|
|
|
|
{
|
2011-01-13 17:33:02 +03:00
|
|
|
|
get { throw new MissingModuleException(this); }
|
2011-01-13 13:44:44 +03:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override Type ResolveType(int metadataToken, Type[] genericTypeArguments, Type[] genericMethodArguments)
|
|
|
|
|
{
|
2011-01-13 17:33:02 +03:00
|
|
|
|
throw new MissingModuleException(this);
|
2011-01-13 13:44:44 +03:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override MethodBase ResolveMethod(int metadataToken, Type[] genericTypeArguments, Type[] genericMethodArguments)
|
|
|
|
|
{
|
2011-01-13 17:33:02 +03:00
|
|
|
|
throw new MissingModuleException(this);
|
2011-01-13 13:44:44 +03:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override FieldInfo ResolveField(int metadataToken, Type[] genericTypeArguments, Type[] genericMethodArguments)
|
|
|
|
|
{
|
2011-01-13 17:33:02 +03:00
|
|
|
|
throw new MissingModuleException(this);
|
2011-01-13 13:44:44 +03:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override MemberInfo ResolveMember(int metadataToken, Type[] genericTypeArguments, Type[] genericMethodArguments)
|
|
|
|
|
{
|
2011-01-13 17:33:02 +03:00
|
|
|
|
throw new MissingModuleException(this);
|
2011-01-13 13:44:44 +03:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override string ResolveString(int metadataToken)
|
|
|
|
|
{
|
2011-01-13 17:33:02 +03:00
|
|
|
|
throw new MissingModuleException(this);
|
2011-01-13 13:44:44 +03:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override Type[] __ResolveOptionalParameterTypes(int metadataToken)
|
|
|
|
|
{
|
2011-01-13 17:33:02 +03:00
|
|
|
|
throw new MissingModuleException(this);
|
2011-01-13 13:44:44 +03:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override string ScopeName
|
|
|
|
|
{
|
2011-01-13 17:33:02 +03:00
|
|
|
|
get { throw new MissingModuleException(this); }
|
2011-01-13 13:44:44 +03:00
|
|
|
|
}
|
|
|
|
|
|
2011-01-20 08:38:11 +03:00
|
|
|
|
internal override Type FindType(TypeName typeName)
|
2011-01-13 13:44:44 +03:00
|
|
|
|
{
|
2011-01-20 08:38:11 +03:00
|
|
|
|
return null;
|
2011-01-13 13:44:44 +03:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
internal override void GetTypesImpl(System.Collections.Generic.List<Type> list)
|
|
|
|
|
{
|
2011-01-13 17:33:02 +03:00
|
|
|
|
throw new MissingModuleException(this);
|
2011-01-13 13:44:44 +03:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override AssemblyName[] __GetReferencedAssemblies()
|
|
|
|
|
{
|
2011-01-13 17:33:02 +03:00
|
|
|
|
throw new MissingModuleException(this);
|
2011-01-13 13:44:44 +03:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
internal override Type GetModuleType()
|
|
|
|
|
{
|
2011-01-13 17:33:02 +03:00
|
|
|
|
throw new MissingModuleException(this);
|
2011-01-13 13:44:44 +03:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
internal override IKVM.Reflection.Reader.ByteReader GetBlob(int blobIndex)
|
|
|
|
|
{
|
2011-01-13 17:33:02 +03:00
|
|
|
|
throw new MissingModuleException(this);
|
2011-01-13 13:44:44 +03:00
|
|
|
|
}
|
2011-01-13 18:27:03 +03:00
|
|
|
|
|
|
|
|
|
public override void __GetDataDirectoryEntry(int index, out int rva, out int length)
|
|
|
|
|
{
|
|
|
|
|
throw new MissingModuleException(this);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override IList<CustomAttributeData> __GetPlaceholderAssemblyCustomAttributes(bool multiple, bool security)
|
|
|
|
|
{
|
|
|
|
|
throw new MissingModuleException(this);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override long __RelativeVirtualAddressToFileOffset(int rva)
|
|
|
|
|
{
|
|
|
|
|
throw new MissingModuleException(this);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override __StandAloneMethodSig __ResolveStandAloneMethodSig(int metadataToken, Type[] genericTypeArguments, Type[] genericMethodArguments)
|
|
|
|
|
{
|
|
|
|
|
throw new MissingModuleException(this);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override int __Subsystem
|
|
|
|
|
{
|
|
|
|
|
get { throw new MissingModuleException(this); }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
internal override void ExportTypes(int fileToken, IKVM.Reflection.Emit.ModuleBuilder manifestModule)
|
|
|
|
|
{
|
|
|
|
|
throw new MissingModuleException(this);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override void GetPEKind(out PortableExecutableKinds peKind, out ImageFileMachine machine)
|
|
|
|
|
{
|
|
|
|
|
throw new MissingModuleException(this);
|
|
|
|
|
}
|
|
|
|
|
|
2011-01-13 18:44:28 +03:00
|
|
|
|
public override bool __IsMissing
|
|
|
|
|
{
|
|
|
|
|
get { return true; }
|
|
|
|
|
}
|
|
|
|
|
|
2011-01-13 18:27:03 +03:00
|
|
|
|
internal override IList<CustomAttributeData> GetCustomAttributesData(Type attributeType)
|
|
|
|
|
{
|
|
|
|
|
throw new MissingModuleException(this);
|
|
|
|
|
}
|
2011-01-13 13:44:44 +03:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
sealed class MissingType : Type
|
|
|
|
|
{
|
2011-01-18 19:44:39 +03:00
|
|
|
|
private readonly Module module;
|
2011-01-13 13:44:44 +03:00
|
|
|
|
private readonly Type declaringType;
|
|
|
|
|
private readonly string ns;
|
|
|
|
|
private readonly string name;
|
|
|
|
|
|
2011-01-18 19:44:39 +03:00
|
|
|
|
internal MissingType(Module module, Type declaringType, string ns, string name)
|
2011-01-13 13:44:44 +03:00
|
|
|
|
{
|
|
|
|
|
this.module = module;
|
|
|
|
|
this.declaringType = declaringType;
|
|
|
|
|
this.ns = ns;
|
|
|
|
|
this.name = name;
|
|
|
|
|
}
|
|
|
|
|
|
2011-01-26 09:59:57 +03:00
|
|
|
|
internal override MethodBase FindMethod(string name, MethodSignature signature)
|
|
|
|
|
{
|
|
|
|
|
MethodInfo method = new MissingMethod(this, name, signature);
|
|
|
|
|
if (name == ".ctor")
|
|
|
|
|
{
|
|
|
|
|
return new ConstructorInfoImpl(method);
|
|
|
|
|
}
|
|
|
|
|
return method;
|
|
|
|
|
}
|
|
|
|
|
|
2011-01-20 17:31:10 +03:00
|
|
|
|
internal override Type FindNestedType(TypeName name)
|
2011-01-13 13:44:44 +03:00
|
|
|
|
{
|
2011-01-20 17:31:10 +03:00
|
|
|
|
return null;
|
2011-01-13 13:44:44 +03:00
|
|
|
|
}
|
|
|
|
|
|
2011-01-26 09:59:57 +03:00
|
|
|
|
public override bool __IsMissing
|
|
|
|
|
{
|
|
|
|
|
get { return true; }
|
|
|
|
|
}
|
|
|
|
|
|
2011-01-13 13:44:44 +03:00
|
|
|
|
public override Type DeclaringType
|
|
|
|
|
{
|
|
|
|
|
get { return declaringType; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override string __Name
|
|
|
|
|
{
|
|
|
|
|
get { return name; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override string __Namespace
|
|
|
|
|
{
|
|
|
|
|
get { return ns; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override string Name
|
|
|
|
|
{
|
|
|
|
|
get { return TypeNameParser.Escape(name); }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override string FullName
|
|
|
|
|
{
|
|
|
|
|
get { return GetFullName(); }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override Module Module
|
|
|
|
|
{
|
|
|
|
|
get { return module; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override Type BaseType
|
|
|
|
|
{
|
2011-01-13 17:33:02 +03:00
|
|
|
|
get { throw new MissingMemberException(this); }
|
2011-01-13 13:44:44 +03:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override TypeAttributes Attributes
|
|
|
|
|
{
|
2011-01-13 17:33:02 +03:00
|
|
|
|
get { throw new MissingMemberException(this); }
|
2011-01-13 13:44:44 +03:00
|
|
|
|
}
|
2011-01-13 17:47:21 +03:00
|
|
|
|
|
|
|
|
|
public override Type[] __GetDeclaredTypes()
|
|
|
|
|
{
|
|
|
|
|
throw new MissingMemberException(this);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override Type[] __GetDeclaredInterfaces()
|
|
|
|
|
{
|
|
|
|
|
throw new MissingMemberException(this);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override MethodBase[] __GetDeclaredMethods()
|
|
|
|
|
{
|
|
|
|
|
throw new MissingMemberException(this);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override __MethodImplMap __GetMethodImplMap()
|
|
|
|
|
{
|
|
|
|
|
throw new MissingMemberException(this);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override FieldInfo[] __GetDeclaredFields()
|
|
|
|
|
{
|
|
|
|
|
throw new MissingMemberException(this);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override EventInfo[] __GetDeclaredEvents()
|
|
|
|
|
{
|
|
|
|
|
throw new MissingMemberException(this);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override PropertyInfo[] __GetDeclaredProperties()
|
|
|
|
|
{
|
|
|
|
|
throw new MissingMemberException(this);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override Type[] __GetRequiredCustomModifiers()
|
|
|
|
|
{
|
|
|
|
|
throw new MissingMemberException(this);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override Type[] __GetOptionalCustomModifiers()
|
|
|
|
|
{
|
|
|
|
|
throw new MissingMemberException(this);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override Type[] GetGenericArguments()
|
|
|
|
|
{
|
|
|
|
|
throw new MissingMemberException(this);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override Type[][] __GetGenericArgumentsRequiredCustomModifiers()
|
|
|
|
|
{
|
|
|
|
|
throw new MissingMemberException(this);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override Type[][] __GetGenericArgumentsOptionalCustomModifiers()
|
|
|
|
|
{
|
|
|
|
|
throw new MissingMemberException(this);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override StructLayoutAttribute StructLayoutAttribute
|
|
|
|
|
{
|
|
|
|
|
get { throw new MissingMemberException(this); }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override bool IsGenericType
|
|
|
|
|
{
|
|
|
|
|
get { throw new MissingMemberException(this); }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override bool IsGenericTypeDefinition
|
|
|
|
|
{
|
|
|
|
|
get { throw new MissingMemberException(this); }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
internal override IList<CustomAttributeData> GetCustomAttributesData(Type attributeType)
|
|
|
|
|
{
|
|
|
|
|
throw new MissingMemberException(this);
|
|
|
|
|
}
|
2011-01-13 18:35:03 +03:00
|
|
|
|
|
|
|
|
|
internal override Type BindTypeParameters(IGenericBinder binder)
|
|
|
|
|
{
|
|
|
|
|
return this;
|
|
|
|
|
}
|
2011-01-13 13:44:44 +03:00
|
|
|
|
}
|
2011-01-26 09:59:57 +03:00
|
|
|
|
|
|
|
|
|
sealed class MissingMethod : MethodInfo
|
|
|
|
|
{
|
|
|
|
|
private readonly Type declaringType;
|
|
|
|
|
private readonly string name;
|
|
|
|
|
private readonly MethodSignature signature;
|
2011-01-26 16:34:04 +03:00
|
|
|
|
private MethodInfo forwarder;
|
2011-01-26 09:59:57 +03:00
|
|
|
|
|
|
|
|
|
internal MissingMethod(Type declaringType, string name, MethodSignature signature)
|
|
|
|
|
{
|
|
|
|
|
this.declaringType = declaringType;
|
|
|
|
|
this.name = name;
|
|
|
|
|
this.signature = signature;
|
|
|
|
|
}
|
|
|
|
|
|
2011-01-26 16:34:04 +03:00
|
|
|
|
private MethodInfo Forwarder
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
MethodInfo method = TryGetForwarder();
|
|
|
|
|
if (method == null)
|
|
|
|
|
{
|
|
|
|
|
throw new MissingMemberException(this);
|
|
|
|
|
}
|
|
|
|
|
return method;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private MethodInfo TryGetForwarder()
|
|
|
|
|
{
|
|
|
|
|
if (forwarder == null && !declaringType.__IsMissing)
|
|
|
|
|
{
|
|
|
|
|
MethodBase mb = declaringType.FindMethod(name, signature);
|
|
|
|
|
ConstructorInfo ci = mb as ConstructorInfo;
|
|
|
|
|
if (ci != null)
|
|
|
|
|
{
|
|
|
|
|
forwarder = ci.GetMethodInfo();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
forwarder = (MethodInfo)mb;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return forwarder;
|
|
|
|
|
}
|
|
|
|
|
|
2011-01-26 09:59:57 +03:00
|
|
|
|
public override bool __IsMissing
|
|
|
|
|
{
|
2011-01-26 16:34:04 +03:00
|
|
|
|
get { return TryGetForwarder() == null; }
|
2011-01-26 09:59:57 +03:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override Type ReturnType
|
|
|
|
|
{
|
|
|
|
|
get { return signature.GetReturnType(this); }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override ParameterInfo ReturnParameter
|
|
|
|
|
{
|
|
|
|
|
get { return new ParameterInfoImpl(this, -1); }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
internal override MethodSignature MethodSignature
|
|
|
|
|
{
|
|
|
|
|
get { return signature; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
internal override int ParameterCount
|
|
|
|
|
{
|
2011-01-26 16:34:04 +03:00
|
|
|
|
get { return signature.GetParameterCount(); }
|
2011-01-26 09:59:57 +03:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private sealed class ParameterInfoImpl : ParameterInfo
|
|
|
|
|
{
|
|
|
|
|
private readonly MissingMethod method;
|
|
|
|
|
private readonly int index;
|
|
|
|
|
|
|
|
|
|
internal ParameterInfoImpl(MissingMethod method, int index)
|
|
|
|
|
{
|
|
|
|
|
this.method = method;
|
|
|
|
|
this.index = index;
|
|
|
|
|
}
|
|
|
|
|
|
2011-01-26 16:34:04 +03:00
|
|
|
|
private ParameterInfo Forwarder
|
|
|
|
|
{
|
|
|
|
|
get { return index == -1 ? method.Forwarder.ReturnParameter : method.Forwarder.GetParameters()[index]; }
|
|
|
|
|
}
|
|
|
|
|
|
2011-01-26 09:59:57 +03:00
|
|
|
|
public override string Name
|
|
|
|
|
{
|
2011-01-26 16:34:04 +03:00
|
|
|
|
get { return Forwarder.Name; }
|
2011-01-26 09:59:57 +03:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override Type ParameterType
|
|
|
|
|
{
|
|
|
|
|
get { return index == -1 ? method.signature.GetReturnType(method) : method.signature.GetParameterType(method, index); }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override ParameterAttributes Attributes
|
|
|
|
|
{
|
2011-01-26 16:34:04 +03:00
|
|
|
|
get { return Forwarder.Attributes; }
|
2011-01-26 09:59:57 +03:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override int Position
|
|
|
|
|
{
|
|
|
|
|
get { return index; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override object RawDefaultValue
|
|
|
|
|
{
|
2011-01-26 16:34:04 +03:00
|
|
|
|
get { return Forwarder.RawDefaultValue; }
|
2011-01-26 09:59:57 +03:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override Type[] GetOptionalCustomModifiers()
|
|
|
|
|
{
|
|
|
|
|
if (index == -1)
|
|
|
|
|
{
|
|
|
|
|
return Util.Copy(method.signature.GetReturnTypeOptionalCustomModifiers(method));
|
|
|
|
|
}
|
|
|
|
|
return Util.Copy(method.signature.GetParameterOptionalCustomModifiers(method, index));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override Type[] GetRequiredCustomModifiers()
|
|
|
|
|
{
|
|
|
|
|
if (index == -1)
|
|
|
|
|
{
|
|
|
|
|
return Util.Copy(method.signature.GetReturnTypeRequiredCustomModifiers(method));
|
|
|
|
|
}
|
|
|
|
|
return Util.Copy(method.signature.GetParameterRequiredCustomModifiers(method, index));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override MemberInfo Member
|
|
|
|
|
{
|
|
|
|
|
get { return method; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override int MetadataToken
|
|
|
|
|
{
|
2011-01-26 16:34:04 +03:00
|
|
|
|
get { return Forwarder.MetadataToken; }
|
2011-01-26 09:59:57 +03:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
internal override Module Module
|
|
|
|
|
{
|
|
|
|
|
get { return method.Module; }
|
|
|
|
|
}
|
2011-01-26 16:34:04 +03:00
|
|
|
|
|
|
|
|
|
internal override IList<CustomAttributeData> GetCustomAttributesData(Type attributeType)
|
|
|
|
|
{
|
|
|
|
|
return Forwarder.GetCustomAttributesData(attributeType);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override string ToString()
|
|
|
|
|
{
|
|
|
|
|
return Forwarder.ToString();
|
|
|
|
|
}
|
2011-01-26 09:59:57 +03:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override ParameterInfo[] GetParameters()
|
|
|
|
|
{
|
2011-01-26 16:34:04 +03:00
|
|
|
|
ParameterInfo[] parameters = new ParameterInfo[signature.GetParameterCount()];
|
2011-01-26 09:59:57 +03:00
|
|
|
|
for (int i = 0; i < parameters.Length; i++)
|
|
|
|
|
{
|
|
|
|
|
parameters[i] = new ParameterInfoImpl(this, i);
|
|
|
|
|
}
|
|
|
|
|
return parameters;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override MethodAttributes Attributes
|
|
|
|
|
{
|
2011-01-26 16:34:04 +03:00
|
|
|
|
get { return Forwarder.Attributes; }
|
2011-01-26 09:59:57 +03:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override MethodImplAttributes GetMethodImplementationFlags()
|
|
|
|
|
{
|
2011-01-26 16:34:04 +03:00
|
|
|
|
return Forwarder.GetMethodImplementationFlags();
|
2011-01-26 09:59:57 +03:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override MethodBody GetMethodBody()
|
|
|
|
|
{
|
2011-01-26 16:34:04 +03:00
|
|
|
|
return Forwarder.GetMethodBody();
|
2011-01-26 09:59:57 +03:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override CallingConventions CallingConvention
|
|
|
|
|
{
|
|
|
|
|
get { return signature.CallingConvention; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
internal override int ImportTo(IKVM.Reflection.Emit.ModuleBuilder module)
|
|
|
|
|
{
|
2011-01-26 16:34:04 +03:00
|
|
|
|
return Forwarder.ImportTo(module);
|
2011-01-26 09:59:57 +03:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override string Name
|
|
|
|
|
{
|
|
|
|
|
get { return name; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override Type DeclaringType
|
|
|
|
|
{
|
|
|
|
|
get { return declaringType.IsModulePseudoType ? null : declaringType; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override Module Module
|
|
|
|
|
{
|
|
|
|
|
get { return declaringType.Module; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override bool Equals(object obj)
|
|
|
|
|
{
|
|
|
|
|
MissingMethod other = obj as MissingMethod;
|
|
|
|
|
return other != null
|
|
|
|
|
&& other.declaringType == declaringType
|
|
|
|
|
&& other.name == name
|
|
|
|
|
&& other.signature.Equals(signature);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override int GetHashCode()
|
|
|
|
|
{
|
|
|
|
|
return declaringType.GetHashCode() ^ name.GetHashCode() ^ signature.GetHashCode();
|
|
|
|
|
}
|
2011-01-26 16:34:04 +03:00
|
|
|
|
|
|
|
|
|
internal override MethodBase BindTypeParameters(Type type)
|
|
|
|
|
{
|
|
|
|
|
return Forwarder.BindTypeParameters(type);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override bool ContainsGenericParameters
|
|
|
|
|
{
|
|
|
|
|
get { return Forwarder.ContainsGenericParameters; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
internal override IList<CustomAttributeData> GetCustomAttributesData(Type attributeType)
|
|
|
|
|
{
|
|
|
|
|
return Forwarder.GetCustomAttributesData(attributeType);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override Type[] GetGenericArguments()
|
|
|
|
|
{
|
|
|
|
|
return Forwarder.GetGenericArguments();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
internal override Type GetGenericMethodArgument(int index)
|
|
|
|
|
{
|
|
|
|
|
return Forwarder.GetGenericMethodArgument(index);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
internal override int GetGenericMethodArgumentCount()
|
|
|
|
|
{
|
|
|
|
|
return Forwarder.GetGenericMethodArgumentCount();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override MethodInfo GetGenericMethodDefinition()
|
|
|
|
|
{
|
|
|
|
|
return Forwarder.GetGenericMethodDefinition();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
internal override MethodInfo GetMethodOnTypeDefinition()
|
|
|
|
|
{
|
|
|
|
|
return Forwarder.GetMethodOnTypeDefinition();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
internal override bool HasThis
|
|
|
|
|
{
|
|
|
|
|
get { return Forwarder.HasThis; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override bool IsGenericMethod
|
|
|
|
|
{
|
|
|
|
|
get { return IsGenericMethodDefinition; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override bool IsGenericMethodDefinition
|
|
|
|
|
{
|
|
|
|
|
get { return signature.GenericParameterCount != 0; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override MethodInfo MakeGenericMethod(params Type[] typeArguments)
|
|
|
|
|
{
|
|
|
|
|
return Forwarder.MakeGenericMethod(typeArguments);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override int MetadataToken
|
|
|
|
|
{
|
|
|
|
|
get { return Forwarder.MetadataToken; }
|
|
|
|
|
}
|
2011-01-26 09:59:57 +03:00
|
|
|
|
}
|
2011-01-13 13:44:44 +03:00
|
|
|
|
}
|