Exemplo n.º 1
0
		public void Parse(string file)
		{
			using (XmlTextReader rdr = new XmlTextReader(file))
			{
				foreach (XmlData data in XmlData.Read(rdr))
				{
					_version = data.File.profilerVersion;
					_driverVersion = data.File.driverVersion;
					if (_when > data.File.startTime)
						_when = data.File.startTime;

					CodeMetric metric = new CodeMetric(data);

					if (ByFile.AddMetric(metric))//if this is a new statement
					{
						ByModule.AddMetric(metric);
						ByNamespace.AddMetric(metric);
						ByClass.AddMetric(metric);
						bool newMethod = ByMethod.AddMetric(metric);

						if (newMethod && Exclude(metric))
							metric.Excluded = true;
					}
				}
			}
		}
Exemplo n.º 2
0
        public void Parse(string file)
        {
            using (XmlTextReader rdr = new XmlTextReader(file))
            {
                foreach (XmlData data in XmlData.Read(rdr))
                {
                    _version       = data.File.profilerVersion;
                    _driverVersion = data.File.driverVersion;
                    if (_when > data.File.startTime)
                    {
                        _when = data.File.startTime;
                    }

                    CodeMetric metric = new CodeMetric(data);

                    if (ByFile.AddMetric(metric))                    //if this is a new statement
                    {
                        ByModule.AddMetric(metric);
                        ByNamespace.AddMetric(metric);
                        ByClass.AddMetric(metric);
                        bool newMethod = ByMethod.AddMetric(metric);

                        if (newMethod && Exclude(metric))
                        {
                            metric.Excluded = true;
                        }
                    }
                }
            }
        }
Exemplo n.º 3
0
        public void QuandoEsseFiltroRelaciona(string tipo)
        {
            var type = Type.GetType(tipo);

            type.Should().Not.Be.Null();

            resultingMetric = ((Ce)resultingMetric).Ignoring(type);
        }
        public void StartItem(MetricGroup group, MetricCounter item)
        {
            Check.IsEqual("module", group.Name);
            CodeMetric info = item.Group;

            WriteLine("<module moduleId='{0}' name='{1}' assembly='{2}' assemblyIdentity='{3}'>",
                      _moduleId++,
                      XmlEncode(info.FileName),
                      XmlEncode(info.AssemblyName),
                      XmlEncode(info.AssemblyFullName)
                      );
        }
Exemplo n.º 5
0
 private bool Exclude(CodeMetric metric)
 {
     foreach (Regex regex in _excluded)
     {
         foreach (string fmtName in new string[] { "{0}.{1}", "{0}.{1}.{2}" })
         {
             string fullname = String.Format(fmtName, metric.Namespace, metric.Class, metric.MethodName);
             if (regex.IsMatch(fullname))
             {
                 //Log.Info("Ignoring '{0}' from rule '{1}'", fullname, regex.ToString());
                 return(true);
             }
         }
     }
     return(false);
 }
        void WriteItem(MetricGroup group, MetricCounter item, bool close)
        {
            CodeMetric info = item.Group;

            List <CodeMetric> seqpnts = item.Seqpnts;

            bool anyInstruments = false;
            bool allExcluded    = true;

            foreach (CodeMetric metric in seqpnts)
            {
                anyInstruments |= metric.Instrumented;
                allExcluded    &= metric.Excluded;
            }

            WriteLine("<method name='{0}' excluded='{5}' instrumented='{4}' class='{1}{2}{3}'>",
                      XmlEncode(info.MethodName),
                      XmlEncode(info.Namespace),
                      String.IsNullOrEmpty(info.Namespace) ? String.Empty : ".",
                      XmlEncode(info.Class),
                      anyInstruments ? TRUE : FALSE,
                      allExcluded ? TRUE : FALSE
                      );

            foreach (CodeMetric metric in seqpnts)
            {
                if (metric.Excluded)
                {
                    continue;
                }

                WriteLine("<seqpnt visitcount='{0}' line='{1}' column='{2}' endline='{3}' endcolumn='{4}' excluded='{5}' document='{6}' />",
                          metric.VisitCount,
                          metric.Line,
                          metric.Column,
                          metric.EndLine,
                          metric.EndColumn,
                          metric.Excluded ? TRUE : FALSE,
                          XmlEncode(metric.SrcFile)
                          );
            }

            WriteLine("</method>");
        }
Exemplo n.º 7
0
 public CyclomaticComplexityMetricResult(Declaration declaration, CodeMetric metricReference, int value) : base(declaration, metricReference)
 {
     this.value = value;
 }
Exemplo n.º 8
0
 public void QuandoDesejoObterSuaComplexidadeCiclomaticaCc()
 {
     resultingMetric = Cc.For(workingMethod);
 }
Exemplo n.º 9
0
 public void DadoQueDesejoObterOAcoplamentoEferenteDeTodosOsTiposDesseAssembly()
 {
     resultingMetric = Ce.For(GetType().Assembly);
 }
Exemplo n.º 10
0
		public override string NameOfGroupItem(CodeMetric obj)
		{ return String.Format("{0}.{1}", base.NameOfGroupItem(obj), obj.Class); }
Exemplo n.º 11
0
		public string NameOfGroupItem(CodeMetric obj)
		{ return obj.SrcFile; }
Exemplo n.º 12
0
		public virtual int Compare(CodeMetric x, CodeMetric y)
		{
			return StringComparer.Ordinal.Compare(x.Namespace, y.Namespace);
		}
Exemplo n.º 13
0
		public override int Compare(CodeMetric x, CodeMetric y)
		{
			int result = base.Compare(x, y);
			return result != 0 ? result : StringComparer.Ordinal.Compare(x.MethodName, y.MethodName);
		}
