@@ -183,19 +183,6 @@ private void CalculateCoverage()
183
183
int ordinal = int . Parse ( info [ 3 ] ) ;
184
184
var branch = document . Branches [ ( start , ordinal ) ] ;
185
185
branch . Hits += hits ;
186
-
187
- // for MoveNext() compiler autogenerated method we need to patch false positive (IAsyncStateMachine for instance)
188
- // the idea is force same hits on other branch
189
- if ( CecilSymbolHelper . IsMoveNext ( branch . Method ) )
190
- {
191
- foreach ( var moveNextBranch in document . Branches )
192
- {
193
- if ( moveNextBranch . Value . Method == branch . Method && moveNextBranch . Value != branch )
194
- {
195
- moveNextBranch . Value . Hits += hits ;
196
- }
197
- }
198
- }
199
186
}
200
187
else
201
188
{
@@ -209,6 +196,31 @@ private void CalculateCoverage()
209
196
}
210
197
}
211
198
199
+ // for MoveNext() compiler autogenerated method we need to patch false positive (IAsyncStateMachine for instance)
200
+ // we'll remove all MoveNext() not covered branch
201
+ foreach ( var document in result . Documents )
202
+ {
203
+ List < KeyValuePair < ( int , int ) , Branch > > branchesToRemove = new List < KeyValuePair < ( int , int ) , Branch > > ( ) ;
204
+ foreach ( var branch in document . Value . Branches )
205
+ {
206
+ //if one branch is covered we search the other one only if it's not covered
207
+ if ( CecilSymbolHelper . IsMoveNext ( branch . Value . Method ) && branch . Value . Hits > 0 )
208
+ {
209
+ foreach ( var moveNextBranch in document . Value . Branches )
210
+ {
211
+ if ( moveNextBranch . Value . Method == branch . Value . Method && moveNextBranch . Value != branch . Value && moveNextBranch . Value . Hits == 0 )
212
+ {
213
+ branchesToRemove . Add ( moveNextBranch ) ;
214
+ }
215
+ }
216
+ }
217
+ }
218
+ foreach ( var branchToRemove in branchesToRemove )
219
+ {
220
+ document . Value . Branches . Remove ( branchToRemove . Key ) ;
221
+ }
222
+ }
223
+
212
224
InstrumentationHelper . DeleteHitsFile ( result . HitsFilePath ) ;
213
225
}
214
226
}
0 commit comments