|
|
@ -86,6 +86,9 @@ namespace ICSharpCode.CodeCoverage |
|
|
|
this.IsStatic = this.GetBooleanAttributeValue("isStatic"); |
|
|
|
this.IsStatic = this.GetBooleanAttributeValue("isStatic"); |
|
|
|
if ( !String.IsNullOrEmpty( this.FileID ) ) { |
|
|
|
if ( !String.IsNullOrEmpty( this.FileID ) ) { |
|
|
|
this.SequencePoints = this.GetSequencePoints(); |
|
|
|
this.SequencePoints = this.GetSequencePoints(); |
|
|
|
|
|
|
|
this.BodyStartSP = getBodyStartSP(this.SequencePoints); |
|
|
|
|
|
|
|
this.BodyFinalSP = getBodyFinalSP(this.SequencePoints); |
|
|
|
|
|
|
|
this.SequencePoints = this.FilterSequencePoints(this.SequencePoints); |
|
|
|
this.BranchPoints = this.GetBranchPoints(); |
|
|
|
this.BranchPoints = this.GetBranchPoints(); |
|
|
|
this.BranchCoverageRatio = this.GetBranchRatio(); |
|
|
|
this.BranchCoverageRatio = this.GetBranchRatio(); |
|
|
|
this.BranchCoverage = this.GetBranchCoverage(); |
|
|
|
this.BranchCoverage = this.GetBranchCoverage(); |
|
|
@ -123,23 +126,27 @@ namespace ICSharpCode.CodeCoverage |
|
|
|
|
|
|
|
|
|
|
|
sps.Add(sp); |
|
|
|
sps.Add(sp); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
return sps; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<CodeCoverageSequencePoint> FilterSequencePoints(List<CodeCoverageSequencePoint> sps) { |
|
|
|
|
|
|
|
|
|
|
|
if (sps.Count > 2) { |
|
|
|
List<CodeCoverageSequencePoint> returnList = sps; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (sps.Count > 2 && |
|
|
|
|
|
|
|
this.BodyStartSP != null && |
|
|
|
|
|
|
|
this.BodyFinalSP != null ) { |
|
|
|
|
|
|
|
|
|
|
|
// After ccrewrite ContractClass/ContractClassFor
|
|
|
|
// After ccrewrite ContractClass/ContractClassFor
|
|
|
|
// sequence point(s) from another file/class/method
|
|
|
|
// sequence point(s) from another file/class/method
|
|
|
|
// is inserted into this method sequence points
|
|
|
|
// is inserted into this method sequence points
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// To remove alien sequence points, all points
|
|
|
|
// To remove alien sequence points, all sequence points on lines
|
|
|
|
// before method signature and after end-brackets xxx{} are removed
|
|
|
|
// before method signature and after end-brackets xxx{} are removed
|
|
|
|
|
|
|
|
// If ContractClassFor is in another file but matches this method lines
|
|
|
|
this.BodyStartSP = getBodyStartSP(sps); |
|
|
|
// then, afaik, not much can be done to remove inserted alien SP's
|
|
|
|
if (this.BodyStartSP == null) { return sps; } |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.BodyFinalSP = getBodyFinalSP(sps); |
|
|
|
|
|
|
|
if (this.BodyFinalSP == null) { return sps; } |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<CodeCoverageSequencePoint> selected = new List<CodeCoverageSequencePoint>(); |
|
|
|
List<CodeCoverageSequencePoint> selected = new List<CodeCoverageSequencePoint>(); |
|
|
|
|
|
|
|
|
|
|
|
foreach (var point in sps) { |
|
|
|
foreach (var point in sps) { |
|
|
|
if ( |
|
|
|
if ( |
|
|
|
(point.Line > BodyStartSP.Line || (point.Line == BodyStartSP.Line && point.Column >= BodyStartSP.Column)) && |
|
|
|
(point.Line > BodyStartSP.Line || (point.Line == BodyStartSP.Line && point.Column >= BodyStartSP.Column)) && |
|
|
@ -150,20 +157,25 @@ namespace ICSharpCode.CodeCoverage |
|
|
|
// After ccrewrite ContractClass/ContractClassFor
|
|
|
|
// After ccrewrite ContractClass/ContractClassFor
|
|
|
|
// duplicate method end-sequence-point (}) is added
|
|
|
|
// duplicate method end-sequence-point (}) is added
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// Add (point) on first finalSP (duplicate)
|
|
|
|
// Add first finalSP (can be a duplicate)
|
|
|
|
// Note: IL.Offset of second duplicate finalSP will
|
|
|
|
// Note: IL.Offset of second duplicate finalSP will
|
|
|
|
// extend branch coverage outside method-end "}",
|
|
|
|
// extend branch coverage outside method-end "}",
|
|
|
|
// and that can lead to wrong branch coverage report!
|
|
|
|
// and that can lead to wrong branch coverage display!
|
|
|
|
if (object.ReferenceEquals (point, this.BodyFinalSP)) { |
|
|
|
if (object.ReferenceEquals (point, this.BodyFinalSP)) { |
|
|
|
selected.Add (point); |
|
|
|
selected.Add (point); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// SP's are originaly ordered by CIL offset
|
|
|
|
|
|
|
|
// but ccrewrite can move offset of
|
|
|
|
|
|
|
|
// Contract.Requires before method signature SP (xxx{) and
|
|
|
|
|
|
|
|
// Contract.Ensures after method closing SP (})
|
|
|
|
|
|
|
|
// So sort SP's back by line/column
|
|
|
|
selected.OrderBy(item => item.Line).OrderBy(item => item.Column); |
|
|
|
selected.OrderBy(item => item.Line).OrderBy(item => item.Column); |
|
|
|
sps = selected; |
|
|
|
returnList = selected; |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
return sps; |
|
|
|
|
|
|
|
|
|
|
|
return returnList; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
int GetSequencePointsCount() { |
|
|
|
int GetSequencePointsCount() { |
|
|
@ -245,10 +257,10 @@ namespace ICSharpCode.CodeCoverage |
|
|
|
|
|
|
|
|
|
|
|
// This sequence point offset is used to skip CCRewrite(n) BranchPoint's (Requires)
|
|
|
|
// This sequence point offset is used to skip CCRewrite(n) BranchPoint's (Requires)
|
|
|
|
// and '{' branches at static methods
|
|
|
|
// and '{' branches at static methods
|
|
|
|
if (this.BodyStartSP == null) { return null; } |
|
|
|
if (this.BodyStartSP == null) { return null; } // empty body
|
|
|
|
|
|
|
|
|
|
|
|
// This sequence point offset is used to skip CCRewrite(n) BranchPoint's (Ensures)
|
|
|
|
// This sequence point offset is used to skip CCRewrite(n) BranchPoint's (Ensures)
|
|
|
|
if (this.BodyFinalSP == null) { return null; } |
|
|
|
if (this.BodyFinalSP == null) { return null; } // empty body
|
|
|
|
|
|
|
|
|
|
|
|
// Connect Sequence & Branches
|
|
|
|
// Connect Sequence & Branches
|
|
|
|
IEnumerator<CodeCoverageSequencePoint> SPEnumerator = this.SequencePoints.GetEnumerator(); |
|
|
|
IEnumerator<CodeCoverageSequencePoint> SPEnumerator = this.SequencePoints.GetEnumerator(); |
|
|
|