Browse Source

CodeCoverage Fix "in" keyword

pull/67/head
Dragan 12 years ago
parent
commit
55f9a6014c
  1. 8
      src/AddIns/Analysis/CodeCoverage/Project/Src/CodeCoverageMethodElement.cs

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

@ -214,15 +214,11 @@ namespace ICSharpCode.CodeCoverage
nextMatch = false; nextMatch = false;
excludeOffsetList.Add(new Tuple<int, int> ( previousSeqPoint.Offset , currentSeqPoint.Offset )); excludeOffsetList.Add(new Tuple<int, int> ( previousSeqPoint.Offset , currentSeqPoint.Offset ));
} }
// SequencePoints are ordered by offset and that order exposes reverse ordered lines
// ie: foreach ( var item in (IEnumerable)items ) code for "in" keyword is generated "out-of-sequence",
// with lower line number than previous line (reversed line order).
// Generated "in" code for IEnumerables contains hidden "try/catch/finally" branches that // 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)
if (currentSeqPoint.Line < previousSeqPoint.Line if (currentSeqPoint.Content == "in") {
&& currentSeqPoint.Content == "in" ) { // Content is equal to "in" keyword
// currentSeqPoint has lower line number than previousSeqPoint and content is equal to "in" keyword
nextMatch = true; nextMatch = true;
} }
previousSeqPoint = currentSeqPoint; previousSeqPoint = currentSeqPoint;

Loading…
Cancel
Save