/// <summary>
        /// For performance this is separate method.
        /// 'genArgs' should hold type for each generic parameter in 'typeRef'.
        /// </summary>
        private static DebugType ResolveTypeInternal(TypeReference typeRef, DebugType[] genArgs, VelerSoftware.SZC.Debugger.Debugger.AppDomain appDomain)
        {
            DebugType type = null;

            // Try to construct non-nested type
            // If there are generic types up in the tree, it must be nested type
            if (genArgs.Length == typeRef.GenericTypes.Count)
            {
                string name = GetNameWithArgCounts(typeRef);
                type = DebugType.CreateFromNameOrNull(appDomain, name, null, genArgs);
            }

            // Try to construct nested type
            if (type == null && typeRef is InnerClassTypeReference)
            {
                DebugType[] outterGenArgs = genArgs;
                // Do not pass our generic arguments to outter type
                Array.Resize(ref outterGenArgs, genArgs.Length - typeRef.GenericTypes.Count);

                DebugType outter     = ResolveTypeInternal(((InnerClassTypeReference)typeRef).BaseType, outterGenArgs, appDomain);
                string    nestedName = typeRef.GenericTypes.Count == 0 ? typeRef.Type : typeRef.Type + "`" + typeRef.GenericTypes.Count;
                type = DebugType.CreateFromNameOrNull(appDomain, nestedName, outter, genArgs);
            }

            if (type == null)
            {
                throw new GetValueException("Can not resolve " + typeRef.PrettyPrint());
            }

            for (int i = 0; i < typeRef.PointerNestingLevel; i++)
            {
                type = (DebugType)type.MakePointerType();
            }
            if (typeRef.RankSpecifier != null)
            {
                for (int i = typeRef.RankSpecifier.Length - 1; i >= 0; i--)
                {
                    type = (DebugType)type.MakeArrayType(typeRef.RankSpecifier[i] + 1);
                }
            }
            return(type);
        }