Skip to content

Commit 5c596ef

Browse files
resolve conflicts
1 parent f005da3 commit 5c596ef

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

src/coverlet.core/Coverage.cs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
using Coverlet.Core.Helpers;
77
using Coverlet.Core.Instrumentation;
8+
using Coverlet.Core.Symbols;
89

910
using Newtonsoft.Json;
1011

@@ -204,6 +205,31 @@ private void CalculateCoverage()
204205
}
205206
}
206207

208+
// for MoveNext() compiler autogenerated method we need to patch false positive (IAsyncStateMachine for instance)
209+
// we'll remove all MoveNext() not covered branch
210+
foreach (var document in result.Documents)
211+
{
212+
List<KeyValuePair<(int, int), Branch>> branchesToRemove = new List<KeyValuePair<(int, int), Branch>>();
213+
foreach (var branch in document.Value.Branches)
214+
{
215+
//if one branch is covered we search the other one only if it's not covered
216+
if (CecilSymbolHelper.IsMoveNext(branch.Value.Method) && branch.Value.Hits > 0)
217+
{
218+
foreach (var moveNextBranch in document.Value.Branches)
219+
{
220+
if (moveNextBranch.Value.Method == branch.Value.Method && moveNextBranch.Value != branch.Value && moveNextBranch.Value.Hits == 0)
221+
{
222+
branchesToRemove.Add(moveNextBranch);
223+
}
224+
}
225+
}
226+
}
227+
foreach (var branchToRemove in branchesToRemove)
228+
{
229+
document.Value.Branches.Remove(branchToRemove.Key);
230+
}
231+
}
232+
207233
InstrumentationHelper.DeleteHitsFile(result.HitsFilePath);
208234
}
209235
}

0 commit comments

Comments
 (0)