Exemplo n.º 1
0
        public static TypeDefinition GetTypeDefinition(TypeReference typeRef)
        {
            if (typeRef == null)
                return null;

            var ts = typeRef.Module.TypeSystem;
            typeRef = DereferenceType(typeRef);

            bool unwrapped = false;
            do {
                var rmt = typeRef as RequiredModifierType;
                var omt = typeRef as OptionalModifierType;

                if (rmt != null) {
                    typeRef = rmt.ElementType;
                    unwrapped = true;
                } else if (omt != null) {
                    typeRef = omt.ElementType;
                    unwrapped = true;
                } else {
                    unwrapped = false;
                }
            } while (unwrapped);

            if (JSExpression.IsOpenGenericType(typeRef))
                return typeRef.Resolve();
            else if (typeRef is ArrayType)
                return new TypeReference(ts.Object.Namespace, "Array", ts.Object.Module, ts.Object.Scope).ResolveOrThrow();
            else if (IsIgnoredType(typeRef))
                return null;
            else
                return typeRef.ResolveOrThrow();
        }