Skip to content

Commit 98604d6

Browse files
committed
fix
1 parent 3aa23ec commit 98604d6

File tree

4 files changed

+1
-93
lines changed

4 files changed

+1
-93
lines changed

src/coverlet.core/Abstractions/ICecilSymbolHelper.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,5 @@ internal interface ICecilSymbolHelper
1212
{
1313
IReadOnlyList<BranchPoint> GetBranchPoints(MethodDefinition methodDefinition);
1414
bool SkipNotCoverableInstruction(MethodDefinition methodDefinition, Instruction instruction);
15-
bool SkipInlineAssignedAutoProperty(bool skipAutoProps, MethodDefinition methodDefinition, Instruction instruction);
1615
}
1716
}

src/coverlet.core/Instrumentation/Instrumenter.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -592,8 +592,7 @@ private void InstrumentIL(MethodDefinition method)
592592

593593
if (sequencePoint != null && !sequencePoint.IsHidden)
594594
{
595-
if (/*_cecilSymbolHelper.SkipInlineAssignedAutoProperty(_parameters.SkipAutoProps, method,
596-
currentInstruction) ||*/ IsInsideExcludedMethodSection(sequencePoint))
595+
if (IsInsideExcludedMethodSection(sequencePoint))
597596
{
598597
index++;
599598
continue;

src/coverlet.core/Symbols/CecilSymbolHelper.cs

Lines changed: 0 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1362,61 +1362,6 @@ private bool SkipExpressionBreakpointsSequences(MethodDefinition methodDefinitio
13621362
return false;
13631363
}
13641364

1365-
//public bool SkipInlineAssignedAutoProperty(bool skipAutoProps, MethodDefinition methodDefinition, Instruction instruction)
1366-
//{
1367-
// if (!skipAutoProps || !methodDefinition.IsConstructor) return false;
1368-
1369-
// return SkipGeneratedBackingFieldAssignment(methodDefinition, instruction) ||
1370-
// SkipDefaultInitializationSystemObject(instruction);
1371-
//}
1372-
1373-
//private static bool SkipGeneratedBackingFieldAssignment(MethodDefinition methodDefinition, Instruction instruction)
1374-
//{
1375-
// /*
1376-
// For inline initialization of properties the compiler generates a field that is set in the constructor of the class.
1377-
// To skip this we search for compiler generated fields that are set in the constructor.
1378-
1379-
// .field private string '<SurName>k__BackingField'
1380-
// .custom instance void [System.Runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = (
1381-
// 01 00 00 00
1382-
// )
1383-
1384-
// .method public hidebysig specialname rtspecialname
1385-
// instance void .ctor () cil managed
1386-
// {
1387-
// IL_0000: ldarg.0
1388-
// IL_0001: ldsfld string[System.Runtime] System.String::Empty
1389-
// IL_0006: stfld string TestRepro.ClassWithPropertyInit::'<SurName>k__BackingField'
1390-
// ...
1391-
// }
1392-
// ...
1393-
// */
1394-
// IEnumerable<FieldDefinition> autogeneratedBackingFields = methodDefinition.DeclaringType.Fields.Where(x =>
1395-
// x.CustomAttributes.Any(ca => ca.AttributeType.FullName.Equals(typeof(CompilerGeneratedAttribute).FullName)) &&
1396-
// x.FullName.EndsWith("k__BackingField"));
1397-
1398-
// return instruction.OpCode == OpCodes.Ldarg &&
1399-
// instruction.Next?.Next?.OpCode == OpCodes.Stfld &&
1400-
// instruction.Next?.Next?.Operand is FieldReference fr &&
1401-
// autogeneratedBackingFields.Select(x => x.FullName).Contains(fr.FullName);
1402-
//}
1403-
1404-
//private static bool SkipDefaultInitializationSystemObject(Instruction instruction)
1405-
//{
1406-
// /*
1407-
// A type always has a constructor with a default instantiation of System.Object. For record types these
1408-
// instructions can have a own sequence point. This means that even the default constructor would be instrumented.
1409-
// To skip this we search for call instructions with a method reference that declares System.Object.
1410-
1411-
// IL_0000: ldarg.0
1412-
// IL_0001: call instance void [System.Runtime]System.Object::.ctor()
1413-
// IL_0006: ret
1414-
// */
1415-
// return instruction.OpCode == OpCodes.Ldarg &&
1416-
// instruction.Next?.OpCode == OpCodes.Call &&
1417-
// instruction.Next?.Operand is MethodReference mr && mr.DeclaringType.FullName.Equals(typeof(System.Object).FullName);
1418-
//}
1419-
14201365
private static bool SkipBranchGeneratedExceptionFilter(Instruction branchInstruction, MethodDefinition methodDefinition)
14211366
{
14221367
if (!methodDefinition.Body.HasExceptionHandlers)

test/coverlet.core.coverage.tests/Samples/Instrumentation.AutoProps.cs

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -12,39 +12,4 @@ public AutoProps()
1212
public int AutoPropsNonInit { get; set; }
1313
public int AutoPropsInit { get; set; } = 10;
1414
}
15-
16-
//public record RecordWithPropertyInit
17-
//{
18-
// private int _myRecordVal = 0;
19-
// public RecordWithPropertyInit()
20-
// {
21-
// _myRecordVal = new Random().Next();
22-
// }
23-
// public string RecordAutoPropsNonInit { get; set; }
24-
// public string RecordAutoPropsInit { get; set; } = string.Empty;
25-
//}
26-
27-
//public class ClassWithRecordsAutoProperties
28-
//{
29-
// record RecordWithPrimaryConstructor(string Prop1, string Prop2);
30-
31-
// public ClassWithRecordsAutoProperties()
32-
// {
33-
// var record = new RecordWithPrimaryConstructor(string.Empty, string.Empty);
34-
// }
35-
//}
36-
37-
//public class ClassWithInheritingRecordsAndAutoProperties
38-
//{
39-
// record BaseRecord(int A);
40-
41-
// record InheritedRecord(int A) : BaseRecord(A);
42-
43-
// public ClassWithInheritingRecordsAndAutoProperties()
44-
// {
45-
// var record = new InheritedRecord(1);
46-
// }
47-
//}
48-
49-
5015
}

0 commit comments

Comments
 (0)