示例#1
0
 public LSystem()
 {
     axiomRep = "";
     axiom    = new List <Module>();
     rules    = new List <ProductionRule>();
     varMap   = new Dictionary <string, float>();
     mc       = new MetricCounter();
     probMap  = new Dictionary <char, float>();
 }
        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)
                      );
        }
示例#3
0
		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)
			);
		}
        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>");
        }
 public void StopItem(MetricGroup group, MetricCounter item)
 {
     Check.IsEqual("module", group.Name);
     WriteLine("</module>");
 }
 public void WriteItem(MetricGroup group, MetricCounter item)
 {
     WriteItem(group, item, true);
 }
示例#7
0
		public void WriteItem(MetricGroup group, MetricCounter item) { WriteItem(group, item, true); }
示例#8
0
		public void StopItem(MetricGroup group, MetricCounter item) 
		{
			Check.IsEqual("module", group.Name);
			WriteLine("</module>");
		}
示例#9
0
		void WriteItem(MetricGroup group, MetricCounter item, bool close)
		{
			CodeMetric info = item.Group;

            List<CodeMetric> seqpnts = item.Seqpnts;
            List<CodeMetric> unused = new List<CodeMetric>();

			foreach (CodeMetric metric in seqpnts)
			{
                if (!metric.Excluded && metric.Instrumented && metric.VisitCount == 0)
                    unused.Add(metric);
			}

            if (unused.Count == 0)
                return;

            WriteLine("<method name='{0}' class='{1}{2}{3}'>",
                XmlEncode(info.MethodName),
                XmlEncode(info.Namespace),
                String.IsNullOrEmpty(info.Namespace) ? String.Empty : ".",
                XmlEncode(info.Class)
            );

            unused.Sort();

            foreach (CodeMetric metric in unused)
			{
                int lineStart = metric.Line - 1;
                int lineEnd = metric.EndLine - 1;

                int colStart = Math.Max(metric.Column - 1, 0);
                int colEnd = Math.Max(metric.EndColumn - 1, 0);

                string[] src;
                if (!_sourceFiles.TryGetValue(metric.SrcFile, out src))
                {
                    try { src = File.ReadAllLines(metric.SrcFile); }
                    catch (FileNotFoundException) { src = new string[0]; }
                }

                StringBuilder sb = new StringBuilder();
                for (int ix = lineStart; ix < src.Length && ix < lineEnd; ix++)
                {
                    string line = src[ix];
                    if (ix == lineStart) line = line.Substring(Math.Min(colStart, line.Length));
                    sb.AppendLine(line);
                }
                if (lineEnd < src.Length)
                {
                    string line = src[lineEnd];
                    int start = Math.Min(line.Length, lineStart == lineEnd ? colStart : 0);
                    int end = Math.Min(line.Length, Math.Max(start, colEnd));
                    sb.AppendLine(line.Substring(start, end - start));
                }

			    WriteLine("<seqpnt src='{0}'/>", XmlEncode(sb.ToString().Trim()));
			}

			WriteLine("</method>");
		}
示例#10
0
		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>");
		}
示例#11
0
		public void StopItem(MetricGroup group, MetricCounter item) { WriteLine("</{0}>", group.Name); }
示例#12
0
		public void StartItem(MetricGroup group, MetricCounter item) { WriteItem(group, item, false); }
示例#13
0
		void WriteItem(MetricGroup group, MetricCounter item, bool close)
		{
			WriteLine("<{0} name='{1}' sequencePoints='{2}' unvisitedPoints='{3}' coverage='{4}' acceptable='{5}'{6}>",
				group.Name,
				XmlEncode(item.Name),
				item.TotalSeqpnts,
				item.Unvisited,
				Math.Round(item.Coverage, 4),
				ACCEPTABLE,
				close ? " /" : String.Empty
			);
		}