Skip to content

Commit 591edc2

Browse files
author
David Mueller x.
committed
cleanup refactoring
1 parent 3194986 commit 591edc2

File tree

3 files changed

+9
-15
lines changed

3 files changed

+9
-15
lines changed

src/coverlet.core/Symbols/CecilSymbolHelper.cs

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -553,11 +553,9 @@ static bool CheckForAsyncEnumerator(List<Instruction> instructions, Instruction
553553
(instructions[currentIndex - 2].OpCode == OpCodes.Ldarg ||
554554
instructions[currentIndex - 2].OpCode == OpCodes.Ldarg_0) &&
555555
instructions[currentIndex - 1].OpCode == OpCodes.Ldfld &&
556-
(
557-
(instructions[currentIndex - 1].Operand is FieldDefinition field && IsCompilerGenerated(field) && field.FieldType.FullName.StartsWith("System.Collections.Generic.IAsyncEnumerator")) ||
558-
(instructions[currentIndex - 1].Operand is FieldReference fieldRef && IsCompilerGenerated(fieldRef.Resolve()) && fieldRef.FieldType.FullName.StartsWith("System.Collections.Generic.IAsyncEnumerator"))
559-
)
560-
)
556+
IsCompilerGeneratedField(instructions[currentIndex - 1], out FieldDefinition field) &&
557+
field.FieldType.FullName.StartsWith("System.Collections.Generic.IAsyncEnumerator")
558+
)
561559
{
562560
return true;
563561
}
@@ -598,10 +596,8 @@ static bool CheckIfExceptionThrown(List<Instruction> instructions, Instruction i
598596
for (int i = currentIndex - 1; i >= minFieldIndex; --i)
599597
{
600598
if (instructions[i].OpCode == OpCodes.Ldfld &&
601-
(
602-
(instructions[i].Operand is FieldDefinition field && IsCompilerGenerated(field) && field.FieldType.FullName == "System.Object") ||
603-
(instructions[i].Operand is FieldReference fieldRef && IsCompilerGenerated(fieldRef.Resolve()) && fieldRef.FieldType.FullName == "System.Object")
604-
))
599+
IsCompilerGeneratedField(instructions[i], out FieldDefinition field) &&
600+
field.FieldType.FullName == "System.Object")
605601
{
606602
// We expect the call to GetResult() to be no more than four
607603
// instructions before the loading of the field's value.
@@ -932,10 +928,8 @@ static bool DisposeCheck(List<Instruction> instructions, Instruction instruction
932928

933929
if (currentIndex >= 2 &&
934930
instructions[currentIndex - 1].OpCode == OpCodes.Ldfld &&
935-
(
936-
(instructions[currentIndex - 1].Operand is FieldDefinition field && IsCompilerGenerated(field) && field.FullName.EndsWith("__disposeMode")) ||
937-
(instructions[currentIndex - 1].Operand is FieldReference fieldRef && IsCompilerGenerated(fieldRef.Resolve()) && fieldRef.FullName.EndsWith("__disposeMode"))
938-
) &&
931+
IsCompilerGeneratedField(instructions[currentIndex - 1], out FieldDefinition field) &&
932+
field.FullName.EndsWith("__disposeMode") &&
939933
(instructions[currentIndex - 2].OpCode == OpCodes.Ldarg ||
940934
instructions[currentIndex - 2].OpCode == OpCodes.Ldarg_0))
941935
{

test/coverlet.core.tests/Coverage/CoverageTests.AwaitUsing.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public void AwaitUsing()
1717
string path = Path.GetTempFileName();
1818
try
1919
{
20-
FunctionExecutor.RunInProcess(async (string[] pathSerialize) =>
20+
FunctionExecutor.Run(async (string[] pathSerialize) =>
2121
{
2222
CoveragePrepareResult coveragePrepareResult = await TestInstrumentationHelper.Run<AwaitUsing>(async instance =>
2323
{

test/coverlet.core.tests/Coverage/InstrumenterHelper.Assertions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public static CoverageResult GenerateReport(this CoverageResult coverageResult,
3030
{
3131
Process.Start("cmd", "/C " + Path.GetFullPath(Path.Combine(directory, "index.htm")));
3232
}
33-
Process.Start("cmd", "/C " + Path.GetFullPath(Path.Combine(directory, "index.htm")));
33+
3434
return coverageResult;
3535
}
3636

0 commit comments

Comments
 (0)