Beispiel #1
0
        private ClassCoverageItem ProcessClass(TypeDefinition t)
#endif
        {
            string className = t.FullName;
            int    nsindex   = className.LastIndexOf(".");
            string namespace2;
            string scopedName;

            if (nsindex == -1)
            {
                namespace2 = "<GLOBAL>";
                scopedName = className;
            }
            else if (nsindex == 0)
            {
                namespace2 = "<GLOBAL>";
                scopedName = className.Substring(1);
            }
            else
            {
                namespace2 = className.Substring(0, nsindex);
                scopedName = className.Substring(nsindex + 1);
            }

            // Create namespaces
            NamespaceCoverageItem ns = (NamespaceCoverageItem)namespaces [namespace2];

            if (ns == null)
            {
                string nsPrefix = "";
                foreach (String nsPart in namespace2.Split('.'))
                {
                    if (nsPrefix == "")
                    {
                        nsPrefix = nsPart;
                    }
                    else
                    {
                        nsPrefix = nsPrefix + "." + nsPart;
                    }
                    NamespaceCoverageItem ns2 = (NamespaceCoverageItem)namespaces [nsPrefix];
                    if (ns2 == null)
                    {
                        if (ns == null)
                        {
                            ns2 = new NamespaceCoverageItem(this, nsPrefix);
                        }
                        else
                        {
                            ns2 = new NamespaceCoverageItem(ns, nsPrefix);
                        }
                        namespaces [nsPrefix] = ns2;
                    }
                    ns = ns2;
                }
            }

            ClassCoverageItem klass = (ClassCoverageItem)classes [className];

            if (klass == null)
            {
                klass            = new ClassCoverageItem(ns);
                klass.name_space = namespace2;
                klass.name       = scopedName;
                klass.type       = t;
                klass.parent     = ns;

#if USE_REFLECTION
                klass.filtered = IsFiltered("[" + t.Assembly + "]" + className);
#else
                klass.filtered = IsFiltered("[" + t.Module.Name + "]" + className);
#endif
                classes [className] = klass;
            }

            return(klass);
        }
Beispiel #2
0
	private ClassCoverageItem ProcessClass (TypeDefinition t)
#endif
	{
		string className = t.FullName;
		int nsindex = className.LastIndexOf (".");
		string namespace2;
		string scopedName;
		if (nsindex == -1) {
			namespace2 = "<GLOBAL>";
			scopedName = className;
		} else if (nsindex == 0) {
			namespace2 = "<GLOBAL>";
			scopedName = className.Substring (1);
		}
		else {
			namespace2 = className.Substring (0, nsindex);
			scopedName = className.Substring (nsindex + 1);
		}

		// Create namespaces
		NamespaceCoverageItem ns = (NamespaceCoverageItem)namespaces [namespace2];
		if (ns == null) {
			string nsPrefix = "";
			foreach (String nsPart in namespace2.Split ('.')) {
				if (nsPrefix == "")
					nsPrefix = nsPart;
				else
					nsPrefix = nsPrefix + "." + nsPart;
				NamespaceCoverageItem ns2 = (NamespaceCoverageItem)namespaces [nsPrefix];
				if (ns2 == null) {
					if (ns == null)
						ns2 = new NamespaceCoverageItem (this, nsPrefix);
					else
						ns2 = new NamespaceCoverageItem (ns, nsPrefix);
					namespaces [nsPrefix] = ns2;
				}
				ns = ns2;
			}					
		}

		ClassCoverageItem klass = (ClassCoverageItem)classes [className];
		if (klass == null) {
			klass = new ClassCoverageItem (ns);
			klass.name_space = namespace2;
			klass.name = scopedName;
			klass.type = t;
			klass.parent = ns;

#if USE_REFLECTION
			klass.filtered = IsFiltered ("[" + t.Assembly + "]" + className);
#else
			klass.filtered = IsFiltered ("[" + t.Module.Name + "]" + className);
#endif
			classes [className] = klass;
		}

		return klass;
	}
Beispiel #3
0
        private void WriteItem(CoverageItem item, Type stopLevel, int level)
        {
            if (item.filtered)
            {
                return;
            }

            if (item.hit + item.missed == 0)
            {
                // Filtered
                return;
            }

            if (level == 0)
            {
                return;
            }

            if (item.GetType() == stopLevel)
            {
                return;
            }

            if (item is CoverageModel)
            {
                writer.WriteStartElement("project");
                writer.WriteAttributeString("name", "Project");
            }
            else
            if (item is NamespaceCoverageItem)
            {
                NamespaceCoverageItem ns = (NamespaceCoverageItem)item;
                writer.WriteStartElement("namespace");

                if (ns.ns == "<GLOBAL>")
                {
                    writer.WriteAttributeString("name", "GLOBAL");
                }
                else
                {
                    writer.WriteAttributeString("name", ns.ns);
                }
            }
            else
            if (item is ClassCoverageItem)
            {
                ClassCoverageItem klass = (ClassCoverageItem)item;
                writer.WriteStartElement("class");
                writer.WriteAttributeString("name", klass.name);
                writer.WriteAttributeString("fullname", klass.FullName.Replace('/', '.'));
            }

            WriteCoverage(item);

            if (item.ChildCount > 0)
            {
                foreach (CoverageItem child in item.children)
                {
                    WriteItem(child, stopLevel, level - 1);
                }
            }
            writer.WriteEndElement();
        }