Exemplo n.º 14
0
		public override int GetHashCode(CodeMetric obj)
		{
			return (base.GetHashCode(obj) & 0x4FFFFFFF) + StringComparer.Ordinal.GetHashCode(obj.MethodName);
		}
Exemplo n.º 15
0
		public override bool Equals(CodeMetric x, CodeMetric y)
		{
			return base.Equals(x, y) && StringComparer.Ordinal.Equals(x.MethodName, y.MethodName);
		}
Exemplo n.º 16
0
 public void QuandoConsideroAsReferenciasVindasDoAssembly(string nomeDoAssemblyExterno)
 {
     Assembly assemblyExterno = Assembly.Load(nomeDoAssemblyExterno);
     resultingMetric = ((Ca)resultingMetric).Including(assemblyExterno);
 }
Exemplo n.º 17
0
 public void DesejoIgnorarReferenciasParaTiposDeOutrosAssemblies()
 {
     resultingMetric = ((Ce)resultingMetric).Ignoring(GetType().Assembly.Not());
 }
Exemplo n.º 18
0
 public void QuandoDesejoObterSeuAcoplamentoEferente()
 {
     resultingMetric = Ce.For(workingType);
 }
Exemplo n.º 19
0
		public bool Equals(CodeMetric x, CodeMetric y)
		{
			return StringComparer.OrdinalIgnoreCase.Equals(x.SrcFile, y.SrcFile);
		}
Exemplo n.º 20
0
		public virtual bool Equals(CodeMetric x, CodeMetric y)
		{
			return StringComparer.Ordinal.Equals(x.Namespace, y.Namespace);
		}
Exemplo n.º 21
0
 public void QuandoDesejoObterSuaComplexidadeCiclomaticaCc()
 {
     resultingMetric = Cc.For(workingMethod);
 }
Exemplo n.º 22
0
		public virtual int GetHashCode(CodeMetric obj)
		{
			return StringComparer.Ordinal.GetHashCode(obj.Namespace);
		}
Exemplo n.º 23
0
        public void QuandoDesejoObterAComplexidadeCiclomaticaDeSeuConstrutor()
        {
            ConstructorInfo constructor = workingType.GetConstructor(new Type[0]);

            resultingMetric = Cc.For(constructor);
        }
Exemplo n.º 24
0
		public override bool Equals(CodeMetric x, CodeMetric y)
		{
			return base.Equals(x, y) && StringComparer.Ordinal.Equals(x.Class, y.Class);
		}
Exemplo n.º 25
0
        public void QuandoEsseFiltroRelaciona(string tipo)
        {
            var type = Type.GetType(tipo);
            type.Should().Not.Be.Null();

            resultingMetric = ((Ce)resultingMetric).Ignoring(type);
        }
Exemplo n.º 26
0
		public int Compare(CodeMetric x, CodeMetric y)
		{
			return StringComparer.OrdinalIgnoreCase.Compare(x.SrcFile, y.SrcFile);
		}
Exemplo n.º 27
0
 public void DadoDesejoIgnorarReferenciasParaTiposDesteAssembly()
 {
     resultingMetric = ((Ce)resultingMetric).Ignoring(GetType().Assembly);
 }
Exemplo n.º 28
0
 public void QuandoDesejoObterSeuAcoplamentoAferente()
 {
     resultingMetric = Ca.For(workingType);
 }
Exemplo n.º 29
0
		public int GetHashCode(CodeMetric obj)
		{
			return StringComparer.OrdinalIgnoreCase.GetHashCode(obj.SrcFile);
		}
Exemplo n.º 30
0
 public void DesejoIgnorarReferenciasParaTiposDeOutrosAssemblies()
 {
     resultingMetric = ((Ce)resultingMetric).Ignoring(GetType().Assembly.Not());
 }
Exemplo n.º 31
0
		public string NameOfGroupItem(CodeMetric obj)
		{ return obj.AssemblyName; }
Exemplo n.º 32
0
 public void DadoQueDesejoObterOAcoplamentoEferenteDeTodosOsTiposDesseAssembly()
 {
     resultingMetric = Ce.For(GetType().Assembly);
 }
Exemplo n.º 33
0
		public bool Equals(CodeMetric x, CodeMetric y)
		{
			return StringComparer.Ordinal.Equals(x.AssemblyName, y.AssemblyName);
		}
Exemplo n.º 34
0
		private bool Exclude(CodeMetric metric)
		{
			foreach (Regex regex in _excluded)
			{
				foreach( string fmtName in new string[] { "{0}.{1}", "{0}.{1}.{2}" } )
				{
					string fullname = String.Format(fmtName, metric.Namespace, metric.Class, metric.MethodName);
					if (regex.IsMatch(fullname))
					{
						//Log.Info("Ignoring '{0}' from rule '{1}'", fullname, regex.ToString());
						return true;
					}
				}
			}
			return false;
		}
Exemplo n.º 35
0
		public int Compare(CodeMetric x, CodeMetric y)
		{
			return StringComparer.Ordinal.Compare(x.AssemblyName, y.AssemblyName);
		}
Exemplo n.º 36
0
		public int GetHashCode(CodeMetric obj)
		{
			return StringComparer.Ordinal.GetHashCode(obj.AssemblyName);
		}
Exemplo n.º 37
0
		public virtual string NameOfGroupItem(CodeMetric obj)
		{ return obj.Namespace; }
Exemplo n.º 38
0
 public CyclomaticComplexityListener(CodeMetric owner) : base(owner)
 {
 }
Exemplo n.º 39
0
 public void QuandoDesejoObterAComplexidadeCiclomaticaDeSeuConstrutor()
 {
     ConstructorInfo constructor = workingType.GetConstructor(new Type[0]);
     resultingMetric = Cc.For(constructor);
 }