< Summary

Information
Class: DirectSight.Parser.Analysis.CodeFile
Assembly DirectSight
File(s): /home/runner/work/DirectSight/DirectSight/DirectSight/Parser/Analysis/CodeFile.cs
Line coverage
92%
Covered lines: 314
Uncovered lines: 25
Coverable lines: 339
Total lines: 690
Line coverage: 92.6%
Branch coverage
86%
Covered branches: 112
Total branches: 130
Branch coverage: 86.1%
Method coverage

Metrics

MethodBranch coverage Cyclomatic complexity NPath complexity Sequence coverage
.ctor(...)50%8877.77%
.ctor(...)100%11100%
.ctor(...)100%11100%
.ctor(...)100%11100%
ToString()100%110%
Equals(...)100%88100%
GetHashCode()100%11100%
CoverageQuotaInRange(...)66.66%181891.3%
AddCoverageByTestMethod(...)66.66%6673.33%
AddMethodMetric(...)100%11100%
AddCodeElement(...)100%11100%
AnalyzeFile(...)100%2222100%
Merge(...)95.83%484895.14%
MergeCoverageByTrackedMethod(...)100%1212100%

File(s)

/home/runner/work/DirectSight/DirectSight/DirectSight/Parser/Analysis/CodeFile.cs

#LineLine coverage
 1using System;
 2using System.Collections.Generic;
 3using System.Linq;
 4using DirectSight.Common;
 5using DirectSight.Logging;
 6using DirectSight.Parser.Analysis.LineCoverage;
 7using DirectSight.Parser.FileReading;
 8
 9namespace DirectSight.Parser.Analysis;
 10
 11/// <summary>
 12/// Represents a source code file.
 13/// </summary>
 14public class CodeFile
 15{
 16    /// <summary>
 17    /// The line coverage by test method.
 18    /// </summary>
 154919    private readonly IDictionary<TestMethod, CoverageByTrackedMethod> lineCoveragesByTestMethod = new Dictionary<TestMet
 20
 21    /// <summary>
 22    /// The method metrics of the class.
 23    /// </summary>
 154924    private readonly HashSet<MethodMetric> methodMetrics = [];
 25
 26    /// <summary>
 27    /// The code elements.
 28    /// </summary>
 154929    private readonly HashSet<CodeElement> codeElements = [];
 30
 31    /// <summary>
 32    /// Array containing the coverage information by line number.
 33    /// -1: Not coverable
 34    /// 0: Not visited
 35    /// >0: Number of visits
 36    /// </summary>
 37    private ILineInfo<int> lineCoverage;
 38
 39    /// <summary>
 40    /// Array containing the line visit status by line number.
 41    /// </summary>
 42    private ILineInfo<LineVisitStatus> lineVisitStatus;
 43
 44    /// <summary>
 45    /// The branches by line number.
 46    /// </summary>
 47    private IDictionary<int, ICollection<Branch>> branches;
 48
 49    /// <summary>
 50    /// The optional additional file reader.
 51    /// </summary>
 52    private IFileReader additionalFileReader;
 53
 54    /// <summary>
 55    /// The number of covered lines.
 56    /// </summary>
 57    private int coveredLines;
 58
 59    /// <summary>
 60    /// The number of coverable lines.
 61    /// </summary>
 62    private int coverableLines;
 63
 64    /// <summary>
 65    /// Initializes a new instance of the <see cref="CodeFile" /> class.
 66    /// </summary>
 67    /// <param name="path">The path of the file.</param>
 68    /// <param name="lineCoverage">The line coverage.</param>
 69    /// <param name="lineVisitStatus">The line visit status.</param>
 70    internal CodeFile(string path, ILineInfo<int> lineCoverage, ILineInfo<LineVisitStatus> lineVisitStatus)
 1671        : this(path, lineCoverage, lineVisitStatus, null, null)
 1672    {
 1673    }
 74
 75    /// <summary>
 76    /// Initializes a new instance of the <see cref="CodeFile" /> class.
 77    /// </summary>
 78    /// <param name="path">The path of the file.</param>
 79    /// <param name="lineCoverage">The line coverage.</param>
 80    /// <param name="lineVisitStatus">The line visit status.</param>
 81    /// <param name="additionalFileReader">The optional additional file reader.</param>
 82    internal CodeFile(string path, ILineInfo<int> lineCoverage, ILineInfo<LineVisitStatus> lineVisitStatus, IFileReader 
 283        : this(path, lineCoverage, lineVisitStatus, null, additionalFileReader)
 284    {
 285    }
 86
 87    /// <summary>
 88    /// Initializes a new instance of the <see cref="CodeFile" /> class.
 89    /// </summary>
 90    /// <param name="path">The path.</param>
 91    /// <param name="lineCoverage">The line coverage.</param>
 92    /// <param name="lineVisitStatus">The line visit status.</param>
 93    /// <param name="branches">The branches.</param>
 94    internal CodeFile(string path, ILineInfo<int> lineCoverage, ILineInfo<LineVisitStatus> lineVisitStatus, IDictionary<
 153195        : this(path, lineCoverage, lineVisitStatus, branches, null)
 153196    {
 153197    }
 98
 99    /// <summary>
 100    /// Initializes a new instance of the <see cref="CodeFile" /> class.
 101    /// </summary>
 102    /// <param name="path">The path.</param>
 103    /// <param name="lineCoverage">The line coverage.</param>
 104    /// <param name="lineVisitStatus">The line visit status.</param>
 105    /// <param name="branches">The branches.</param>
 106    /// <param name="additionalFileReader">The optional additional file reader.</param>
 1549107    internal CodeFile(
 1549108        string path,
 1549109        ILineInfo<int> lineCoverage,
 1549110        ILineInfo<LineVisitStatus> lineVisitStatus,
 1549111        IDictionary<int, ICollection<Branch>> branches,
 1549112        IFileReader additionalFileReader)
 1549113    {
 1549114        if (lineCoverage == null)
 0115        {
 0116            throw new ArgumentNullException(nameof(lineCoverage));
 117        }
 118
 1549119        if (lineVisitStatus == null)
 0120        {
 0121            throw new ArgumentNullException(nameof(lineVisitStatus));
 122        }
 123
 1549124        if (lineCoverage.LongLength != lineVisitStatus.LongLength)
 0125        {
 0126            throw new ArgumentException("Length of 'lineCoverage' and 'lineVisitStatus' must match", nameof(lineVisitSta
 127        }
 128
 1549129        this.Path = path ?? throw new ArgumentNullException(nameof(path));
 1549130        this.lineCoverage = lineCoverage;
 1549131        this.lineVisitStatus = lineVisitStatus;
 1549132        this.branches = branches;
 1549133        this.additionalFileReader = additionalFileReader;
 134
 46475135        this.coveredLines = this.lineCoverage.Count(l => l > 0);
 46475136        this.coverableLines = this.lineCoverage.Count(l => l >= 0);
 1549137    }
 138
 139    /// <summary>
 140    /// Gets the path.
 141    /// </summary>
 142    /// <value>The path.</value>
 5076143    public string Path { get; }
 144
 145    /// <summary>
 146    /// Gets the test methods.
 147    /// </summary>
 148    /// <value>
 149    /// The test methods.
 150    /// </value>
 104151    public IEnumerable<TestMethod> TestMethods => this.lineCoveragesByTestMethod.Keys;
 152
 153    /// <summary>
 154    /// Gets the method metrics.
 155    /// </summary>
 156    /// <value>The method metrics.</value>
 173157    public IEnumerable<MethodMetric> MethodMetrics => this.methodMetrics;
 158
 159    /// <summary>
 160    /// Gets the code elements.
 161    /// </summary>
 162    /// <value>
 163    /// The code elements.
 164    /// </value>
 689165    public IEnumerable<CodeElement> CodeElements => this.codeElements;
 166
 167    /// <summary>
 168    /// Gets the number of covered lines.
 169    /// </summary>
 170    /// <value>The number of covered lines.</value>
 1589171    public int CoveredLines => this.coveredLines;
 172
 173    /// <summary>
 174    /// Gets the number of coverable lines.
 175    /// </summary>
 176    /// <value>The number of coverable lines.</value>
 2528177    public int CoverableLines => this.coverableLines;
 178
 179    /// <summary>
 180    /// Gets the number of total lines.
 181    /// </summary>
 182    /// <value>The number of total lines.</value>
 480183    public int? TotalLines { get; private set; }
 184
 185    /// <summary>
 186    /// Gets line coverage information by line number for this file.
 187    /// </summary>
 0188    public IReadOnlyLineInfo<int> LineCoverage => this.lineCoverage;
 189
 190    /// <summary>
 191    /// Gets line visit status by line number for this file.
 192    /// </summary>
 2193    public IReadOnlyLineInfo<LineVisitStatus> LineVisitStatus => this.lineVisitStatus;
 194
 195    /// <summary>
 196    /// Gets the branches by line number.
 197    /// </summary>
 0198    public IDictionary<int, ICollection<Branch>> BranchesByLine => this.branches ?? new Dictionary<int, ICollection<Bran
 199
 200    /// <summary>
 201    /// Gets the number of covered branches.
 202    /// </summary>
 203    /// <value>
 204    /// The number of covered branches.
 205    /// </value>
 206    public int? CoveredBranches
 207    {
 208        get
 1191209        {
 1191210            if (this.branches == null)
 2211            {
 2212                return null;
 213            }
 214
 2255215            return this.branches.SafeSum(l => l.Value.Count(b => b.BranchVisits > 0));
 1191216        }
 217    }
 218
 219    /// <summary>
 220    /// Gets the number of total branches.
 221    /// </summary>
 222    /// <value>
 223    /// The number of total branches.
 224    /// </value>
 225    public int? TotalBranches
 226    {
 227        get
 2023228        {
 2023229            if (this.branches == null)
 2230            {
 2231                return null;
 232            }
 233
 2584234            return this.branches.SafeSum(l => l.Value.Count);
 2023235        }
 236    }
 237
 238    /// <summary>
 239    /// Gets the number of covered code elements.
 240    /// </summary>
 241    /// <value>
 242    /// The number of covered code elements.
 243    /// </value>
 244    public int CoveredCodeElements
 245    {
 246        get
 325247        {
 325248            return this.CodeElements.Count(
 1318249                x => x.CoverageQuota.GetValueOrDefault() > 0);
 325250        }
 251    }
 252
 253    /// <summary>
 254    /// Gets the number of fully covered code elements.
 255    /// </summary>
 256    /// <value>
 257    /// The number of fully covered code elements.
 258    /// </value>
 259    public int FullCoveredCodeElements
 260    {
 261        get
 324262        {
 324263            return this.CodeElements.Count(
 1314264                x => this.lineCoverage.Skip(x.FirstLine)
 1314265                    .Take(x.LastLine - x.FirstLine + 1)
 4608266                    .All(y => y != 0));
 324267        }
 268    }
 269
 270    /// <summary>
 271    /// Gets the number of total code elements.
 272    /// </summary>
 273    /// <value>
 274    /// The number of total code elements.
 275    /// </value>
 972276    public int TotalCodeElements => this.codeElements.Count;
 277
 278    /// <summary>
 279    /// Gets the coverage quota of the file.
 280    /// </summary>
 281    /// <value>The coverage quota.</value>
 282    public decimal? CoverageQuota
 283    {
 284        get
 0285        {
 0286            return (this.CoverableLines == 0) ? (decimal?)null : MathExtensions.CalculatePercentage(this.CoveredLines, t
 0287        }
 288    }
 289
 290    /// <summary>
 291    /// Returns a <see cref="string" /> that represents this instance.
 292    /// </summary>
 293    /// <returns>
 294    /// A <see cref="string" /> that represents this instance.
 295    /// </returns>
 296    public override string ToString()
 0297    {
 0298        return this.Path;
 0299    }
 300
 301    /// <summary>
 302    /// Determines whether the specified <see cref="object"/> is equal to this instance.
 303    /// </summary>
 304    /// <param name="obj">The <see cref="object"/> to compare with this instance.</param>
 305    /// <returns>
 306    ///   <c>true</c> if the specified <see cref="object"/> is equal to this instance; otherwise, <c>false</c>.
 307    /// </returns>
 308    public override bool Equals(object obj)
 449309    {
 449310        if (obj == null || !obj.GetType().Equals(typeof(CodeFile)))
 2311        {
 2312            return false;
 313        }
 314        else
 447315        {
 447316            var codeFile = (CodeFile)obj;
 317
 447318            string fileNameToCompare = codeFile.Path.Substring(codeFile.Path.LastIndexOf('/') + 1);
 447319            int indexOfSlash = codeFile.Path.LastIndexOf('/');
 320
 447321            if (indexOfSlash != -1)
 447322            {
 447323                fileNameToCompare = codeFile.Path.Substring(indexOfSlash + 1);
 447324            }
 325
 447326            string fileName = this.Path.Substring(this.Path.LastIndexOf('/') + 1);
 447327            indexOfSlash = this.Path.LastIndexOf('/');
 447328            if (indexOfSlash != -1)
 447329            {
 447330                fileName = this.Path.Substring(this.Path.LastIndexOf('/') + 1);
 447331            }
 332
 447333            return fileName.Equals(fileNameToCompare, StringComparison.OrdinalIgnoreCase);
 334        }
 449335    }
 336
 337    /// <summary>
 338    /// Returns a hash code for this instance.
 339    /// </summary>
 340    /// <returns>
 341    /// A hash code for this instance, suitable for use in hashing algorithms and data structures like a hash table.
 342    /// </returns>
 108343    public override int GetHashCode() => this.Path.GetHashCode();
 344
 345    /// <summary>
 346    /// Calculates the coverage quota in a given range of lines.
 347    /// </summary>
 348    /// <param name="firstLine">The first line.</param>
 349    /// <param name="lastLine">The last line.</param>
 350    /// <returns>The coverage quota or <code>null</code> if not applicable.</returns>
 351    internal decimal? CoverageQuotaInRange(int firstLine, int lastLine)
 5520352    {
 5520353        if (firstLine < 0
 5520354            || firstLine >= this.lineVisitStatus.Length
 5520355            || lastLine < 0
 5520356            || lastLine >= this.lineVisitStatus.Length
 5520357            || firstLine > lastLine)
 0358        {
 0359            return null;
 360        }
 361
 5520362        int coverableLines = 0;
 5520363        int coveredLines = 0;
 364
 62040365        for (int i = firstLine; i <= lastLine; i++)
 25500366        {
 25500367            if (this.lineVisitStatus[i] != Analysis.LineVisitStatus.NotCoverable)
 22215368            {
 22215369                coverableLines++;
 22215370            }
 371
 25500372            if (this.lineVisitStatus[i] > Analysis.LineVisitStatus.NotCovered)
 13989373            {
 13989374                coveredLines++;
 13989375            }
 25500376        }
 377
 5520378        return (coverableLines == 0) ? (decimal?)null : MathExtensions.CalculatePercentage(coveredLines, coverableLines)
 5520379    }
 380
 381    /// <summary>
 382    /// Adds the coverage by test method.
 383    /// </summary>
 384    /// <param name="testMethod">The test method.</param>
 385    /// <param name="trackedMethodCoverage">The coverage by for test method.</param>
 386    internal void AddCoverageByTestMethod(TestMethod testMethod, CoverageByTrackedMethod trackedMethodCoverage)
 456387    {
 456388        if (testMethod == null)
 0389        {
 0390            throw new ArgumentNullException(nameof(testMethod));
 391        }
 392
 456393        if (trackedMethodCoverage == null)
 0394        {
 0395            throw new ArgumentNullException(nameof(trackedMethodCoverage));
 396        }
 397
 456398        if (!this.lineCoveragesByTestMethod.TryGetValue(testMethod, out CoverageByTrackedMethod existingTrackedMethodCov
 455399        {
 455400            this.lineCoveragesByTestMethod.Add(testMethod, trackedMethodCoverage);
 455401        }
 402        else
 1403        {
 1404            this.lineCoveragesByTestMethod[testMethod] = MergeCoverageByTrackedMethod(existingTrackedMethodCoverage, tra
 1405        }
 456406    }
 407
 408    /// <summary>
 409    /// Adds the given method metric.
 410    /// </summary>
 411    /// <param name="methodMetric">The method metric.</param>
 412    internal void AddMethodMetric(MethodMetric methodMetric)
 2988413    {
 2988414        this.methodMetrics.Add(methodMetric);
 2988415    }
 416
 417    /// <summary>
 418    /// Adds the code element.
 419    /// </summary>
 420    /// <param name="codeElement">The code element.</param>
 421    internal void AddCodeElement(CodeElement codeElement)
 4426422    {
 4426423        this.codeElements.Add(codeElement);
 4426424    }
 425
 426    /// <summary>
 427    /// Performs the analysis of the source file.
 428    /// </summary>
 429    /// <param name="fileReader">The file reader.</param>
 430    /// <returns>The analysis result.</returns>
 431    internal FileAnalysis AnalyzeFile(IFileReader fileReader)
 65432    {
 65433        string error = null;
 434
 65435        string[] lines = null;
 436
 65437        if (this.additionalFileReader != null)
 2438        {
 2439            lines = this.additionalFileReader.LoadFile(this.Path, out error);
 2440        }
 441
 65442        if (this.additionalFileReader == null || error != null)
 64443        {
 64444            error = null;
 64445            lines = fileReader.LoadFile(this.Path, out error);
 64446        }
 447
 65448        if (error != null)
 2449        {
 2450            ConsoleLogger.Error(error);
 2451            lines = this.lineCoverage
 8452                .Select(l => string.Empty)
 2453                .ToArray();
 2454        }
 455
 65456        this.TotalLines = lines.Length;
 457
 65458        int currentLineNumber = 0;
 459
 65460        var result = new FileAnalysis(this.Path, error);
 65461        ICollection<Branch> branchesOfLine = null;
 462
 5279463        foreach (var line in lines)
 2542464        {
 2542465            currentLineNumber++;
 2542466            int visits = this.lineCoverage.Length > currentLineNumber ? this.lineCoverage[currentLineNumber] : -1;
 2542467            LineVisitStatus lineVisitStatus = this.lineVisitStatus.Length > currentLineNumber ? this.lineVisitStatus[cur
 468
 2542469            var lineCoverageByTestMethod = this.lineCoveragesByTestMethod
 2542470                .ToDictionary(
 2524471                l => l.Key,
 2542472                l =>
 2524473                {
 2524474                    if (l.Value.Coverage.Length > currentLineNumber)
 1908475                    {
 1908476                        return new ShortLineAnalysis(l.Value.Coverage[currentLineNumber], l.Value.LineVisitStatus[curren
 2542477                    }
 2542478                    else
 616479                    {
 616480                        return new ShortLineAnalysis(-1, Analysis.LineVisitStatus.NotCoverable);
 2542481                    }
 5066482                });
 483
 2542484            if (this.branches != null && this.branches.TryGetValue(currentLineNumber, out branchesOfLine))
 25485            {
 25486                result.AddLineAnalysis(
 25487                    new LineAnalysis(
 25488                        visits,
 25489                        lineVisitStatus,
 25490                        lineCoverageByTestMethod,
 25491                        currentLineNumber,
 25492                        line.TrimEnd(),
 50493                        branchesOfLine.Count(b => b.BranchVisits > 0),
 25494                        branchesOfLine.Count))
 25495                ;
 25496            }
 497            else
 2517498            {
 2517499                result.AddLineAnalysis(
 2517500                    new LineAnalysis(
 2517501                        visits,
 2517502                        lineVisitStatus,
 2517503                        lineCoverageByTestMethod,
 2517504                        currentLineNumber,
 2517505                        line.TrimEnd()));
 2517506            }
 2542507        }
 508
 65509        return result;
 65510    }
 511
 512    /// <summary>
 513    /// Merges the given file with the current instance.
 514    /// </summary>
 515    /// <param name="file">The file to merge.</param>
 516    internal void Merge(CodeFile file)
 390517    {
 390518        if (file == null)
 0519        {
 0520            throw new ArgumentNullException(nameof(file));
 521        }
 522
 523        // Resize coverage array if necessary
 390524        if (file.lineCoverage.LongLength > this.lineCoverage.LongLength)
 4525        {
 4526            this.lineCoverage = this.lineCoverage.Resize(file.lineCoverage.LongLength);
 4527        }
 528
 529        // Resize line visit status array if necessary
 390530        if (file.lineVisitStatus.LongLength > this.lineVisitStatus.LongLength)
 4531        {
 4532            this.lineVisitStatus = this.lineVisitStatus.Resize(file.lineVisitStatus.LongLength);
 4533        }
 534
 390535        if (file.branches != null)
 387536        {
 387537            if (this.branches == null)
 1538            {
 1539                this.branches = new Dictionary<int, ICollection<Branch>>();
 1540            }
 541
 1369542            foreach (var branchByLine in file.branches)
 104543            {
 104544                if (this.branches.TryGetValue(branchByLine.Key, out ICollection<Branch> existingBranches))
 101545                {
 719546                    foreach (var branch in branchByLine.Value)
 208547                    {
 532548                        Branch existingBranch = existingBranches.FirstOrDefault(b => b.Equals(branch));
 208549                        if (existingBranch != null)
 207550                        {
 207551                            existingBranch.BranchVisits += branch.BranchVisits;
 207552                        }
 553                        else
 1554                        {
 1555                            existingBranches.Add(branch);
 1556                        }
 208557                    }
 101558                }
 559                else
 3560                {
 3561                    this.branches.Add(branchByLine);
 3562                }
 104563            }
 387564        }
 565
 23500566        for (long i = 0; i < file.lineCoverage.LongLength; i++)
 11360567        {
 11360568            int coverage = this.lineCoverage[i];
 569
 11360570            if (coverage < 0)
 7192571            {
 7192572                coverage = file.lineCoverage[i];
 7192573            }
 4168574            else if (file.lineCoverage[i] > 0)
 2654575            {
 2654576                coverage += file.lineCoverage[i];
 2654577            }
 578
 11360579            this.lineCoverage[i] = coverage;
 11360580        }
 581
 11750582        this.coveredLines = this.lineCoverage.Count(l => l > 0);
 11750583        this.coverableLines = this.lineCoverage.Count(l => l >= 0);
 584
 23500585        for (long i = 0; i < file.lineVisitStatus.LongLength; i++)
 11360586        {
 11360587            int lineVisitStatus = Math.Max((int)this.lineVisitStatus[i], (int)file.lineVisitStatus[i]);
 588
 11360589            this.lineVisitStatus[i] = (LineVisitStatus)lineVisitStatus;
 590
 11360591            if (this.lineVisitStatus[i] == Analysis.LineVisitStatus.PartiallyCovered
 11360592                && this.branches != null
 11360593                && this.branches.TryGetValue((int)i, out ICollection<Branch> branches))
 74594            {
 218595                if (branches.All(b => b.BranchVisits > 0))
 1596                {
 1597                    this.lineVisitStatus[i] = Analysis.LineVisitStatus.Covered;
 1598                }
 74599            }
 11360600        }
 601
 1174602        foreach (var lineCoverageByTestMethod in file.lineCoveragesByTestMethod)
 2603        {
 2604            this.lineCoveragesByTestMethod.TryGetValue(lineCoverageByTestMethod.Key, out CoverageByTrackedMethod existin
 605
 2606            if (existingTrackedMethodCoverage == null)
 1607            {
 1608                this.lineCoveragesByTestMethod.Add(lineCoverageByTestMethod);
 1609            }
 610            else
 1611            {
 1612                this.lineCoveragesByTestMethod[lineCoverageByTestMethod.Key] = MergeCoverageByTrackedMethod(existingTrac
 1613            }
 2614        }
 615
 2672616        foreach (var methodMetric in file.methodMetrics)
 751617        {
 2419618            var existingMethodMetric = this.methodMetrics.FirstOrDefault(m => m.Equals(methodMetric));
 751619            if (existingMethodMetric != null)
 751620            {
 751621                existingMethodMetric.Merge(methodMetric);
 751622            }
 623            else
 0624            {
 0625                this.AddMethodMetric(methodMetric);
 0626            }
 751627        }
 628
 3364629        foreach (var codeElement in file.codeElements)
 1097630        {
 1097631            this.codeElements.Add(codeElement);
 1097632        }
 633
 3364634        foreach (var codeElement in this.codeElements)
 1097635        {
 1097636            codeElement.ApplyMaximumCoverageQuota(this.CoverageQuotaInRange(codeElement.FirstLine, codeElement.LastLine)
 1097637        }
 638
 390639        if (file.additionalFileReader == null)
 390640        {
 390641            file.additionalFileReader = this.additionalFileReader;
 390642        }
 390643    }
 644
 645    /// <summary>
 646    /// Merges the two tracked method coverage.
 647    /// </summary>
 648    /// <param name="existingTrackedMethodCoverage">The existing tracked method coverage.</param>
 649    /// <param name="lineCoverageByTestMethod">The new line coverage by test method.</param>
 650    /// <returns>The merged tracked method coverage.</returns>
 651    private static CoverageByTrackedMethod MergeCoverageByTrackedMethod(CoverageByTrackedMethod existingTrackedMethodCov
 2652    {
 653        // Resize coverage array if neccessary
 2654        if (lineCoverageByTestMethod.Coverage.LongLength > existingTrackedMethodCoverage.Coverage.LongLength)
 1655        {
 1656            existingTrackedMethodCoverage.Coverage = lineCoverageByTestMethod.Coverage.Resize(lineCoverageByTestMethod.C
 1657        }
 658
 659        // Resize line visit status array if neccessary
 2660        if (lineCoverageByTestMethod.LineVisitStatus.LongLength > existingTrackedMethodCoverage.LineVisitStatus.LongLeng
 1661        {
 1662            existingTrackedMethodCoverage.LineVisitStatus = lineCoverageByTestMethod.LineVisitStatus.Resize(lineCoverage
 1663        }
 664
 48665        for (long i = 0; i < lineCoverageByTestMethod.Coverage.LongLength; i++)
 22666        {
 22667            int coverage = existingTrackedMethodCoverage.Coverage[i];
 668
 22669            if (coverage < 0)
 8670            {
 8671                coverage = lineCoverageByTestMethod.Coverage[i];
 8672            }
 14673            else if (lineCoverageByTestMethod.Coverage[i] > 0)
 7674            {
 7675                coverage += lineCoverageByTestMethod.Coverage[i];
 7676            }
 677
 22678            existingTrackedMethodCoverage.Coverage[i] = coverage;
 22679        }
 680
 48681        for (long i = 0; i < lineCoverageByTestMethod.LineVisitStatus.LongLength; i++)
 22682        {
 22683            int lineVisitStatus = Math.Max((int)existingTrackedMethodCoverage.LineVisitStatus[i], (int)lineCoverageByTes
 684
 22685            existingTrackedMethodCoverage.LineVisitStatus[i] = (LineVisitStatus)lineVisitStatus;
 22686        }
 687
 2688        return existingTrackedMethodCoverage;
 2689    }
 690}

Methods/Properties

.ctor(System.String,DirectSight.Parser.Analysis.LineCoverage.ILineInfo`1<System.Int32>,DirectSight.Parser.Analysis.LineCoverage.ILineInfo`1<DirectSight.Parser.Analysis.LineVisitStatus>,System.Collections.Generic.IDictionary`2<System.Int32,System.Collections.Generic.ICollection`1<DirectSight.Parser.Analysis.Branch>>,DirectSight.Parser.FileReading.IFileReader)
.ctor(System.String,DirectSight.Parser.Analysis.LineCoverage.ILineInfo`1<System.Int32>,DirectSight.Parser.Analysis.LineCoverage.ILineInfo`1<DirectSight.Parser.Analysis.LineVisitStatus>)
.ctor(System.String,DirectSight.Parser.Analysis.LineCoverage.ILineInfo`1<System.Int32>,DirectSight.Parser.Analysis.LineCoverage.ILineInfo`1<DirectSight.Parser.Analysis.LineVisitStatus>,DirectSight.Parser.FileReading.IFileReader)
.ctor(System.String,DirectSight.Parser.Analysis.LineCoverage.ILineInfo`1<System.Int32>,DirectSight.Parser.Analysis.LineCoverage.ILineInfo`1<DirectSight.Parser.Analysis.LineVisitStatus>,System.Collections.Generic.IDictionary`2<System.Int32,System.Collections.Generic.ICollection`1<DirectSight.Parser.Analysis.Branch>>)
Path()
TestMethods()
MethodMetrics()
CodeElements()
CoveredLines()
CoverableLines()
TotalLines()
LineCoverage()
LineVisitStatus()
BranchesByLine()
CoveredBranches()
TotalBranches()
CoveredCodeElements()
FullCoveredCodeElements()
TotalCodeElements()
CoverageQuota()
ToString()
Equals(System.Object)
GetHashCode()
CoverageQuotaInRange(System.Int32,System.Int32)
AddCoverageByTestMethod(DirectSight.Parser.Analysis.TestMethod,DirectSight.Parser.Analysis.CoverageByTrackedMethod)
AddMethodMetric(DirectSight.Parser.Analysis.MethodMetric)
AddCodeElement(DirectSight.Parser.Analysis.CodeElement)
AnalyzeFile(DirectSight.Parser.FileReading.IFileReader)
Merge(DirectSight.Parser.Analysis.CodeFile)
MergeCoverageByTrackedMethod(DirectSight.Parser.Analysis.CoverageByTrackedMethod,DirectSight.Parser.Analysis.CoverageByTrackedMethod)