File tree Expand file tree Collapse file tree 2 files changed +21
-5
lines changed Expand file tree Collapse file tree 2 files changed +21
-5
lines changed Original file line number Diff line number Diff line change
1
+ using Coverlet . Core . Helpers ;
2
+ using Coverlet . Core . Instrumentation ;
3
+ using Coverlet . Core . Symbols ;
1
4
using System ;
2
5
using System . Collections . Generic ;
3
6
using System . IO ;
4
- using System . IO . Compression ;
5
7
using System . Linq ;
6
-
7
- using Coverlet . Core . Helpers ;
8
- using Coverlet . Core . Instrumentation ;
9
-
8
+
10
9
namespace Coverlet . Core
11
10
{
12
11
public class Coverage
@@ -183,6 +182,18 @@ private void CalculateCoverage()
183
182
{
184
183
int ordinal = int . Parse ( info [ 3 ] ) ;
185
184
var branch = document . Branches [ ( start , ordinal ) ] ;
185
+ // for MoveNext() compiler autogenerated method we need to patch false positive (IAsyncStateMachine for instance)
186
+ // the idea is force same hits on other branch
187
+ if ( CecilSymbolHelper . IsMoveNext ( branch . Method ) )
188
+ {
189
+ foreach ( var moveNextBranch in document . Branches )
190
+ {
191
+ if ( moveNextBranch . Value . Method == branch . Method && moveNextBranch . Value != branch )
192
+ {
193
+ moveNextBranch . Value . Hits += hits ;
194
+ }
195
+ }
196
+ }
186
197
branch . Hits += hits ;
187
198
}
188
199
else
Original file line number Diff line number Diff line change @@ -20,6 +20,11 @@ public static class CecilSymbolHelper
20
20
private const int StepOverLineCode = 0xFEEFEE ;
21
21
private static readonly Regex IsMovenext = new Regex ( @"\<[^\s>]+\>\w__\w(\w)?::MoveNext\(\)$" , RegexOptions . Compiled | RegexOptions . ExplicitCapture ) ;
22
22
23
+ public static bool IsMoveNext ( string fullName )
24
+ {
25
+ return IsMovenext . IsMatch ( fullName ) ;
26
+ }
27
+
23
28
public static List < BranchPoint > GetBranchPoints ( MethodDefinition methodDefinition )
24
29
{
25
30
var list = new List < BranchPoint > ( ) ;
You can’t perform that action at this time.
0 commit comments