internal MethodData(string name, MemberAccessibility accessibility, MemberFlags memberFlags, TypeData type, bool isTypeDynamic, GenericTypeParameterCollection genericParameters, bool isExtensionMethod, ParameterCollection parameters) : base(name, accessibility, memberFlags, type, isTypeDynamic, parameters) { this.GenericParameters = genericParameters; this.IsExtensionMethod = isExtensionMethod; }
internal ConstantData(string name, Accessibility accessibility, MemberFlags memberFlags, TypeData type, bool isTypeDynamic, object value) : base(name, accessibility, memberFlags, type, isTypeDynamic) =>
internal IndexerData(string name, Accessibility accessibility, MemberFlags memberFlags, TypeData type, bool isTypeDynamic, ParameterCollection parameters, Accessibility?getMethodAccessibility, Accessibility?setMethodAccessibility) : base(name, accessibility, memberFlags, type, isTypeDynamic, getMethodAccessibility, setMethodAccessibility) =>
internal EventData(string name, MemberAccessibility accessibility, MemberFlags memberFlags, TypeData type) : base(name, accessibility, memberFlags, type, isTypeDynamic: false) { }
internal PropertyData(string name, Accessibility accessibility, MemberFlags memberFlags, TypeData type, bool isTypeDynamic, Accessibility?getMethodAccessibility, Accessibility?setMethodAccessibility) : base(name, accessibility, memberFlags, type, isTypeDynamic) { GetMethodAccessibility = getMethodAccessibility; SetMethodAccessibility = setMethodAccessibility; }
/// <summary> /// Gets the <see cref="TypeDefinitionData"/> instance representing the specified type. /// </summary> /// <returns>The <see cref="TypeDefinitionData"/> instance.</returns> public new static TypeDefinitionData FromType(TypeReference t) { return((TypeDefinitionData)TypeData.FromType(t)); }
/// <summary> /// Indicates whether an old type is logically the same as the current type, just from an older build. /// </summary> #endif public bool IsEquivalentToOld(TypeData oldType, AssemblyFamily newAssemblyFamily) { return(oldType.IsEquivalentToNewMember(this, newAssemblyFamily)); }
internal OperatorData(string name, Accessibility accessibility, MemberFlags memberFlags, TypeData type, bool isTypeDynamic, ParameterCollection parameters) : base(name, accessibility, memberFlags, type, isTypeDynamic, parameters) { }
/// <summary> /// Gets the derived <see cref="TypeData"/> instance representing the specified type. /// </summary> /// <param name="t">The type for which to get the <see cref="TypeData"/>.</param> /// <returns>The derived <see cref="TypeData"/> instance.</returns> public static TypeData FromType(Type t) { return(TypeData.FromType( t.Assembly.ToAssemblyDefinition().MainModule.GetType(t.FullName, runtimeName: true))); }
/// <summary> /// Indicates whether a new type is logically the same as the current type, just from a newer build. /// </summary> #endif public bool IsEquivalentToNew(TypeData newType, AssemblyFamily newAssemblyFamily) { return(this.IsEquivalentToNewMember(newType, newAssemblyFamily)); }
/// <summary> /// Gets the derived <see cref="TypeData"/> instance representing the specified type. /// </summary> /// <typeparam name="T">The type for which to get the <see cref="TypeData"/>.</typeparam> /// <returns>The derived <see cref="TypeData"/> instance.</returns> public static TypeData FromType <T>() { return(TypeData.FromType(typeof(T))); }
/// <summary> /// Gets the derived <see cref="ConstructedGenericTypeData"/> instance representing the specified type. /// </summary> /// <returns>The derived <see cref="ConstructedGenericTypeData"/> instance.</returns> public new static ConstructedGenericTypeData FromType(Type t) { // TODO_Public: throw an exception if the type is not a constructed generic return((ConstructedGenericTypeData)TypeData.FromType(t)); }
internal ArrayTypeData(TypeData elementType, byte arrayRank) : base($"{elementType.Name}[{new string(',', arrayRank - 1)}]", Accessibility.Public, MemberFlags.None, TypeKind.Class, elementType) =>
/// <summary> /// Gets the <see cref="TypeData"/> instance containing the metadata for externally visible types and members of the specified <see cref="Type"/>. /// </summary> /// <param name="type">The type for which of corresponding to the TypeData to get.</param> /// <returns>The TypeData instance containing the metadata for externally visible types and members of the specified Type.</returns> #endif internal TypeData GetTypeData(TypeReference type) { Debug.Assert(type.GetType() != typeof(TypeReference), "The type has not been resolved yet, and may be from a different assembly."); Debug.Assert(type.GetDeclaringAssembly().FullName == this.FullName, "The type belongs to another assembly."); var genericParameter = type as GenericParameter; if (genericParameter != null) { return(this.GetGenericTypeParameterData(genericParameter)); } var accessibility = type.GetAccessibility(); if (accessibility == null) { return(null); } var typeDefinition = type as TypeDefinition; if (typeDefinition != null) { return(this.GetTypeDefinitionData(typeDefinition.FullName)); } DeclaringTypeData declaringType = null; if (type.DeclaringType != null) { declaringType = (DeclaringTypeData)this.GetTypeData(type.DeclaringType.Resolve()); } var genericInstance = type as GenericInstanceType; if (genericInstance != null) { return(TypeDefinitionData.FromType(genericInstance.ElementType).GetConstructedGenericTypeData(genericInstance.GenericArguments.Select(a => TypeData.FromType(a)))); } if (type.IsByReference) { Debug.Fail("We should never create representations for by-ref types. They can only be parameter types and ref or out parameters store the element type and indicate whether they are ref or out."); return(null); } var arrayType = type as ArrayType; if (arrayType != null) { Debug.Assert(declaringType == null, "Types with elements should not be declared within other types."); return(TypeData.FromType(arrayType.ElementType).GetArrayType((byte)arrayType.Rank)); } var pointerType = type as PointerType; if (pointerType != null) { return(TypeData.FromType(pointerType.ElementType).GetPointerType()); } var modifierType = type as IModifierType; if (modifierType != null) { return(TypeData.FromType(modifierType.ElementType)); } Debug.Fail("Unknown kind of type."); return(TypeData.FromType(type.Resolve())); }
internal virtual bool IsArray(out int rank, out TypeData elementType) { rank = 0; elementType = null; return(false); }
private void LoadFromMetadata(AssemblyDefinition assembly) { _isLoading = true; foreach (var module in assembly.Modules) { foreach (var type in module.Types) { this.RegisterType(type, null); } } // Finalize Definitions this.IterateAllTypeDefinitions(assembly, typeDefinitionAction: type => { var typeData = (TypeDefinitionData)this.GetTypeData(type); if (typeData == null) { return(false); } typeData.FinalizeDefinition(type); return(true); }, genericParameterAction: genericParameter => { this.GetGenericTypeParameterData(genericParameter).FinalizeDefinition(genericParameter); }); // Populate Members this.IterateAllTypeDefinitions(assembly, typeDefinitionAction: type => { var typeData = (TypeDefinitionData)this.GetTypeData(type); if (typeData == null) { return(false); } typeData.PopulateMembers(type); return(true); }); while (_constructedGenericsToFinalizeAfterLoad.Count != 0) { var temp = _constructedGenericsToFinalizeAfterLoad.ToArray(); _constructedGenericsToFinalizeAfterLoad.Clear(); foreach (var type in temp) { type.FinalizeDefiniton(); } } foreach (var type in assembly.MainModule.ExportedTypes.Where(e => e.IsForwarder).Select(t => (TypeDefinitionData)TypeData.FromType(t.Resolve())).Where(t => t != null)) { this.AddForwardedType(type); } foreach (var referenceName in assembly.Modules.SelectMany(m => m.AssemblyReferences)) { AssemblyData reference; if (_cachedAssemblyDatas.TryGetValue(referenceName.FullName, out reference)) { _referencedAssemblies.Add(reference); } } _isLoading = false; }
/// <summary> /// Indicates whether a variable of the current type is assignable from the specified source type, which is from an older build, if they /// had been from the same assembly version. /// </summary> /// <param name="oldSourceType">The older source type from which to test assignability to this type.</param> /// <param name="newAssemblyFamily"> /// The newer family of assemblies from which to obtain equivalents of older types, or null to use a default family containing only the new type's assembly. /// </param> #endif internal bool IsAssignableFromOld(TypeData oldSourceType, AssemblyFamily newAssemblyFamily = null) { newAssemblyFamily = newAssemblyFamily ?? this.GetDefiningAssemblyFamily(); return(this.IsAssignableFrom(oldSourceType, new IsAssignableFromContext(newAssemblyFamily, isSourceTypeOld: true, onlyReferenceAndIdentityConversions: false))); }
internal TypeWithElementData(string name, MemberAccessibility accessibility, MemberFlags memberFlags, TypeKind typeKind, TypeData elementType) : base(name, accessibility, memberFlags, typeKind) { this.ElementType = elementType; }
/// <summary> /// Indicates whether the type is a nullable value type. /// </summary> /// <param name="underlyingType">[Out] Will be set to the underlying value type if the tpye is nullable; will be null otherwise.</param> /// <returns>True if the type is nullable; False otherwise.</returns> #endif internal virtual bool IsNullable(out TypeData underlyingType) { underlyingType = null; return(false); }
internal PointerTypeData(string name, MemberAccessibility accessibility, MemberFlags memberFlags, TypeKind typeKind, TypeData elementType) : base(name, accessibility, memberFlags, typeKind, elementType) { }
internal override bool IsArray(out int rank, out TypeData elementType) { rank = this.ArrayRank; elementType = this.ElementType; return(true); }
internal TypedMemberDataBase(string name, MemberAccessibility accessibility, MemberFlags memberFlags, TypeData type, bool isTypeDynamic) : base(name, accessibility, memberFlags) { this.Type = type; this.IsTypeDynamic = isTypeDynamic; }
internal ArrayTypeData(string name, MemberAccessibility accessibility, MemberFlags memberFlags, TypeKind typeKind, TypeData elementType, byte arrayRank) : base(name, accessibility, memberFlags, typeKind, elementType) { this.ArrayRank = arrayRank; }
internal FieldData(string name, Accessibility accessibility, MemberFlags memberFlags, TypeData type, bool isTypeDynamic, bool isReadOnly) : base(name, accessibility, memberFlags, type, isTypeDynamic) =>
internal MethodDataBase(string name, MemberAccessibility accessibility, MemberFlags memberFlags, TypeData type, bool isTypeDynamic, ParameterCollection parameters) : base(name, accessibility, memberFlags, type, isTypeDynamic) { this.Parameters = parameters; }