public TypeDefinition(string @namespace, string name, TypeAttributes attributes, TypeReference baseType, uint fieldList, uint methodList) : base(new MetaDataRow((uint)attributes, 0U, 0U, 0U, fieldList, methodList)) { this._namespace = @namespace; this._name = name; this._baseType = baseType; }
public TypeSpecification(TypeReference typeRef) { originaltype = typeRef; netheader = typeRef.netheader; IsArray = typeRef.IsArray; IsPointer = typeRef.IsPointer; IsByReference = typeRef.IsByReference; IsDefinition = typeRef.IsDefinition; IsGenericInstance = typeRef.IsGenericInstance; IsPinned = typeRef.IsPinned; IsValueType = typeRef.IsValueType; }
public ArrayType(TypeReference typeRef, int rank, ArrayDimension[] dimensions) : base(typeRef) { // System.Diagnostics.Debugger.Break(); this.name = typeRef.name; if (rank == 0) this.name += "[]"; else for (int i = 0; i < rank; i++) this.name = this.name + dimensions[i].ToString(); Rank = rank; Dimensions = dimensions; }
public virtual TypeDefinition ResolveType(TypeReference typeRef) { Win32Assembly targetAssembly = null; typeRef = typeRef.GetElementType(); if (typeRef.IsNested) { var declaringType = ResolveType(typeRef.DeclaringType); foreach (var nestedClass in declaringType.NestedClasses) { if (nestedClass.Class != null && TypeRefsAreEqual(nestedClass.Class, typeRef)) { return nestedClass.Class; } } } else { if (typeRef.ResolutionScope is AssemblyDefinition) { targetAssembly = typeRef.ResolutionScope.NETHeader.ParentAssembly; } else if (typeRef.ResolutionScope is AssemblyReference) { targetAssembly = AssemblyResolver.Resolve(typeRef.ResolutionScope as AssemblyReference); } if (targetAssembly == null) { return null; } var typesTable = targetAssembly.NETHeader.TablesHeap.GetTable(MetaDataTableType.TypeDef); foreach (TypeDefinition member in typesTable.Members) { if (TypeRefsAreEqual(member, typeRef)) { return member; } } } return null; }
public override void ClearCache() { _owner = null; _constraint = null; }
public override void LoadCache() { _owner = Owner; _constraint = Constraint; }
private void UpdateTypeRef(Workspace workspace, TypeReference typeRef) { typeRef.MetaDataRow.Parts[0] = GetMemberIndex(workspace, typeRef._resolutionScope as MetaDataMember); typeRef.MetaDataRow.Parts[1] = GetStringIndex(workspace, typeRef.Namespace); typeRef.MetaDataRow.Parts[2] = GetStringIndex(workspace, typeRef.Name); }
public GenericParamConstraint(GenericParameter owner, TypeReference constraint) : base(new MetaDataRow(owner.TableIndex, 0U)) { this._owner = owner; this._constraint = constraint; }
public object ReadCustomAttributeArgumentElement(TypeReference paramType) { if (paramType._elementType == ElementType.None) { // TODO: convert string to type ref: if (paramType.FullName == "System.Type") return ReadUtf8String(); var resolvedTypeDef = paramType.Resolve(); if (resolvedTypeDef != null) { var enumType = resolvedTypeDef.GetEnumType(); if (enumType != null) return ReadCustomAttributeArgumentElement(enumType); } return null; } else { if (paramType._elementType == ElementType.String) return ReadUtf8String(); return ReadPrimitiveValue(paramType._elementType); } }
protected virtual bool TypeRefsAreEqual(TypeReference reference1, TypeReference reference2) { if (reference1 == null || reference2 == null) return false; if ((reference1.Name != reference2.Name) || (reference1.Namespace != reference2.Namespace)) return false; if (reference1.HasGenericParameters != reference2.HasGenericParameters) return false; if (reference1.HasGenericParameters && reference2.HasGenericParameters) { if (reference1.GenericParameters.Length != reference2.GenericParameters.Length) return false; //for (int i = 0; i < reference1.GenericParameters.Length; i++) //{ // if (!GenericParamsAreEqual(reference1.GenericParameters[i], reference2.GenericParameters[i])) // return false; //} } return true; }
public ArrayType(TypeReference typeRef) : this(typeRef, 0, null) { }
public object ReadCustomAttributeArgumentValue(TypeReference paramType) { if (!paramType.IsArray || !(paramType as ArrayType).IsVector) return ReadCustomAttributeArgumentElement(paramType); // throw new NotImplementedException("Array constructor values are not supported yet."); ushort elementcount = this.ReadUInt16(); object[] elements = new object[elementcount]; for (int i = 0; i < elementcount; i++) elements[i] = ReadCustomAttributeArgumentElement((paramType as ArrayType).OriginalType); return elements; }
public override void LoadCache() { _addmethod = AddMethod; _removemethod = RemoveMethod; _name = Name; _eventType = EventType; }
public EventDefinition(string name, EventAttributes attributes, TypeReference eventType) : base(new MetaDataRow((ushort)attributes, 0U, 0U)) { this._name = name; this._eventType = eventType; }
public override void ClearCache() { _addmethod = null; _removemethod = null; _name = null; _eventType = null; }
public GenericInstanceType(TypeReference typeRef) : base(typeRef) { }
public PointerType(TypeReference typeRef) : base(typeRef) { this.name = typeRef.Name + "*"; }
public ByReferenceType(TypeReference typeRef) : base(typeRef) { }
public ArrayType(TypeReference typeRef, int rank, ArrayDimension[] dimensions) : base(typeRef) { Rank = rank; Dimensions = dimensions; }
public override void ClearCache() { signature = null; declaringType = null; name = null; }
public override void ClearCache() { @class = null; @interface = null; }
public TypeReference[] ReadGenericArguments() { uint number = NETGlobals.ReadCompressedUInt32(this); var genericArguments = new TypeReference[number]; for (int i = 0; i < number; i++) genericArguments[i] = ReadTypeReference(); return genericArguments; }
public FieldReference(string name, TypeReference declaringType, uint signature) : base(new MetaDataRow(0U, 0U, signature)) { this._name = name; this._declaringType = declaringType; }
public bool IsBasedOn(TypeReference typeRef) { return BaseType != null && BaseType.FullName == typeRef.FullName; }
public override void LoadCache() { _pinvokeimpl = PInvokeImplementation; _customAttributes = CustomAttributes; _declaringType = DeclaringType; }
private object ReadArgumentValue(BinaryReader reader, TypeReference paramType) { if (!paramType.IsArray || !(paramType as ArrayType).IsVector) return ReadElement(reader,paramType); // throw new NotImplementedException("Array constructor values are not supported yet."); ushort elementcount = reader.ReadUInt16(); object[] elements = new object[elementcount]; for (int i = 0; i < elementcount; i++) elements[i] = ReadElement(reader,(paramType as ArrayType).OriginalType); return elements; }
internal GenericParamReference(int index, TypeReference baseType) : base(baseType) { Index = index; IsMethodVar = baseType.elementType == ElementType.MVar; }
private object ReadElement(BinaryReader reader, TypeReference paramType) { switch (paramType.elementType) { case ElementType.I1: return reader.ReadSByte(); case ElementType.I2: return reader.ReadInt16(); case ElementType.I4: return reader.ReadInt32(); case ElementType.I8: return reader.ReadInt64(); case ElementType.U1: return reader.ReadByte(); case ElementType.U2: return reader.ReadInt16(); case ElementType.U4: return reader.ReadInt32(); case ElementType.U8: return reader.ReadInt64(); case ElementType.R4: return reader.ReadSingle(); case ElementType.R8: return reader.ReadDouble(); case ElementType.Type: case ElementType.String: uint size = ReadCompressedUInt32(reader); if (size == 0xFF) return string.Empty; byte[] rawdata = reader.ReadBytes((int)size); return Encoding.UTF8.GetString(rawdata); case ElementType.Char: return reader.ReadChar(); throw new NotSupportedException(); case ElementType.Boolean: return reader.ReadByte() == 1; } return null; }
public PinnedType(TypeReference typeRef) : base(typeRef) { }
public CustomModifierType(TypeReference modifierType, TypeReference baseType, bool isRequired) : base(baseType) { ModifierType = modifierType; IsRequired = isRequired; }
public EventDefinition(string name, EventAttributes attributes, TypeReference eventType) : base(new MetaDataRow((ushort)attributes, 0U, 0U)) { this.name = name; this.eventType = eventType; }