using System;
using System.Diagnostics.SymbolStore;
using System.Globalization;
using System.Runtime.InteropServices;
using System.Security;
using System.Security.Permissions;
using System.Text;
namespace System.Reflection.Emit
{
/// Defines and represents a constructor of a dynamic class.
// Token: 0x020001E2 RID: 482
[ComVisible(true)]
[ComDefaultInterface(typeof(_ConstructorBuilder))]
[ClassInterface(ClassInterfaceType.None)]
public sealed class ConstructorBuilder : ConstructorInfo, _ConstructorBuilder
{
// Token: 0x060018DC RID: 6364 RVA: 0x0005FD78 File Offset: 0x0005DF78
internal ConstructorBuilder(TypeBuilder tb, MethodAttributes attributes, CallingConventions callingConvention, Type[] parameterTypes, Type[][] paramModReq, Type[][] paramModOpt)
{
this.attrs = attributes | MethodAttributes.SpecialName | MethodAttributes.RTSpecialName;
this.call_conv = callingConvention;
if (parameterTypes != null)
{
for (int i = 0; i < parameterTypes.Length; i++)
{
if (parameterTypes[i] == null)
{
throw new ArgumentException("Elements of the parameterTypes array cannot be null", "parameterTypes");
}
}
this.parameters = new Type[parameterTypes.Length];
Array.Copy(parameterTypes, this.parameters, parameterTypes.Length);
}
this.type = tb;
this.paramModReq = paramModReq;
this.paramModOpt = paramModOpt;
this.table_idx = this.get_next_table_index(this, 6, true);
((ModuleBuilder)tb.Module).RegisterToken(this, this.GetToken().Token);
}
/// Maps a set of names to a corresponding set of dispatch identifiers.
/// Reserved for future use. Must be IID_NULL.
/// Passed-in array of names to be mapped.
/// Count of the names to be mapped.
/// The locale context in which to interpret the names.
/// Caller-allocated array which receives the IDs corresponding to the names.
/// Late-bound access using the COM IDispatch interface is not supported.
// Token: 0x060018DD RID: 6365 RVA: 0x0005FE48 File Offset: 0x0005E048
void _ConstructorBuilder.GetIDsOfNames([In] ref Guid riid, IntPtr rgszNames, uint cNames, uint lcid, IntPtr rgDispId)
{
throw new NotImplementedException();
}
/// Retrieves the type information for an object, which can then be used to get the type information for an interface.
/// The type information to return.
/// The locale identifier for the type information.
/// Receives a pointer to the requested type information object.
/// Late-bound access using the COM IDispatch interface is not supported.
// Token: 0x060018DE RID: 6366 RVA: 0x0005FE50 File Offset: 0x0005E050
void _ConstructorBuilder.GetTypeInfo(uint iTInfo, uint lcid, IntPtr ppTInfo)
{
throw new NotImplementedException();
}
/// Retrieves the number of type information interfaces that an object provides (either 0 or 1).
/// Points to a location that receives the number of type information interfaces provided by the object.
/// Late-bound access using the COM IDispatch interface is not supported.
// Token: 0x060018DF RID: 6367 RVA: 0x0005FE58 File Offset: 0x0005E058
void _ConstructorBuilder.GetTypeInfoCount(out uint pcTInfo)
{
throw new NotImplementedException();
}
/// Provides access to properties and methods exposed by an object.
/// Identifies the member.
/// Reserved for future use. Must be IID_NULL.
/// The locale context in which to interpret arguments.
/// Flags describing the context of the call.
/// Pointer to a structure containing an array of arguments, an array of argument DISPIDs for named arguments, and counts for the number of elements in the arrays.
/// Pointer to the location where the result is to be stored.
/// Pointer to a structure that contains exception information.
/// The index of the first argument that has an error.
/// Late-bound access using the COM IDispatch interface is not supported.
// Token: 0x060018E0 RID: 6368 RVA: 0x0005FE60 File Offset: 0x0005E060
void _ConstructorBuilder.Invoke(uint dispIdMember, [In] ref Guid riid, uint lcid, short wFlags, IntPtr pDispParams, IntPtr pVarResult, IntPtr pExcepInfo, IntPtr puArgErr)
{
throw new NotImplementedException();
}
/// Gets a value that depends on whether the declaring type is generic.
///
/// if the declaring type is generic; otherwise, .
// Token: 0x17000454 RID: 1108
// (get) Token: 0x060018E1 RID: 6369 RVA: 0x0005FE68 File Offset: 0x0005E068
[MonoTODO]
public override CallingConventions CallingConvention
{
get
{
return this.call_conv;
}
}
/// Gets or sets whether the local variables in this constructor should be zero-initialized.
/// Read/write. Gets or sets whether the local variables in this constructor should be zero-initialized.
// Token: 0x17000455 RID: 1109
// (get) Token: 0x060018E2 RID: 6370 RVA: 0x0005FE70 File Offset: 0x0005E070
// (set) Token: 0x060018E3 RID: 6371 RVA: 0x0005FE78 File Offset: 0x0005E078
public bool InitLocals
{
get
{
return this.init_locals;
}
set
{
this.init_locals = value;
}
}
// Token: 0x17000456 RID: 1110
// (get) Token: 0x060018E4 RID: 6372 RVA: 0x0005FE84 File Offset: 0x0005E084
internal TypeBuilder TypeBuilder
{
get
{
return this.type;
}
}
/// Returns the method implementation flags for this constructor.
/// The method implementation flags for this constructor.
// Token: 0x060018E5 RID: 6373 RVA: 0x0005FE8C File Offset: 0x0005E08C
public override MethodImplAttributes GetMethodImplementationFlags()
{
return this.iattrs;
}
/// Returns the parameters of this constructor.
/// Returns an array of objects that represent the parameters of this constructor.
///
/// has not been called on this constructor's type, in the .NET Framework versions 1.0 and 1.1.
///
/// has not been called on this constructor's type, in the .NET Framework version 2.0.
// Token: 0x060018E6 RID: 6374 RVA: 0x0005FE94 File Offset: 0x0005E094
public override ParameterInfo[] GetParameters()
{
if (!this.type.is_created && !this.IsCompilerContext)
{
throw this.not_created();
}
return this.GetParametersInternal();
}
// Token: 0x060018E7 RID: 6375 RVA: 0x0005FECC File Offset: 0x0005E0CC
internal ParameterInfo[] GetParametersInternal()
{
if (this.parameters == null)
{
return new ParameterInfo[0];
}
ParameterInfo[] array = new ParameterInfo[this.parameters.Length];
for (int i = 0; i < this.parameters.Length; i++)
{
array[i] = new ParameterInfo((this.pinfo != null) ? this.pinfo[i + 1] : null, this.parameters[i], this, i + 1);
}
return array;
}
// Token: 0x060018E8 RID: 6376 RVA: 0x0005FF44 File Offset: 0x0005E144
internal override int GetParameterCount()
{
if (this.parameters == null)
{
return 0;
}
return this.parameters.Length;
}
/// Dynamically invokes the constructor reflected by this instance with the specified arguments, under the constraints of the specified Binder.
/// An instance of the class associated with the constructor.
/// The object that needs to be reinitialized.
/// One of the BindingFlags values that specifies the type of binding that is desired.
/// A Binder that defines a set of properties and enables the binding, coercion of argument types, and invocation of members using reflection. If is null, then Binder.DefaultBinding is used.
/// An argument list. This is an array of arguments with the same number, order, and type as the parameters of the constructor to be invoked. If there are no parameters, this should be a null reference (Nothing in Visual Basic).
/// A used to govern the coercion of types. If this is null, the for the current thread is used.
/// This method is not currently supported. You can retrieve the constructor using and call on the returned .
// Token: 0x060018E9 RID: 6377 RVA: 0x0005FF5C File Offset: 0x0005E15C
public override object Invoke(object obj, BindingFlags invokeAttr, Binder binder, object[] parameters, CultureInfo culture)
{
throw this.not_supported();
}
/// Invokes the constructor dynamically reflected by this instance on the given object, passing along the specified parameters, and under the constraints of the given binder.
/// Returns an that is the return value of the invoked constructor.
/// This must be a bit flag from , such as InvokeMethod, NonPublic, and so on.
/// An object that enables the binding, coercion of argument types, invocation of members, and retrieval of MemberInfo objects using reflection. If binder is null, the default binder is used. See .
/// An argument list. This is an array of arguments with the same number, order, and type as the parameters of the constructor to be invoked. If there are no parameters this should be null.
/// An instance of used to govern the coercion of types. If this is null, the for the current thread is used. (For example, this is necessary to convert a that represents 1000 to a value, since 1000 is represented differently by different cultures.)
/// This method is not currently supported. You can retrieve the constructor using and call on the returned .
// Token: 0x060018EA RID: 6378 RVA: 0x0005FF64 File Offset: 0x0005E164
public override object Invoke(BindingFlags invokeAttr, Binder binder, object[] parameters, CultureInfo culture)
{
throw this.not_supported();
}
/// Retrieves the internal handle for the method. Use this handle to access the underlying metadata handle.
/// Returns the internal handle for the method. Use this handle to access the underlying metadata handle.
/// This property is not supported on this class.
// Token: 0x17000457 RID: 1111
// (get) Token: 0x060018EB RID: 6379 RVA: 0x0005FF6C File Offset: 0x0005E16C
public override RuntimeMethodHandle MethodHandle
{
get
{
throw this.not_supported();
}
}
/// Retrieves the attributes for this constructor.
/// Returns the attributes for this constructor.
// Token: 0x17000458 RID: 1112
// (get) Token: 0x060018EC RID: 6380 RVA: 0x0005FF74 File Offset: 0x0005E174
public override MethodAttributes Attributes
{
get
{
return this.attrs;
}
}
/// Holds a reference to the object from which this object was obtained.
/// Returns the Type object from which this object was obtained.
// Token: 0x17000459 RID: 1113
// (get) Token: 0x060018ED RID: 6381 RVA: 0x0005FF7C File Offset: 0x0005E17C
public override Type ReflectedType
{
get
{
return this.type;
}
}
/// Retrieves a reference to the object for the type that declares this member.
/// Returns the object for the type that declares this member.
// Token: 0x1700045A RID: 1114
// (get) Token: 0x060018EE RID: 6382 RVA: 0x0005FF84 File Offset: 0x0005E184
public override Type DeclaringType
{
get
{
return this.type;
}
}
/// Gets null.
/// Returns null.
// Token: 0x1700045B RID: 1115
// (get) Token: 0x060018EF RID: 6383 RVA: 0x0005FF8C File Offset: 0x0005E18C
public Type ReturnType
{
get
{
return null;
}
}
/// Retrieves the name of this constructor.
/// Returns the name of this constructor.
// Token: 0x1700045C RID: 1116
// (get) Token: 0x060018F0 RID: 6384 RVA: 0x0005FF90 File Offset: 0x0005E190
public override string Name
{
get
{
return ((this.attrs & MethodAttributes.Static) == MethodAttributes.PrivateScope) ? ConstructorInfo.ConstructorName : ConstructorInfo.TypeConstructorName;
}
}
/// Retrieves the signature of the field in the form of a string.
/// Returns the signature of the field.
// Token: 0x1700045D RID: 1117
// (get) Token: 0x060018F1 RID: 6385 RVA: 0x0005FFB0 File Offset: 0x0005E1B0
public string Signature
{
get
{
return "constructor signature";
}
}
/// Adds declarative security to this constructor.
/// The security action to be taken, such as Demand, Assert, and so on.
/// The set of permissions the action applies to.
///
/// is invalid (RequestMinimum, RequestOptional, and RequestRefuse are invalid).
/// The containing type has been previously created using .-or- The permission set contains an action that was added earlier by AddDeclarativeSecurity.
///
/// is null.
// Token: 0x060018F2 RID: 6386 RVA: 0x0005FFB8 File Offset: 0x0005E1B8
public void AddDeclarativeSecurity(SecurityAction action, PermissionSet pset)
{
}
/// Defines a parameter of this constructor.
/// Returns a ParameterBuilder object that represents the new parameter of this constructor.
/// The position of the parameter in the parameter list. Parameters are indexed beginning with the number 1 for the first parameter.
/// The attributes of the parameter.
/// The name of the parameter. The name can be the null string.
///
/// is less than or equal to zero, or it is greater than the number of parameters of the constructor.
/// The containing type has been created using .
// Token: 0x060018F3 RID: 6387 RVA: 0x0005FFBC File Offset: 0x0005E1BC
public ParameterBuilder DefineParameter(int iSequence, ParameterAttributes attributes, string strParamName)
{
if (iSequence < 1 || iSequence > this.GetParameterCount())
{
throw new ArgumentOutOfRangeException("iSequence");
}
if (this.type.is_created)
{
throw this.not_after_created();
}
ParameterBuilder parameterBuilder = new ParameterBuilder(this, iSequence, attributes, strParamName);
if (this.pinfo == null)
{
this.pinfo = new ParameterBuilder[this.parameters.Length + 1];
}
this.pinfo[iSequence] = parameterBuilder;
return parameterBuilder;
}
/// Checks if the specified custom attribute type is defined.
/// true if the specified custom attribute type is defined; otherwise, false.
/// A custom attribute type.
/// Controls inheritance of custom attributes from base classes. This parameter is ignored.
/// This method is not currently supported. You can retrieve the constructor using and call on the returned .
// Token: 0x060018F4 RID: 6388 RVA: 0x00060034 File Offset: 0x0005E234
public override bool IsDefined(Type attributeType, bool inherit)
{
throw this.not_supported();
}
/// Returns all the custom attributes defined for this constructor.
/// Returns an array of objects representing all the custom attributes of the constructor represented by this instance.
/// Controls inheritance of custom attributes from base classes. This parameter is ignored.
/// This method is not currently supported.
// Token: 0x060018F5 RID: 6389 RVA: 0x0006003C File Offset: 0x0005E23C
public override object[] GetCustomAttributes(bool inherit)
{
if (this.type.is_created && this.IsCompilerContext)
{
return MonoCustomAttrs.GetCustomAttributes(this, inherit);
}
throw this.not_supported();
}
/// Returns the custom attributes identified by the given type.
/// Returns an array of type representing the attributes of this constructor.
/// The custom attribute type.
/// Controls inheritance of custom attributes from base classes. This parameter is ignored.
/// This method is not currently supported.
// Token: 0x060018F6 RID: 6390 RVA: 0x00060074 File Offset: 0x0005E274
public override object[] GetCustomAttributes(Type attributeType, bool inherit)
{
if (this.type.is_created && this.IsCompilerContext)
{
return MonoCustomAttrs.GetCustomAttributes(this, attributeType, inherit);
}
throw this.not_supported();
}
/// Gets an for this constructor.
/// Returns an object for this constructor.
/// The constructor is a default constructor.-or-The constructor has or flags indicating that it should not have a method body.
// Token: 0x060018F7 RID: 6391 RVA: 0x000600AC File Offset: 0x0005E2AC
public ILGenerator GetILGenerator()
{
return this.GetILGenerator(64);
}
/// Gets an object, with the specified MSIL stream size, that can be used to build a method body for this constructor.
/// An for this constructor.
/// The size of the MSIL stream, in bytes.
/// The constructor is a default constructor.-or-The constructor has or flags indicating that it should not have a method body.
// Token: 0x060018F8 RID: 6392 RVA: 0x000600B8 File Offset: 0x0005E2B8
public ILGenerator GetILGenerator(int streamSize)
{
if (this.ilgen != null)
{
return this.ilgen;
}
this.ilgen = new ILGenerator(this.type.Module, ((ModuleBuilder)this.type.Module).GetTokenGenerator(), streamSize);
return this.ilgen;
}
/// Set a custom attribute using a custom attribute builder.
/// An instance of a helper class to define the custom attribute.
///
/// is null.
// Token: 0x060018F9 RID: 6393 RVA: 0x0006010C File Offset: 0x0005E30C
public void SetCustomAttribute(CustomAttributeBuilder customBuilder)
{
if (customBuilder == null)
{
throw new ArgumentNullException("customBuilder");
}
string fullName = customBuilder.Ctor.ReflectedType.FullName;
if (fullName == "System.Runtime.CompilerServices.MethodImplAttribute")
{
byte[] data = customBuilder.Data;
int num = (int)data[2];
num |= (int)data[3] << 8;
this.SetImplementationFlags((MethodImplAttributes)num);
return;
}
if (this.cattrs != null)
{
CustomAttributeBuilder[] array = new CustomAttributeBuilder[this.cattrs.Length + 1];
this.cattrs.CopyTo(array, 0);
array[this.cattrs.Length] = customBuilder;
this.cattrs = array;
}
else
{
this.cattrs = new CustomAttributeBuilder[1];
this.cattrs[0] = customBuilder;
}
}
/// Set a custom attribute using a specified custom attribute blob.
/// The constructor for the custom attribute.
/// A byte blob representing the attributes.
///
/// or is null.
// Token: 0x060018FA RID: 6394 RVA: 0x000601BC File Offset: 0x0005E3BC
[ComVisible(true)]
public void SetCustomAttribute(ConstructorInfo con, byte[] binaryAttribute)
{
if (con == null)
{
throw new ArgumentNullException("con");
}
if (binaryAttribute == null)
{
throw new ArgumentNullException("binaryAttribute");
}
this.SetCustomAttribute(new CustomAttributeBuilder(con, binaryAttribute));
}
/// Sets the method implementation flags for this constructor.
/// The method implementation flags.
/// The containing type has been created using .
// Token: 0x060018FB RID: 6395 RVA: 0x000601F0 File Offset: 0x0005E3F0
public void SetImplementationFlags(MethodImplAttributes attributes)
{
if (this.type.is_created)
{
throw this.not_after_created();
}
this.iattrs = attributes;
}
/// Returns a reference to the module that contains this constructor.
/// The module that contains this constructor.
// Token: 0x060018FC RID: 6396 RVA: 0x00060210 File Offset: 0x0005E410
public Module GetModule()
{
return this.type.Module;
}
/// Returns the that represents the token for this constructor.
/// Returns the of this constructor.
// Token: 0x060018FD RID: 6397 RVA: 0x00060220 File Offset: 0x0005E420
public MethodToken GetToken()
{
return new MethodToken(100663296 | this.table_idx);
}
/// Sets this constructor's custom attribute associated with symbolic information.
/// The name of the custom attribute.
/// The value of the custom attribute.
/// The containing type has been created using .-or- The module does not have a symbol writer defined. For example, the module is not a debug module.
// Token: 0x060018FE RID: 6398 RVA: 0x00060234 File Offset: 0x0005E434
[MonoTODO]
public void SetSymCustomAttribute(string name, byte[] data)
{
if (this.type.is_created)
{
throw this.not_after_created();
}
}
/// Gets the dynamic module in which this constructor is defined.
/// A object that represents the dynamic module in which this constructor is defined.
// Token: 0x1700045E RID: 1118
// (get) Token: 0x060018FF RID: 6399 RVA: 0x00060250 File Offset: 0x0005E450
public override Module Module
{
get
{
return base.Module;
}
}
/// Returns this instance as a .
/// Returns a containing the name, attributes, and exceptions of this constructor, followed by the current Microsoft intermediate language (MSIL) stream.
// Token: 0x06001900 RID: 6400 RVA: 0x00060258 File Offset: 0x0005E458
public override string ToString()
{
return "ConstructorBuilder ['" + this.type.Name + "']";
}
// Token: 0x06001901 RID: 6401 RVA: 0x00060274 File Offset: 0x0005E474
internal void fixup()
{
if ((this.attrs & (MethodAttributes.Abstract | MethodAttributes.PinvokeImpl)) == MethodAttributes.PrivateScope && (this.iattrs & (MethodImplAttributes)4099) == MethodImplAttributes.IL && (this.ilgen == null || ILGenerator.Mono_GetCurrentOffset(this.ilgen) == 0))
{
throw new InvalidOperationException("Method '" + this.Name + "' does not have a method body.");
}
if (this.ilgen != null)
{
this.ilgen.label_fixup();
}
}
// Token: 0x06001902 RID: 6402 RVA: 0x000602F0 File Offset: 0x0005E4F0
internal void GenerateDebugInfo(ISymbolWriter symbolWriter)
{
if (this.ilgen != null && this.ilgen.HasDebugInfo)
{
SymbolToken symbolToken = new SymbolToken(this.GetToken().Token);
symbolWriter.OpenMethod(symbolToken);
symbolWriter.SetSymAttribute(symbolToken, "__name", Encoding.UTF8.GetBytes(this.Name));
this.ilgen.GenerateDebugInfo(symbolWriter);
symbolWriter.CloseMethod();
}
}
// Token: 0x06001903 RID: 6403 RVA: 0x00060364 File Offset: 0x0005E564
internal override int get_next_table_index(object obj, int table, bool inc)
{
return this.type.get_next_table_index(obj, table, inc);
}
// Token: 0x1700045F RID: 1119
// (get) Token: 0x06001904 RID: 6404 RVA: 0x00060374 File Offset: 0x0005E574
private bool IsCompilerContext
{
get
{
ModuleBuilder moduleBuilder = (ModuleBuilder)this.TypeBuilder.Module;
AssemblyBuilder assemblyBuilder = (AssemblyBuilder)moduleBuilder.Assembly;
return assemblyBuilder.IsCompilerContext;
}
}
// Token: 0x06001905 RID: 6405 RVA: 0x000603A4 File Offset: 0x0005E5A4
private void RejectIfCreated()
{
if (this.type.is_created)
{
throw new InvalidOperationException("Type definition of the method is complete.");
}
}
// Token: 0x06001906 RID: 6406 RVA: 0x000603C4 File Offset: 0x0005E5C4
private Exception not_supported()
{
return new NotSupportedException("The invoked member is not supported in a dynamic module.");
}
// Token: 0x06001907 RID: 6407 RVA: 0x000603D0 File Offset: 0x0005E5D0
private Exception not_after_created()
{
return new InvalidOperationException("Unable to change after type has been created.");
}
// Token: 0x06001908 RID: 6408 RVA: 0x000603DC File Offset: 0x0005E5DC
private Exception not_created()
{
return new NotSupportedException("The type is not yet created.");
}
// Token: 0x04000771 RID: 1905
private RuntimeMethodHandle mhandle;
// Token: 0x04000772 RID: 1906
private ILGenerator ilgen;
// Token: 0x04000773 RID: 1907
internal Type[] parameters;
// Token: 0x04000774 RID: 1908
private MethodAttributes attrs;
// Token: 0x04000775 RID: 1909
private MethodImplAttributes iattrs;
// Token: 0x04000776 RID: 1910
private int table_idx;
// Token: 0x04000777 RID: 1911
private CallingConventions call_conv;
// Token: 0x04000778 RID: 1912
private TypeBuilder type;
// Token: 0x04000779 RID: 1913
internal ParameterBuilder[] pinfo;
// Token: 0x0400077A RID: 1914
private CustomAttributeBuilder[] cattrs;
// Token: 0x0400077B RID: 1915
private bool init_locals = true;
// Token: 0x0400077C RID: 1916
private Type[][] paramModReq;
// Token: 0x0400077D RID: 1917
private Type[][] paramModOpt;
// Token: 0x0400077E RID: 1918
private RefEmitPermissionSet[] permissions;
}
}