Browse Source

CodeCoverage: Apply C# filter only to .cs files

pull/495/head
Dragan 11 years ago
parent
commit
164af14443
  1. 9
      src/AddIns/Analysis/CodeCoverage/Project/Src/CodeCoverageMethodElement.cs

9
src/AddIns/Analysis/CodeCoverage/Project/Src/CodeCoverageMethodElement.cs

@ -58,6 +58,7 @@ namespace ICSharpCode.CodeCoverage
public string FileID { get; private set; } public string FileID { get; private set; }
public string FileName { get; private set; } public string FileName { get; private set; }
public string FileNameExt { get; private set; }
public bool IsVisited { get; private set; } public bool IsVisited { get; private set; }
public int CyclomaticComplexity { get; private set; } public int CyclomaticComplexity { get; private set; }
public decimal SequenceCoverage { get; private set; } public decimal SequenceCoverage { get; private set; }
@ -86,9 +87,14 @@ namespace ICSharpCode.CodeCoverage
this.FileID = GetFileRef(); this.FileID = GetFileRef();
this.FileName = String.Empty; this.FileName = String.Empty;
this.FileNameExt = String.Empty;
if (!String.IsNullOrEmpty(this.FileID)) { if (!String.IsNullOrEmpty(this.FileID)) {
if (results != null) { if (results != null) {
this.FileName = results.GetFileName(this.FileID); this.FileName = results.GetFileName(this.FileID);
try {
this.FileNameExt = Path.GetExtension(this.FileName);
}
catch {}
if (cacheFileName != this.FileName) { if (cacheFileName != this.FileName) {
cacheFileName = this.FileName; cacheFileName = this.FileName;
cacheDocument = GetSource (cacheFileName); cacheDocument = GetSource (cacheFileName);
@ -303,6 +309,8 @@ namespace ICSharpCode.CodeCoverage
continue; // skip continue; // skip
} }
if (this.FileNameExt == ".cs") {
// 0) Only for C#
// 1) Generated "in" code for IEnumerables contains hidden "try/catch/finally" branches that // 1) Generated "in" code for IEnumerables contains hidden "try/catch/finally" branches that
// one do not want or cannot cover by test-case because is handled earlier at same method. // one do not want or cannot cover by test-case because is handled earlier at same method.
// ie: NullReferenceException in foreach loop is pre-handled at method entry, ie. by Contract.Require(items!=null) // ie: NullReferenceException in foreach loop is pre-handled at method entry, ie. by Contract.Require(items!=null)
@ -321,6 +329,7 @@ namespace ICSharpCode.CodeCoverage
sp.BranchCoverage = true; sp.BranchCoverage = true;
continue; // skip continue; // skip
} }
}
totalBranchCount += sp.BranchExitsCount; totalBranchCount += sp.BranchExitsCount;
totalBranchVisit += sp.BranchExitsVisit; totalBranchVisit += sp.BranchExitsVisit;

Loading…
Cancel
Save