Example #1
0
        public IType ResolveType(EntityHandle typeRefDefSpec, GenericContext context, TypeSystemOptions customOptions, CustomAttributeHandleCollection?typeAttributes = null, Nullability nullableContext = Nullability.Oblivious)
        {
            if (typeRefDefSpec.IsNil)
            {
                return(SpecialType.UnknownType);
            }
            IType ty;

            switch (typeRefDefSpec.Kind)
            {
            case HandleKind.TypeDefinition:
                ty = TypeProvider.GetTypeFromDefinition(metadata, (TypeDefinitionHandle)typeRefDefSpec, 0);
                break;

            case HandleKind.TypeReference:
                ty = TypeProvider.GetTypeFromReference(metadata, (TypeReferenceHandle)typeRefDefSpec, 0);
                break;

            case HandleKind.TypeSpecification:
                var typeSpec = metadata.GetTypeSpecification((TypeSpecificationHandle)typeRefDefSpec);
                ty = typeSpec.DecodeSignature(TypeProvider, context);
                break;

            case HandleKind.ExportedType:
                return(ResolveForwardedType(metadata.GetExportedType((ExportedTypeHandle)typeRefDefSpec)));

            default:
                throw new BadImageFormatException("Not a type handle");
            }
            ty = ApplyAttributeTypeVisitor.ApplyAttributesToType(ty, Compilation, typeAttributes, metadata, customOptions, nullableContext);
            return(ty);
        }
Example #2
0
        IType ResolveDeclaringType(EntityHandle declaringTypeReference, GenericContext context)
        {
            // resolve without substituting dynamic/tuple types
            var ty = ResolveType(declaringTypeReference, context,
                                 options & ~(TypeSystemOptions.Dynamic | TypeSystemOptions.Tuple | TypeSystemOptions.NullabilityAnnotations));

            // but substitute tuple types in type arguments:
            ty = ApplyAttributeTypeVisitor.ApplyAttributesToType(ty, Compilation, null, metadata, options, Nullability.Oblivious, typeChildrenOnly: true);
            return(ty);
        }
Example #3
0
 IType IntroduceTupleTypes(IType ty)
 {
     // run ApplyAttributeTypeVisitor without attributes, in order to introduce tuple types
     return(ApplyAttributeTypeVisitor.ApplyAttributesToType(ty, Compilation, null, metadata, options, Nullability.Oblivious));
 }