예제 #1
0
 protected BasePersistance(ICommandLine commandLine, ILog logger)
 {
     CommandLine = commandLine;
     _logger = logger;
     CoverageSession = new CoverageSession();
     _trackedMethodId = 0;
 }
		/// <summary>
		/// Updates the coverage results for current OpenCover run on the UI thread.
		/// </summary>
		/// <param name="data">The CoverageSession data.</param>
		public void UpdateCoverageResults(CoverageSession data)
		{
			CoverageSession = data;

			if (CoverageSession != null)
			{
				Dispatcher.Invoke(() =>
				{
					CodeCoverageResultsTreeView.Root = new CoverageNode(data);
				});
			}
		}
예제 #3
0
 public CoverageNode(CoverageSession coverageSession)
 {
     _coverageSession = coverageSession;
     LazyLoading = true;
 }
예제 #4
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="session"></param>
        protected void ReassignCoverageSession(CoverageSession session)
        {
            _moduleMethodMap.Clear();
            CoverageSession = session;
            CoverageSession.Summary = new Summary();
            foreach (var module in CoverageSession.Modules)
            {
                BuildMethodMapForModule(module);
                module.Summary = new Summary();
                foreach (var @class in module.Classes)
                {
                    @class.Summary = new Summary();
                    foreach (var method in @class.Methods)
                    {
                        method.Summary = new Summary();
                        if (method.SequencePoints != null && method.SequencePoints.Any() && method.SequencePoints[0].Offset == method.MethodPoint.Offset)
                        {
                            var point = new[] { method.SequencePoints[0], (SequencePoint)method.MethodPoint }
                                .OrderBy(x => x.OrigSequencePoint)
                                .First();

                            method.MethodPoint = point;
                            method.SequencePoints[0] = point;
                        }
                    }
                }
            }

            InstrumentationPoint.ResetAfterLoading();
            File.ResetAfterLoading();
        }
예제 #5
0
 protected void ClearCoverageSession()
 {
     _moduleMethodMap.Clear();
     CoverageSession = new CoverageSession();
     InstrumentationPoint.Clear();
 }
