Example #1
0
 static void AppendClassTypeReference(StringBuilder sb, FullTypeName name, int outerTypeParameterCount)
 {
     if (name.IsNested)
     {
         for (int i = 0; i < name.NestingLevel; i++)
         {
             if (i > 0)
             {
                 sb.Append('.');
             }
             sb.Append(name.GetNestedTypeName(i));
         }
     }
     else
     {
         if (!string.IsNullOrEmpty(name.TopLevelTypeName.Namespace))
         {
             sb.Append(name.TopLevelTypeName.Namespace);
             sb.Append('.');
         }
         sb.Append(name.TopLevelTypeName.Name);
     }
     if (name.TypeParameterCount - outerTypeParameterCount > 0)
     {
         sb.Append('`');
         sb.Append(name.TypeParameterCount - outerTypeParameterCount);
     }
 }
        public AstType ConvertType(FullTypeName fullTypeName)
        {
            if (resolver != null)
            {
                foreach (var asm in resolver.Compilation.Assemblies)
                {
                    var def = asm.GetTypeDefinition(fullTypeName);
                    if (def != null)
                    {
                        return(ConvertType(def));
                    }
                }
            }
            TopLevelTypeName top = fullTypeName.TopLevelTypeName;
            AstType          type;

            if (string.IsNullOrEmpty(top.Namespace))
            {
                type = new SimpleType(top.Name);
            }
            else
            {
                type = new SimpleType(top.Namespace).MemberType(top.Name);
            }
            for (int i = 0; i < fullTypeName.NestingLevel; i++)
            {
                type = type.MemberType(fullTypeName.GetNestedTypeName(i));
            }
            return(type);
        }
 public ITypeDefinitionModel this[FullTypeName fullTypeName] {
     get {
         ITypeDefinitionModel model = this[fullTypeName.TopLevelTypeName];
         for (int i = 0; i < fullTypeName.NestingLevel && model != null; i++)
         {
             string name = fullTypeName.GetNestedTypeName(i);
             int    atpc = fullTypeName.GetNestedTypeAdditionalTypeParameterCount(i);
             model = model.GetNestedType(name, atpc);
         }
         return(model);
     }
 }
        public NUnitTestClass GetTestClass(FullTypeName fullTypeName)
        {
            var testClass = (NUnitTestClass)base.GetTestClass(fullTypeName.TopLevelTypeName);
            int tpc       = fullTypeName.TopLevelTypeName.TypeParameterCount;

            for (int i = 0; i < fullTypeName.NestingLevel; i++)
            {
                if (testClass == null)
                {
                    break;
                }
                tpc      += fullTypeName.GetNestedTypeAdditionalTypeParameterCount(i);
                testClass = testClass.FindNestedTestClass(fullTypeName.GetNestedTypeName(i), tpc);
            }
            return(testClass);
        }
 /// <summary>
 /// Gets the type definition for the specified unresolved type.
 /// Returns null if the unresolved type does not belong to this assembly.
 /// </summary>
 public static ITypeDefinition GetTypeDefinition(this IAssembly assembly, FullTypeName fullTypeName)
 {
     if (assembly == null)
         throw new ArgumentNullException("assembly");
     TopLevelTypeName topLevelTypeName = fullTypeName.TopLevelTypeName;
     ITypeDefinition typeDef = assembly.GetTypeDefinition(topLevelTypeName);
     if (typeDef == null)
         return null;
     int typeParameterCount = topLevelTypeName.TypeParameterCount;
     for (int i = 0; i < fullTypeName.NestingLevel; i++) {
         string name = fullTypeName.GetNestedTypeName(i);
         typeParameterCount += fullTypeName.GetNestedTypeAdditionalTypeParameterCount(i);
         typeDef = FindNestedType(typeDef, name, typeParameterCount);
         if (typeDef == null)
             break;
     }
     return typeDef;
 }
		public NUnitTestClass GetTestClass(FullTypeName fullTypeName)
		{
			var testClass = (NUnitTestClass)base.GetTestClass(fullTypeName.TopLevelTypeName);
			int tpc = fullTypeName.TopLevelTypeName.TypeParameterCount;
			for (int i = 0; i < fullTypeName.NestingLevel; i++) {
				if (testClass == null)
					break;
				tpc += fullTypeName.GetNestedTypeAdditionalTypeParameterCount(i);
				testClass = testClass.FindNestedTestClass(fullTypeName.GetNestedTypeName(i), tpc);
			}
			return testClass;
		}
 public AstType ConvertType(FullTypeName fullTypeName)
 {
     if (resolver != null) {
         foreach (var asm in resolver.Compilation.Assemblies) {
             var def = asm.GetTypeDefinition(fullTypeName);
             if (def != null) {
                 return ConvertType(def);
             }
         }
     }
     TopLevelTypeName top = fullTypeName.TopLevelTypeName;
     AstType type;
     if (string.IsNullOrEmpty(top.Namespace)) {
         type = new SimpleType(top.Name);
     } else {
         type = new SimpleType(top.Namespace).MemberType(top.Name);
     }
     for (int i = 0; i < fullTypeName.NestingLevel; i++) {
         type = type.MemberType(fullTypeName.GetNestedTypeName(i));
     }
     return type;
 }