Esempio n. 1
0
        public override AstNode VisitSimpleType(SimpleType simpleType, ICecilArgumentsResolver argumentsResolver)
        {
            Type type          = null;
            var  typeReference = simpleType.Annotation <TypeReference>();

            if (typeReference != null)
            {
                bool   hasTypes = false;
                Type[] types    = new Type[simpleType.TypeArguments.Count];

                if (typeReference.HasGenericParameters)
                {
                    simpleType.TypeArguments
                    .ForEach((a, i) => {
                        type = a.GetActualType() ?? argumentsResolver.ResolveType(a.ToString());

                        if (type != null)
                        {
                            types[i] = type;
                            hasTypes = true;
                        }
                    });

                    if (hasTypes)
                    {
                        type = typeReference.GetActualType()
                               .MakeGenericType(types);

                        simpleType.RemoveAnnotations <TypeReference>();
                        typeReference = new TypeReference(string.Empty, type.FullName, typeReference.Module, typeReference.Scope);
                        simpleType.AddAnnotation(typeReference);
                    }
                }
            }
            else
            {
                var pair = argumentsResolver.ResolvePair(simpleType.Identifier);

                type          = pair.Type;
                typeReference = pair.TypeReference;
                simpleType.AddAnnotation(typeReference);
                simpleType.Identifier = pair.Type.FullName;
            }

            return(simpleType);
        }