예제 #6
0
        private static void DisplayResults(CoverageSession coverageSession, ICommandLine parser, ILog logger)
        {
            if (!logger.IsInfoEnabled) 
                return;

            var altTotalClasses = 0;
            var altVisitedClasses = 0;

            var altTotalMethods = 0;
            var altVisitedMethods = 0;

            var unvisitedClasses = new List<string>();
            var unvisitedMethods = new List<string>();

            if (coverageSession.Modules != null)
            {
                foreach (var @class in
                    from module in coverageSession.Modules.Where(x=>x.Classes != null)
                    from @class in module.Classes.Where(c => !c.ShouldSerializeSkippedDueTo())
                    select @class)
                {
                    if (@class.Methods == null) 
                        continue;

                    if (!(@class.Methods.Any(x => !x.ShouldSerializeSkippedDueTo() && x.SequencePoints.Any(y => y.VisitCount > 0))))
                        if ((@class.Methods.Any(x => x.FileRef != null)))
                            unvisitedClasses.Add(@class.FullName);

                    if (@class.Methods.Any(x => x.Visited))
                    {
                        altVisitedClasses += 1;
                        altTotalClasses += 1;
                    }
                    else if (@class.Methods.Any())
                    {
                        altTotalClasses += 1;
                    }

                    foreach (var method in @class.Methods.Where(x=> !x.ShouldSerializeSkippedDueTo()))
                    {
                        if (!(method.SequencePoints.Any(x => x.VisitCount > 0)))
                            if (method.FileRef != null)
                                unvisitedMethods.Add(string.Format("{0}", method.FullName));

                        altTotalMethods += 1;
                        if (method.Visited)
                        {
                            altVisitedMethods += 1;
                        }
                    }
                }
            }

            if (coverageSession.Summary.NumClasses > 0)
            {
                logger.InfoFormat("Visited Classes {0} of {1} ({2})", coverageSession.Summary.VisitedClasses,
                                  coverageSession.Summary.NumClasses, Math.Round(coverageSession.Summary.VisitedClasses * 100.0 / coverageSession.Summary.NumClasses, 2));
                logger.InfoFormat("Visited Methods {0} of {1} ({2})", coverageSession.Summary.VisitedMethods,
                                  coverageSession.Summary.NumMethods, Math.Round(coverageSession.Summary.VisitedMethods * 100.0 / coverageSession.Summary.NumMethods, 2));
                logger.InfoFormat("Visited Points {0} of {1} ({2})", coverageSession.Summary.VisitedSequencePoints,
                                  coverageSession.Summary.NumSequencePoints, coverageSession.Summary.SequenceCoverage);
                logger.InfoFormat("Visited Branches {0} of {1} ({2})", coverageSession.Summary.VisitedBranchPoints,
                                  coverageSession.Summary.NumBranchPoints, coverageSession.Summary.BranchCoverage);

                logger.InfoFormat("");
                logger.InfoFormat(
                    "==== Alternative Results (includes all methods including those without corresponding source) ====");
                logger.InfoFormat("Alternative Visited Classes {0} of {1} ({2})", altVisitedClasses,
                                  altTotalClasses, altTotalClasses == 0 ? 0 : Math.Round(altVisitedClasses * 100.0 / altTotalClasses, 2));
                logger.InfoFormat("Alternative Visited Methods {0} of {1} ({2})", altVisitedMethods,
                                  altTotalMethods, altTotalMethods == 0 ? 0 : Math.Round(altVisitedMethods * 100.0 / altTotalMethods, 2));

                if (parser.ShowUnvisited)
                {
                    logger.InfoFormat("");
                    logger.InfoFormat("====Unvisited Classes====");
                    foreach (var unvisitedClass in unvisitedClasses)
                    {
                        logger.InfoFormat(unvisitedClass);
                    }

                    logger.InfoFormat("");
                    logger.InfoFormat("====Unvisited Methods====");
                    foreach (var unvisitedMethod in unvisitedMethods)
                    {
                        logger.InfoFormat(unvisitedMethod);
                    }
                }
            }
            else
            {
                logger.InfoFormat("No results, this could be for a number of reasons. The most common reasons are:");
                logger.InfoFormat("    1) missing PDBs for the assemblies that match the filter please review the");
                logger.InfoFormat("    output file and refer to the Usage guide (Usage.rtf) about filters.");
                logger.InfoFormat("    2) the profiler may not be registered correctly, please refer to the Usage");
                logger.InfoFormat("    guide and the -register switch.");
            }
        }
예제 #7
0
 public BasePersistance(ICommandLine commandLine)
 {
     _commandLine = commandLine;
     CoverageSession = new CoverageSession();
 }
예제 #8
0
 public BasePersistance(ICommandLine commandLine)
 {
     _commandLine = commandLine;
     CoverageSession = new CoverageSession();
     _trackedMethodId = 0;
 }
		/// <summary>
		/// Updates the coverage results for current OpenCover run on the UI thread.
		/// </summary>
		/// <param name="data">The CoverageSession data.</param>
		public void UpdateCoverageResults(CoverageSession data)
		{
			CoverageSession = data;

			if (CoverageSession != null)
			{
				Dispatcher.BeginInvoke(new Action(() =>
				{
					CodeCoverageResultsTreeView.Root = new CoverageNode(data);
					IsLoading = false;
				}), null);
			}
		}
		/// <summary>
		/// Updates the coverage results for current OpenCover run on the UI thread.
		/// </summary>
		/// <param name="data">The CoverageSession data.</param>
		public void UpdateCoverageResults(CoverageSession data)
		{
			CoverageSession = data;

			if (CoverageSession != null)
			{
				Dispatcher.BeginInvoke(new Action(() =>
				{
					CodeCoverageResultsTreeView.Root = new CoverageNode(data);
					IsLoading = false;

                    if (NewCoverageDataAvailable != null)
                        NewCoverageDataAvailable(this, EventArgs.Empty);

				}), null);
			}
		}
	    /// <summary>
		/// Updates the coverage results for current OpenCover run on the UI thread.
		/// </summary>
		/// <param name="data">The CoverageSession data.</param>
		public void UpdateCoverageResults(CoverageSession data)
		{
		    CoverageSession = data;

		    UpdateCoverageResults();
		}