public void CreatePost(ConvertedTypeDefinition converted, SemanticTypeInformation typeInformation) { if (converted.IsGeneric()) { var generic = (ConvertedGenericTypeDefinition_I)converted; generic.GenericKind = typeInformation.GenericKind; generic.SourceGenericInstanceType = typeInformation.GenericInstanceType; if (typeInformation.GenericTypeDefinition == null) { if (typeInformation.IsClosedGeneric && !typeInformation.IsAnonymousType) { throw new System.Exception("Expected a generic type definition"); } } } converted.AssemblyQualifiedName = Cecil.Metadata.Members.Types.Naming.GetAssemblyQualifiedName(typeInformation.TypeReference); converted.FullName = typeInformation.FullName; converted.Name = typeInformation.Name; converted.PackingSize = typeInformation.PackingSize; converted.SourceTypeReference = typeInformation.TypeReference; converted.ResolutionName = Types.Naming.GetResolutionName(converted); if (typeInformation.IsGlobal) { converted.TypeKind |= Enums.E01D.Runtimic.Infrastructure.Metadata.Members.Typal.TypeKind.Global; } }
public void AssignTypeParameters(ILConversion conversion, ConvertedTypeDefinition type, List <ConvertedGenericParameterTypeDefinition> typeParameters) { if (!type.IsGeneric()) { return; } ConvertedTypeDefinitionWithTypeParameters_I generic = (ConvertedTypeDefinitionWithTypeParameters_I)type; Types.TypeParameters.Clear(conversion, generic); Types.TypeParameters.Add(conversion, generic, typeParameters); }
public Type[] Build(ILConversion conversion, ConvertedTypeDefinition converted) { if (!converted.IsGeneric()) { return(Type.EmptyTypes); } GenericInstanceType inputType = (GenericInstanceType)converted.SourceTypeReference; var list = new List <SemanticTypeDefinitionMask_I>(); if (inputType.GenericArguments.Count <= 0) { return(Type.EmptyTypes); } Type[] types = new Type[inputType.GenericArguments.Count]; bool hasGenericParametersAsTypeArguments = false; for (var i = 0; i < inputType.GenericArguments.Count; i++) { var genericArgument = inputType.GenericArguments[i]; var semanticType = Execution.Types.Ensuring.Ensure(conversion, genericArgument, null, null); if (!(semanticType is BoundTypeDefinitionMask_I bound)) { throw new System.Exception("Semantic type needs to be a bound type."); } types[i] = bound.UnderlyingType; hasGenericParametersAsTypeArguments |= types[i].IsGenericParameter; list.Add(Models.Types.GetBoundTypeOrThrow(semanticType, false)); } ConvertedGenericTypeDefinition_I generic = (ConvertedGenericTypeDefinition_I)converted; generic.TypeArguments.All = list; //generic.TypeArguments.HasGenericParametersAsTypeArguments = hasGenericParametersAsTypeArguments; return(types); }