From 7f254884e150b01fd8e343f0c89c6b23095f1193 Mon Sep 17 00:00:00 2001 From: Lucas Lara Date: Tue, 27 Oct 2020 23:31:57 +0100 Subject: [PATCH 1/3] Update .NET sdk --- global.json | 2 +- .../CommandLine/Options/ThresholdOption.cs | 8 +++++--- .../Instrumentation/AsyncMethod.cs | 18 ++++++++---------- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/global.json b/global.json index 70a59a3..9731311 100644 --- a/global.json +++ b/global.json @@ -1,5 +1,5 @@ { "sdk": { - "version": "3.1.201" + "version": "3.1.403" } } \ No newline at end of file diff --git a/src/MiniCover/CommandLine/Options/ThresholdOption.cs b/src/MiniCover/CommandLine/Options/ThresholdOption.cs index be81356..dc04c01 100644 --- a/src/MiniCover/CommandLine/Options/ThresholdOption.cs +++ b/src/MiniCover/CommandLine/Options/ThresholdOption.cs @@ -1,4 +1,6 @@ -namespace MiniCover.CommandLine.Options +using System.Globalization; + +namespace MiniCover.CommandLine.Options { class ThresholdOption : ISingleValueOption, IThresholdOption { @@ -10,7 +12,7 @@ class ThresholdOption : ISingleValueOption, IThresholdOption public void ReceiveValue(string value) { - if (!float.TryParse(value, out var threshold)) + if (!float.TryParse(value, NumberStyles.Any, CultureInfo.InvariantCulture, out var threshold)) { threshold = _defaultValue; } @@ -18,4 +20,4 @@ public void ReceiveValue(string value) Value = threshold / 100; } } -} \ No newline at end of file +} diff --git a/tests/MiniCover.UnitTests/Instrumentation/AsyncMethod.cs b/tests/MiniCover.UnitTests/Instrumentation/AsyncMethod.cs index a187c51..06f2a41 100644 --- a/tests/MiniCover.UnitTests/Instrumentation/AsyncMethod.cs +++ b/tests/MiniCover.UnitTests/Instrumentation/AsyncMethod.cs @@ -33,7 +33,7 @@ public override void FunctionalTest() { .method public System.Threading.Tasks.Task`1 Method { - .locals init (MiniCover.UnitTests.Instrumentation.AsyncMethod/Class/d__0 V_0, System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1 V_1) + .locals init (MiniCover.UnitTests.Instrumentation.AsyncMethod/Class/d__0 V_0) IL_0000: newobj System.Void MiniCover.UnitTests.Instrumentation.AsyncMethod/Class/d__0::.ctor() IL_0005: stloc.0 IL_0006: ldloc.0 @@ -46,15 +46,13 @@ .locals init (MiniCover.UnitTests.Instrumentation.AsyncMethod/Class/d__0 IL_0019: ldc.i4.m1 IL_001a: stfld System.Int32 MiniCover.UnitTests.Instrumentation.AsyncMethod/Class/d__0::<>1__state IL_001f: ldloc.0 - IL_0020: ldfld System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1 MiniCover.UnitTests.Instrumentation.AsyncMethod/Class/d__0::<>t__builder - IL_0025: stloc.1 - IL_0026: ldloca.s V_1 - IL_0028: ldloca.s V_0 - IL_002a: call System.Void System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1::Startd__0>(!!0&) - IL_002f: ldloc.0 - IL_0030: ldflda System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1 MiniCover.UnitTests.Instrumentation.AsyncMethod/Class/d__0::<>t__builder - IL_0035: call System.Threading.Tasks.Task`1 System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1::get_Task() - IL_003a: ret + IL_0020: ldflda System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1 MiniCover.UnitTests.Instrumentation.AsyncMethod/Class/d__0::<>t__builder + IL_0025: ldloca.s V_0 + IL_0027: call System.Void System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1::Startd__0>(!!0&) + IL_002c: ldloc.0 + IL_002d: ldflda System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1 MiniCover.UnitTests.Instrumentation.AsyncMethod/Class/d__0::<>t__builder + IL_0032: call System.Threading.Tasks.Task`1 System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1::get_Task() + IL_0037: ret } .method public System.Void .ctor { From 8344c5d7186872bad74136d044673377c578e067 Mon Sep 17 00:00:00 2001 From: Lucas Lara Date: Wed, 28 Oct 2020 00:04:26 +0100 Subject: [PATCH 2/3] Fix issue when hits are recorded after hits file is saved --- src/MiniCover.HitServices/HitContext.cs | 13 +++- src/MiniCover.HitServices/HitService.cs | 67 ++----------------- src/MiniCover.HitServices/MethodScope.cs | 58 ++++++++++++++++ .../Instrumentation/MethodInstrumenter.cs | 8 +-- .../Instrumentation/AsyncMethod.cs | 18 ++--- .../ConstructorGenericCallThis.cs | 10 +-- .../ConstructorWithCallBase.cs | 10 +-- .../ConstructorWithTryFinally.cs | 18 ++--- .../Instrumentation/EnumerableMethod.cs | 16 ++--- .../ExcludedFromCodeCoverageClass.cs | 6 +- .../ExcludedFromCodeCoverageMethod.cs | 6 +- .../Instrumentation/FieldInitialization.cs | 8 +-- .../Instrumentation/For.cs | 18 ++--- .../MiniCover.UnitTests/Instrumentation/If.cs | 12 ++-- .../Instrumentation/IfInline.cs | 12 ++-- .../Instrumentation/IfInlineNested.cs | 16 ++--- .../Instrumentation/IfWithAnd.cs | 16 ++--- .../Instrumentation/Lambda.cs | 16 ++--- .../MiniCover.UnitTests/Instrumentation/Or.cs | 8 +-- .../Instrumentation/OrWithEquals.cs | 12 ++-- .../Instrumentation/StaticMethod.cs | 8 +-- .../Instrumentation/Switch.cs | 16 ++--- .../Instrumentation/ThrowException.cs | 10 +-- .../Instrumentation/Using.cs | 12 ++-- 24 files changed, 202 insertions(+), 192 deletions(-) create mode 100644 src/MiniCover.HitServices/MethodScope.cs diff --git a/src/MiniCover.HitServices/HitContext.cs b/src/MiniCover.HitServices/HitContext.cs index a31b419..986b734 100644 --- a/src/MiniCover.HitServices/HitContext.cs +++ b/src/MiniCover.HitServices/HitContext.cs @@ -18,6 +18,8 @@ public static HitContext Current private readonly object _lock = new object(); + private int _refCount; + public HitContext( string assemblyName, string className, @@ -35,6 +37,15 @@ public static HitContext Current public string MethodName { get; } public IDictionary Hits { get; } + public int IncrementRef() + { + return Interlocked.Increment(ref _refCount); + } + public int DecrementRef() + { + return Interlocked.Decrement(ref _refCount); + } + public void RecordHit(int id) { lock (_lock) @@ -121,4 +132,4 @@ public static HitContext Read(BinaryReader binaryReader) return new HitContext(assemblyName, className, methodName, hits); } } -} \ No newline at end of file +} diff --git a/src/MiniCover.HitServices/HitService.cs b/src/MiniCover.HitServices/HitService.cs index 5d93c6c..b427ae4 100644 --- a/src/MiniCover.HitServices/HitService.cs +++ b/src/MiniCover.HitServices/HitService.cs @@ -1,73 +1,14 @@ -using System; -using System.Collections.Concurrent; -using System.IO; - -namespace MiniCover.HitServices +namespace MiniCover.HitServices { public static class HitService { - public static MethodContext EnterMethod( + public static MethodScope EnterMethod( string hitsPath, string assemblyName, string className, string methodName) { - return new MethodContext(hitsPath, assemblyName, className, methodName); - } - - public class MethodContext : IDisposable - { - private static ConcurrentDictionary _filesStream = new ConcurrentDictionary(); - - private readonly string _hitsPath; - private readonly HitContext _hitContext; - private readonly bool _saveHitContext; - - public MethodContext( - string hitsPath, - string assemblyName, - string className, - string methodName) - { - _hitsPath = hitsPath; - - if (HitContext.Current == null) - { - _hitContext = new HitContext(assemblyName, className, methodName); - HitContext.Current = _hitContext; - _saveHitContext = true; - } - else - { - _hitContext = HitContext.Current; - } - } - - public void Hit(int id) - { - _hitContext.RecordHit(id); - } - - public void Dispose() - { - if (_saveHitContext) - { - var fileStream = _filesStream.GetOrAdd(_hitsPath, CreateOutputFile); - lock (fileStream) - { - _hitContext.Serialize(fileStream); - fileStream.Flush(); - } - HitContext.Current = null; - } - } - - private static FileStream CreateOutputFile(string hitsPath) - { - Directory.CreateDirectory(hitsPath); - var filePath = Path.Combine(hitsPath, $"{Guid.NewGuid()}.hits"); - return File.Open(filePath, FileMode.CreateNew); - } + return new MethodScope(hitsPath, assemblyName, className, methodName); } } -} \ No newline at end of file +} diff --git a/src/MiniCover.HitServices/MethodScope.cs b/src/MiniCover.HitServices/MethodScope.cs new file mode 100644 index 0000000..440f65f --- /dev/null +++ b/src/MiniCover.HitServices/MethodScope.cs @@ -0,0 +1,58 @@ +using System; +using System.IO; + +namespace MiniCover.HitServices +{ + public class MethodScope : IDisposable + { + private readonly HitContext _hitContext; + private readonly string _hitsPath; + private readonly bool _createdHitContext; + + public MethodScope( + string hitsPath, + string assemblyName, + string className, + string methodName) + { + _hitContext = HitContext.Current; + + if (_hitContext == null) + { + _hitContext = new HitContext(assemblyName, className, methodName); + _createdHitContext = true; + HitContext.Current = _hitContext; + } + + _hitsPath = hitsPath; + _hitContext.IncrementRef(); + } + + public void Hit(int id) + { + _hitContext.RecordHit(id); + } + + public void Dispose() + { + if (_hitContext.DecrementRef() == 0) + SaveHitContext(); + + if (_createdHitContext) + HitContext.Current = null; + } + + private void SaveHitContext() + { + Directory.CreateDirectory(_hitsPath); + + var fileName = Path.Combine(_hitsPath, $"{Guid.NewGuid()}.hits"); + + using (var fileStream = File.Open(fileName, FileMode.OpenOrCreate)) + { + _hitContext.Serialize(fileStream); + fileStream.Flush(); + } + } + } +} diff --git a/src/MiniCover/Instrumentation/MethodInstrumenter.cs b/src/MiniCover/Instrumentation/MethodInstrumenter.cs index 9e5bcee..7c7425b 100644 --- a/src/MiniCover/Instrumentation/MethodInstrumenter.cs +++ b/src/MiniCover/Instrumentation/MethodInstrumenter.cs @@ -18,10 +18,10 @@ namespace MiniCover.Instrumentation public class MethodInstrumenter { private static readonly Type hitServiceType = typeof(HitService); - private static readonly Type methodContextType = typeof(HitService.MethodContext); - private static readonly MethodInfo hitMethodInfo = methodContextType.GetMethod(nameof(HitService.MethodContext.Hit)); + private static readonly Type methodScopeType = typeof(MethodScope); + private static readonly MethodInfo hitMethodInfo = methodScopeType.GetMethod(nameof(MethodScope.Hit)); private static readonly MethodInfo enterMethodInfo = hitServiceType.GetMethod(nameof(HitService.EnterMethod)); - private static readonly MethodInfo disposeMethodInfo = methodContextType.GetMethod(nameof(IDisposable.Dispose)); + private static readonly MethodInfo disposeMethodInfo = methodScopeType.GetMethod(nameof(IDisposable.Dispose)); private readonly ILogger _logger; private readonly IFileReader _fileReader; @@ -49,7 +49,7 @@ public class MethodInstrumenter FullName = originalMethod.FullName, }); - var methodContextClassReference = methodDefinition.Module.GetOrImportReference(methodContextType); + var methodContextClassReference = methodDefinition.Module.GetOrImportReference(methodScopeType); var enterMethodReference = methodDefinition.Module.GetOrImportReference(enterMethodInfo); var disposeMethodReference = methodDefinition.Module.GetOrImportReference(disposeMethodInfo); diff --git a/tests/MiniCover.UnitTests/Instrumentation/AsyncMethod.cs b/tests/MiniCover.UnitTests/Instrumentation/AsyncMethod.cs index 06f2a41..c9f61a8 100644 --- a/tests/MiniCover.UnitTests/Instrumentation/AsyncMethod.cs +++ b/tests/MiniCover.UnitTests/Instrumentation/AsyncMethod.cs @@ -74,12 +74,12 @@ .locals init (MiniCover.UnitTests.Instrumentation.AsyncMethod/Class/d__0 } .method System.Void MoveNext { - .locals init (System.Int32 V_0, System.Int32 V_1, System.Runtime.CompilerServices.TaskAwaiter V_2, MiniCover.UnitTests.Instrumentation.AsyncMethod/Class/d__0 V_3, System.Int32 V_4, System.Runtime.CompilerServices.TaskAwaiter V_5, System.Exception V_6, MiniCover.HitServices.HitService/MethodContext V_7) + .locals init (System.Int32 V_0, System.Int32 V_1, System.Runtime.CompilerServices.TaskAwaiter V_2, MiniCover.UnitTests.Instrumentation.AsyncMethod/Class/d__0 V_3, System.Int32 V_4, System.Runtime.CompilerServices.TaskAwaiter V_5, System.Exception V_6, MiniCover.HitServices.MethodScope V_7) IL_0000: ldstr ""/tmp"" IL_0005: ldstr ""MiniCover.UnitTests"" IL_000a: ldstr ""MiniCover.UnitTests.Instrumentation.AsyncMethod/Class"" IL_000f: ldstr ""Method"" - IL_0014: call MiniCover.HitServices.HitService/MethodContext MiniCover.HitServices.HitService::EnterMethod(System.String,System.String,System.String,System.String) + IL_0014: call MiniCover.HitServices.MethodScope MiniCover.HitServices.HitService::EnterMethod(System.String,System.String,System.String,System.String) IL_0019: stloc.s V_7 IL_001b: nop .try @@ -101,13 +101,13 @@ .locals init (System.Int32 V_0, System.Int32 V_1, System.Runtime.CompilerService IL_0035: nop IL_0036: ldloc.s V_7 IL_0038: ldc.i4.1 - IL_0039: callvirt System.Void MiniCover.HitServices.HitService/MethodContext::Hit(System.Int32) + IL_0039: callvirt System.Void MiniCover.HitServices.MethodScope::Hit(System.Int32) IL_003e: ldarg.0 // this IL_003f: ldc.i4.0 IL_0040: stfld System.Int32 MiniCover.UnitTests.Instrumentation.AsyncMethod/Class/d__0::5__1 IL_0045: ldloc.s V_7 IL_0047: ldc.i4.2 - IL_0048: callvirt System.Void MiniCover.HitServices.HitService/MethodContext::Hit(System.Int32) + IL_0048: callvirt System.Void MiniCover.HitServices.MethodScope::Hit(System.Int32) IL_004d: ldc.i4.5 IL_004e: call System.Threading.Tasks.Task System.Threading.Tasks.Task::Delay(System.Int32) IL_0053: callvirt System.Runtime.CompilerServices.TaskAwaiter System.Threading.Tasks.Task::GetAwaiter() @@ -148,7 +148,7 @@ .locals init (System.Int32 V_0, System.Int32 V_1, System.Runtime.CompilerService IL_00ac: nop IL_00ad: ldloc.s V_7 IL_00af: ldc.i4.3 - IL_00b0: callvirt System.Void MiniCover.HitServices.HitService/MethodContext::Hit(System.Int32) + IL_00b0: callvirt System.Void MiniCover.HitServices.MethodScope::Hit(System.Int32) IL_00b5: ldarg.0 // this IL_00b6: ldfld System.Int32 MiniCover.UnitTests.Instrumentation.AsyncMethod/Class/d__0::5__1 IL_00bb: stloc.s V_4 @@ -159,7 +159,7 @@ .locals init (System.Int32 V_0, System.Int32 V_1, System.Runtime.CompilerService IL_00c2: stfld System.Int32 MiniCover.UnitTests.Instrumentation.AsyncMethod/Class/d__0::5__1 IL_00c7: ldloc.s V_7 IL_00c9: ldc.i4.4 - IL_00ca: callvirt System.Void MiniCover.HitServices.HitService/MethodContext::Hit(System.Int32) + IL_00ca: callvirt System.Void MiniCover.HitServices.MethodScope::Hit(System.Int32) IL_00cf: ldc.i4.5 IL_00d0: call System.Threading.Tasks.Task System.Threading.Tasks.Task::Delay(System.Int32) IL_00d5: callvirt System.Runtime.CompilerServices.TaskAwaiter System.Threading.Tasks.Task::GetAwaiter() @@ -200,7 +200,7 @@ .locals init (System.Int32 V_0, System.Int32 V_1, System.Runtime.CompilerService IL_0131: nop IL_0132: ldloc.s V_7 IL_0134: ldc.i4.5 - IL_0135: callvirt System.Void MiniCover.HitServices.HitService/MethodContext::Hit(System.Int32) + IL_0135: callvirt System.Void MiniCover.HitServices.MethodScope::Hit(System.Int32) IL_013a: ldarg.0 // this IL_013b: ldfld System.Int32 MiniCover.UnitTests.Instrumentation.AsyncMethod/Class/d__0::5__1 IL_0140: stloc.s V_4 @@ -211,7 +211,7 @@ .locals init (System.Int32 V_0, System.Int32 V_1, System.Runtime.CompilerService IL_0147: stfld System.Int32 MiniCover.UnitTests.Instrumentation.AsyncMethod/Class/d__0::5__1 IL_014c: ldloc.s V_7 IL_014e: ldc.i4.6 - IL_014f: callvirt System.Void MiniCover.HitServices.HitService/MethodContext::Hit(System.Int32) + IL_014f: callvirt System.Void MiniCover.HitServices.MethodScope::Hit(System.Int32) IL_0154: ldarg.0 // this IL_0155: ldfld System.Int32 MiniCover.UnitTests.Instrumentation.AsyncMethod/Class/d__0::5__1 IL_015a: stloc.1 @@ -244,7 +244,7 @@ .locals init (System.Int32 V_0, System.Int32 V_1, System.Runtime.CompilerService { IL_018e: nop IL_018f: ldloc.s V_7 - IL_0191: callvirt System.Void MiniCover.HitServices.HitService/MethodContext::Dispose() + IL_0191: callvirt System.Void MiniCover.HitServices.MethodScope::Dispose() IL_0196: endfinally } IL_0197: ret diff --git a/tests/MiniCover.UnitTests/Instrumentation/ConstructorGenericCallThis.cs b/tests/MiniCover.UnitTests/Instrumentation/ConstructorGenericCallThis.cs index 194b92c..d4cbe4d 100644 --- a/tests/MiniCover.UnitTests/Instrumentation/ConstructorGenericCallThis.cs +++ b/tests/MiniCover.UnitTests/Instrumentation/ConstructorGenericCallThis.cs @@ -34,19 +34,19 @@ public override void FunctionalTest() result.Other.Should().BeTrue(); } - public override string ExpectedIL => @".locals init (MiniCover.HitServices.HitService/MethodContext V_0) + public override string ExpectedIL => @".locals init (MiniCover.HitServices.MethodScope V_0) IL_0000: ldstr ""/tmp"" IL_0005: ldstr ""MiniCover.UnitTests"" IL_000a: ldstr ""MiniCover.UnitTests.Instrumentation.ConstructorGenericCallThis/Class`1"" IL_000f: ldstr "".ctor"" -IL_0014: call MiniCover.HitServices.HitService/MethodContext MiniCover.HitServices.HitService::EnterMethod(System.String,System.String,System.String,System.String) +IL_0014: call MiniCover.HitServices.MethodScope MiniCover.HitServices.HitService::EnterMethod(System.String,System.String,System.String,System.String) IL_0019: stloc.0 IL_001a: nop .try { IL_001b: ldloc.0 IL_001c: ldc.i4.1 - IL_001d: callvirt System.Void MiniCover.HitServices.HitService/MethodContext::Hit(System.Int32) + IL_001d: callvirt System.Void MiniCover.HitServices.MethodScope::Hit(System.Int32) IL_0022: ldarg.0 // this IL_0023: ldarg.1 IL_0024: ldc.i4.1 @@ -59,7 +59,7 @@ public override void FunctionalTest() { IL_002e: nop IL_002f: ldloc.0 - IL_0030: callvirt System.Void MiniCover.HitServices.HitService/MethodContext::Dispose() + IL_0030: callvirt System.Void MiniCover.HitServices.MethodScope::Dispose() IL_0035: endfinally } IL_0036: ret @@ -70,4 +70,4 @@ public override void FunctionalTest() [1] = 1 }; } -} \ No newline at end of file +} diff --git a/tests/MiniCover.UnitTests/Instrumentation/ConstructorWithCallBase.cs b/tests/MiniCover.UnitTests/Instrumentation/ConstructorWithCallBase.cs index 96fb604..f0e5ac0 100644 --- a/tests/MiniCover.UnitTests/Instrumentation/ConstructorWithCallBase.cs +++ b/tests/MiniCover.UnitTests/Instrumentation/ConstructorWithCallBase.cs @@ -37,19 +37,19 @@ public override void FunctionalTest() result.BaseWasCalled.Should().BeTrue(); } - public override string ExpectedIL => @".locals init (MiniCover.HitServices.HitService/MethodContext V_0) + public override string ExpectedIL => @".locals init (MiniCover.HitServices.MethodScope V_0) IL_0000: ldstr ""/tmp"" IL_0005: ldstr ""MiniCover.UnitTests"" IL_000a: ldstr ""MiniCover.UnitTests.Instrumentation.ConstructorWithCallBase/Class"" IL_000f: ldstr "".ctor"" -IL_0014: call MiniCover.HitServices.HitService/MethodContext MiniCover.HitServices.HitService::EnterMethod(System.String,System.String,System.String,System.String) +IL_0014: call MiniCover.HitServices.MethodScope MiniCover.HitServices.HitService::EnterMethod(System.String,System.String,System.String,System.String) IL_0019: stloc.0 IL_001a: nop .try { IL_001b: ldloc.0 IL_001c: ldc.i4.1 - IL_001d: callvirt System.Void MiniCover.HitServices.HitService/MethodContext::Hit(System.Int32) + IL_001d: callvirt System.Void MiniCover.HitServices.MethodScope::Hit(System.Int32) IL_0022: ldarg.0 // this IL_0023: ldarg.1 IL_0024: call System.Void MiniCover.UnitTests.Instrumentation.ConstructorWithCallBase/BaseClass::.ctor(System.Int32) @@ -57,7 +57,7 @@ public override void FunctionalTest() IL_002a: nop IL_002b: ldloc.0 IL_002c: ldc.i4.2 - IL_002d: callvirt System.Void MiniCover.HitServices.HitService/MethodContext::Hit(System.Int32) + IL_002d: callvirt System.Void MiniCover.HitServices.MethodScope::Hit(System.Int32) IL_0032: ldarg.0 // this IL_0033: ldc.i4.1 IL_0034: stfld System.Boolean MiniCover.UnitTests.Instrumentation.ConstructorWithCallBase/Class::WasCalled @@ -67,7 +67,7 @@ public override void FunctionalTest() { IL_003b: nop IL_003c: ldloc.0 - IL_003d: callvirt System.Void MiniCover.HitServices.HitService/MethodContext::Dispose() + IL_003d: callvirt System.Void MiniCover.HitServices.MethodScope::Dispose() IL_0042: endfinally } IL_0043: ret diff --git a/tests/MiniCover.UnitTests/Instrumentation/ConstructorWithTryFinally.cs b/tests/MiniCover.UnitTests/Instrumentation/ConstructorWithTryFinally.cs index 98b173f..cdcc3ab 100644 --- a/tests/MiniCover.UnitTests/Instrumentation/ConstructorWithTryFinally.cs +++ b/tests/MiniCover.UnitTests/Instrumentation/ConstructorWithTryFinally.cs @@ -43,19 +43,19 @@ public override void FunctionalTest() result.FinallyWasCalled.Should().BeTrue(); } - public override string ExpectedIL => @".locals init (MiniCover.HitServices.HitService/MethodContext V_0) + public override string ExpectedIL => @".locals init (MiniCover.HitServices.MethodScope V_0) IL_0000: ldstr ""/tmp"" IL_0005: ldstr ""MiniCover.UnitTests"" IL_000a: ldstr ""MiniCover.UnitTests.Instrumentation.ConstructorWithExistingTryFinally/Class"" IL_000f: ldstr "".ctor"" -IL_0014: call MiniCover.HitServices.HitService/MethodContext MiniCover.HitServices.HitService::EnterMethod(System.String,System.String,System.String,System.String) +IL_0014: call MiniCover.HitServices.MethodScope MiniCover.HitServices.HitService::EnterMethod(System.String,System.String,System.String,System.String) IL_0019: stloc.0 IL_001a: nop .try { IL_001b: ldloc.0 IL_001c: ldc.i4.1 - IL_001d: callvirt System.Void MiniCover.HitServices.HitService/MethodContext::Hit(System.Int32) + IL_001d: callvirt System.Void MiniCover.HitServices.MethodScope::Hit(System.Int32) IL_0022: ldarg.0 // this IL_0023: call System.Void System.Object::.ctor() IL_0028: nop @@ -67,13 +67,13 @@ public override void FunctionalTest() IL_002a: nop IL_002b: ldloc.0 IL_002c: ldc.i4.2 - IL_002d: callvirt System.Void MiniCover.HitServices.HitService/MethodContext::Hit(System.Int32) + IL_002d: callvirt System.Void MiniCover.HitServices.MethodScope::Hit(System.Int32) IL_0032: ldarg.0 // this IL_0033: ldc.i4.1 IL_0034: stfld System.Boolean MiniCover.UnitTests.Instrumentation.ConstructorWithExistingTryFinally/Class::TryWasCalled IL_0039: ldloc.0 IL_003a: ldc.i4.3 - IL_003b: callvirt System.Void MiniCover.HitServices.HitService/MethodContext::Hit(System.Int32) + IL_003b: callvirt System.Void MiniCover.HitServices.MethodScope::Hit(System.Int32) IL_0040: ldstr ""Test"" IL_0045: newobj System.Void System.Exception::.ctor(System.String) IL_004a: throw @@ -82,12 +82,12 @@ public override void FunctionalTest() { IL_004b: ldloc.0 IL_004c: ldc.i4.4 - IL_004d: callvirt System.Void MiniCover.HitServices.HitService/MethodContext::Hit(System.Int32) + IL_004d: callvirt System.Void MiniCover.HitServices.MethodScope::Hit(System.Int32) IL_0052: pop IL_0053: nop IL_0054: ldloc.0 IL_0055: ldc.i4.5 - IL_0056: callvirt System.Void MiniCover.HitServices.HitService/MethodContext::Hit(System.Int32) + IL_0056: callvirt System.Void MiniCover.HitServices.MethodScope::Hit(System.Int32) IL_005b: ldarg.0 // this IL_005c: ldc.i4.1 IL_005d: stfld System.Boolean MiniCover.UnitTests.Instrumentation.ConstructorWithExistingTryFinally/Class::CatchWasCalled @@ -101,7 +101,7 @@ public override void FunctionalTest() IL_0067: nop IL_0068: ldloc.0 IL_0069: ldc.i4.6 - IL_006a: callvirt System.Void MiniCover.HitServices.HitService/MethodContext::Hit(System.Int32) + IL_006a: callvirt System.Void MiniCover.HitServices.MethodScope::Hit(System.Int32) IL_006f: ldarg.0 // this IL_0070: ldc.i4.1 IL_0071: stfld System.Boolean MiniCover.UnitTests.Instrumentation.ConstructorWithExistingTryFinally/Class::FinallyWasCalled @@ -114,7 +114,7 @@ public override void FunctionalTest() { IL_007a: nop IL_007b: ldloc.0 - IL_007c: callvirt System.Void MiniCover.HitServices.HitService/MethodContext::Dispose() + IL_007c: callvirt System.Void MiniCover.HitServices.MethodScope::Dispose() IL_0081: endfinally } IL_0082: ret diff --git a/tests/MiniCover.UnitTests/Instrumentation/EnumerableMethod.cs b/tests/MiniCover.UnitTests/Instrumentation/EnumerableMethod.cs index dad0cfd..a4430b6 100644 --- a/tests/MiniCover.UnitTests/Instrumentation/EnumerableMethod.cs +++ b/tests/MiniCover.UnitTests/Instrumentation/EnumerableMethod.cs @@ -73,12 +73,12 @@ public override void FunctionalTest() } .method System.Boolean MoveNext { - .locals init (System.Int32 V_0, System.Int32 V_1, System.Boolean V_2, MiniCover.HitServices.HitService/MethodContext V_3, System.Boolean V_4) + .locals init (System.Int32 V_0, System.Int32 V_1, System.Boolean V_2, MiniCover.HitServices.MethodScope V_3, System.Boolean V_4) IL_0000: ldstr ""/tmp"" IL_0005: ldstr ""MiniCover.UnitTests"" IL_000a: ldstr ""MiniCover.UnitTests.Instrumentation.EnumerableMethod/Class"" IL_000f: ldstr ""Method"" - IL_0014: call MiniCover.HitServices.HitService/MethodContext MiniCover.HitServices.HitService::EnterMethod(System.String,System.String,System.String,System.String) + IL_0014: call MiniCover.HitServices.MethodScope MiniCover.HitServices.HitService::EnterMethod(System.String,System.String,System.String,System.String) IL_0019: stloc.3 IL_001a: nop .try @@ -104,14 +104,14 @@ .locals init (System.Int32 V_0, System.Int32 V_1, System.Boolean V_2, MiniCover. IL_0040: nop IL_0041: ldloc.3 IL_0042: ldc.i4.1 - IL_0043: callvirt System.Void MiniCover.HitServices.HitService/MethodContext::Hit(System.Int32) + IL_0043: callvirt System.Void MiniCover.HitServices.MethodScope::Hit(System.Int32) IL_0048: ldarg.0 // this IL_0049: ldc.i4.0 IL_004a: stfld System.Int32 MiniCover.UnitTests.Instrumentation.EnumerableMethod/Class/d__0::5__1 IL_004f: br.s IL_008e IL_0051: ldloc.3 IL_0052: ldc.i4.2 - IL_0053: callvirt System.Void MiniCover.HitServices.HitService/MethodContext::Hit(System.Int32) + IL_0053: callvirt System.Void MiniCover.HitServices.MethodScope::Hit(System.Int32) IL_0058: ldarg.0 // this IL_0059: ldarg.0 // this IL_005a: ldfld System.Int32 MiniCover.UnitTests.Instrumentation.EnumerableMethod/Class/d__0::5__1 @@ -127,7 +127,7 @@ .locals init (System.Int32 V_0, System.Int32 V_1, System.Boolean V_2, MiniCover. IL_0072: stfld System.Int32 MiniCover.UnitTests.Instrumentation.EnumerableMethod/Class/d__0::<>1__state IL_0077: ldloc.3 IL_0078: ldc.i4.3 - IL_0079: callvirt System.Void MiniCover.HitServices.HitService/MethodContext::Hit(System.Int32) + IL_0079: callvirt System.Void MiniCover.HitServices.MethodScope::Hit(System.Int32) IL_007e: ldarg.0 // this IL_007f: ldfld System.Int32 MiniCover.UnitTests.Instrumentation.EnumerableMethod/Class/d__0::5__1 IL_0084: stloc.1 @@ -138,7 +138,7 @@ .locals init (System.Int32 V_0, System.Int32 V_1, System.Boolean V_2, MiniCover. IL_0089: stfld System.Int32 MiniCover.UnitTests.Instrumentation.EnumerableMethod/Class/d__0::5__1 IL_008e: ldloc.3 IL_008f: ldc.i4.4 - IL_0090: callvirt System.Void MiniCover.HitServices.HitService/MethodContext::Hit(System.Int32) + IL_0090: callvirt System.Void MiniCover.HitServices.MethodScope::Hit(System.Int32) IL_0095: ldarg.0 // this IL_0096: ldfld System.Int32 MiniCover.UnitTests.Instrumentation.EnumerableMethod/Class/d__0::5__1 IL_009b: ldarg.0 // this @@ -149,7 +149,7 @@ .locals init (System.Int32 V_0, System.Int32 V_1, System.Boolean V_2, MiniCover. IL_00a5: brtrue.s IL_0051 IL_00a7: ldloc.3 IL_00a8: ldc.i4.5 - IL_00a9: callvirt System.Void MiniCover.HitServices.HitService/MethodContext::Hit(System.Int32) + IL_00a9: callvirt System.Void MiniCover.HitServices.MethodScope::Hit(System.Int32) IL_00ae: ldc.i4.0 IL_00af: stloc.s V_4 IL_00b1: leave.s IL_00bb @@ -158,7 +158,7 @@ .locals init (System.Int32 V_0, System.Int32 V_1, System.Boolean V_2, MiniCover. { IL_00b3: nop IL_00b4: ldloc.3 - IL_00b5: callvirt System.Void MiniCover.HitServices.HitService/MethodContext::Dispose() + IL_00b5: callvirt System.Void MiniCover.HitServices.MethodScope::Dispose() IL_00ba: endfinally } IL_00bb: ldloc.s V_4 diff --git a/tests/MiniCover.UnitTests/Instrumentation/ExcludedFromCodeCoverageClass.cs b/tests/MiniCover.UnitTests/Instrumentation/ExcludedFromCodeCoverageClass.cs index 0ec4403..b46539f 100644 --- a/tests/MiniCover.UnitTests/Instrumentation/ExcludedFromCodeCoverageClass.cs +++ b/tests/MiniCover.UnitTests/Instrumentation/ExcludedFromCodeCoverageClass.cs @@ -25,12 +25,12 @@ public override void FunctionalTest() new Class().Method(5).Should().Be(10); } - public override string ExpectedIL => @".locals init (System.Int32 V_0, MiniCover.HitServices.HitService/MethodContext V_1, System.Int32 V_2) + public override string ExpectedIL => @".locals init (System.Int32 V_0, MiniCover.HitServices.MethodScope V_1, System.Int32 V_2) IL_0000: ldstr ""/tmp"" IL_0005: ldstr ""MiniCover.UnitTests"" IL_000a: ldstr ""MiniCover.UnitTests.Instrumentation.ExcludedFromCodeCoverageClass/Class"" IL_000f: ldstr ""Method"" -IL_0014: call MiniCover.HitServices.HitService/MethodContext MiniCover.HitServices.HitService::EnterMethod(System.String,System.String,System.String,System.String) +IL_0014: call MiniCover.HitServices.MethodScope MiniCover.HitServices.HitService::EnterMethod(System.String,System.String,System.String,System.String) IL_0019: stloc.1 IL_001a: nop .try @@ -49,7 +49,7 @@ public override void FunctionalTest() { IL_0026: nop IL_0027: ldloc.1 - IL_0028: callvirt System.Void MiniCover.HitServices.HitService/MethodContext::Dispose() + IL_0028: callvirt System.Void MiniCover.HitServices.MethodScope::Dispose() IL_002d: endfinally } IL_002e: ldloc.2 diff --git a/tests/MiniCover.UnitTests/Instrumentation/ExcludedFromCodeCoverageMethod.cs b/tests/MiniCover.UnitTests/Instrumentation/ExcludedFromCodeCoverageMethod.cs index 3356229..d24613a 100644 --- a/tests/MiniCover.UnitTests/Instrumentation/ExcludedFromCodeCoverageMethod.cs +++ b/tests/MiniCover.UnitTests/Instrumentation/ExcludedFromCodeCoverageMethod.cs @@ -25,12 +25,12 @@ public override void FunctionalTest() new Class().Method(5).Should().Be(10); } - public override string ExpectedIL => @".locals init (System.Int32 V_0, MiniCover.HitServices.HitService/MethodContext V_1, System.Int32 V_2) + public override string ExpectedIL => @".locals init (System.Int32 V_0, MiniCover.HitServices.MethodScope V_1, System.Int32 V_2) IL_0000: ldstr ""/tmp"" IL_0005: ldstr ""MiniCover.UnitTests"" IL_000a: ldstr ""MiniCover.UnitTests.Instrumentation.ExcludedFromCodeCoverageMethod/Class"" IL_000f: ldstr ""Method"" -IL_0014: call MiniCover.HitServices.HitService/MethodContext MiniCover.HitServices.HitService::EnterMethod(System.String,System.String,System.String,System.String) +IL_0014: call MiniCover.HitServices.MethodScope MiniCover.HitServices.HitService::EnterMethod(System.String,System.String,System.String,System.String) IL_0019: stloc.1 IL_001a: nop .try @@ -49,7 +49,7 @@ public override void FunctionalTest() { IL_0026: nop IL_0027: ldloc.1 - IL_0028: callvirt System.Void MiniCover.HitServices.HitService/MethodContext::Dispose() + IL_0028: callvirt System.Void MiniCover.HitServices.MethodScope::Dispose() IL_002d: endfinally } IL_002e: ldloc.2 diff --git a/tests/MiniCover.UnitTests/Instrumentation/FieldInitialization.cs b/tests/MiniCover.UnitTests/Instrumentation/FieldInitialization.cs index 61e2129..c9771c5 100644 --- a/tests/MiniCover.UnitTests/Instrumentation/FieldInitialization.cs +++ b/tests/MiniCover.UnitTests/Instrumentation/FieldInitialization.cs @@ -21,19 +21,19 @@ public override void FunctionalTest() result.Value.Should().Be(5); } - public override string ExpectedIL => @".locals init (MiniCover.HitServices.HitService/MethodContext V_0) + public override string ExpectedIL => @".locals init (MiniCover.HitServices.MethodScope V_0) IL_0000: ldstr ""/tmp"" IL_0005: ldstr ""MiniCover.UnitTests"" IL_000a: ldstr ""MiniCover.UnitTests.Instrumentation.FieldInitialization/Class"" IL_000f: ldstr "".ctor"" -IL_0014: call MiniCover.HitServices.HitService/MethodContext MiniCover.HitServices.HitService::EnterMethod(System.String,System.String,System.String,System.String) +IL_0014: call MiniCover.HitServices.MethodScope MiniCover.HitServices.HitService::EnterMethod(System.String,System.String,System.String,System.String) IL_0019: stloc.0 IL_001a: nop .try { IL_001b: ldloc.0 IL_001c: ldc.i4.1 - IL_001d: callvirt System.Void MiniCover.HitServices.HitService/MethodContext::Hit(System.Int32) + IL_001d: callvirt System.Void MiniCover.HitServices.MethodScope::Hit(System.Int32) IL_0022: ldarg.0 // this IL_0023: ldc.i4.5 IL_0024: stfld System.Int32 MiniCover.UnitTests.Instrumentation.FieldInitialization/Class::Value @@ -46,7 +46,7 @@ public override void FunctionalTest() { IL_0032: nop IL_0033: ldloc.0 - IL_0034: callvirt System.Void MiniCover.HitServices.HitService/MethodContext::Dispose() + IL_0034: callvirt System.Void MiniCover.HitServices.MethodScope::Dispose() IL_0039: endfinally } IL_003a: ret diff --git a/tests/MiniCover.UnitTests/Instrumentation/For.cs b/tests/MiniCover.UnitTests/Instrumentation/For.cs index 11ad559..a6dc48c 100644 --- a/tests/MiniCover.UnitTests/Instrumentation/For.cs +++ b/tests/MiniCover.UnitTests/Instrumentation/For.cs @@ -26,12 +26,12 @@ public override void FunctionalTest() new Class().Method(5).Should().Be(5 + 4 + 3 + 2 + 1); } - public override string ExpectedIL => @".locals init (System.Int32 result, System.Int32 i, System.Boolean V_2, System.Int32 V_3, MiniCover.HitServices.HitService/MethodContext V_4, System.Int32 V_5) + public override string ExpectedIL => @".locals init (System.Int32 result, System.Int32 i, System.Boolean V_2, System.Int32 V_3, MiniCover.HitServices.MethodScope V_4, System.Int32 V_5) IL_0000: ldstr ""/tmp"" IL_0005: ldstr ""MiniCover.UnitTests"" IL_000a: ldstr ""MiniCover.UnitTests.Instrumentation.For/Class"" IL_000f: ldstr ""Method"" -IL_0014: call MiniCover.HitServices.HitService/MethodContext MiniCover.HitServices.HitService::EnterMethod(System.String,System.String,System.String,System.String) +IL_0014: call MiniCover.HitServices.MethodScope MiniCover.HitServices.HitService::EnterMethod(System.String,System.String,System.String,System.String) IL_0019: stloc.s V_4 IL_001b: nop .try @@ -39,32 +39,32 @@ public override void FunctionalTest() IL_001c: nop IL_001d: ldloc.s V_4 IL_001f: ldc.i4.1 - IL_0020: callvirt System.Void MiniCover.HitServices.HitService/MethodContext::Hit(System.Int32) + IL_0020: callvirt System.Void MiniCover.HitServices.MethodScope::Hit(System.Int32) IL_0025: ldc.i4.0 IL_0026: stloc.0 IL_0027: ldloc.s V_4 IL_0029: ldc.i4.2 - IL_002a: callvirt System.Void MiniCover.HitServices.HitService/MethodContext::Hit(System.Int32) + IL_002a: callvirt System.Void MiniCover.HitServices.MethodScope::Hit(System.Int32) IL_002f: ldc.i4.1 IL_0030: stloc.1 IL_0031: br.s IL_004b IL_0033: ldloc.s V_4 IL_0035: ldc.i4.3 - IL_0036: callvirt System.Void MiniCover.HitServices.HitService/MethodContext::Hit(System.Int32) + IL_0036: callvirt System.Void MiniCover.HitServices.MethodScope::Hit(System.Int32) IL_003b: ldloc.0 IL_003c: ldloc.1 IL_003d: add IL_003e: stloc.0 IL_003f: ldloc.s V_4 IL_0041: ldc.i4.4 - IL_0042: callvirt System.Void MiniCover.HitServices.HitService/MethodContext::Hit(System.Int32) + IL_0042: callvirt System.Void MiniCover.HitServices.MethodScope::Hit(System.Int32) IL_0047: ldloc.1 IL_0048: ldc.i4.1 IL_0049: add IL_004a: stloc.1 IL_004b: ldloc.s V_4 IL_004d: ldc.i4.5 - IL_004e: callvirt System.Void MiniCover.HitServices.HitService/MethodContext::Hit(System.Int32) + IL_004e: callvirt System.Void MiniCover.HitServices.MethodScope::Hit(System.Int32) IL_0053: ldloc.1 IL_0054: ldarg.1 IL_0055: cgt @@ -75,7 +75,7 @@ public override void FunctionalTest() IL_005c: brtrue.s IL_0033 IL_005e: ldloc.s V_4 IL_0060: ldc.i4.6 - IL_0061: callvirt System.Void MiniCover.HitServices.HitService/MethodContext::Hit(System.Int32) + IL_0061: callvirt System.Void MiniCover.HitServices.MethodScope::Hit(System.Int32) IL_0066: ldloc.0 IL_0067: stloc.3 IL_0068: br.s IL_006a @@ -87,7 +87,7 @@ public override void FunctionalTest() { IL_006f: nop IL_0070: ldloc.s V_4 - IL_0072: callvirt System.Void MiniCover.HitServices.HitService/MethodContext::Dispose() + IL_0072: callvirt System.Void MiniCover.HitServices.MethodScope::Dispose() IL_0077: endfinally } IL_0078: ldloc.s V_5 diff --git a/tests/MiniCover.UnitTests/Instrumentation/If.cs b/tests/MiniCover.UnitTests/Instrumentation/If.cs index 7d210d2..130784d 100644 --- a/tests/MiniCover.UnitTests/Instrumentation/If.cs +++ b/tests/MiniCover.UnitTests/Instrumentation/If.cs @@ -27,12 +27,12 @@ public override void FunctionalTest() new Class().Method(2).Should().Be(true); } - public override string ExpectedIL => @".locals init (System.Boolean V_0, System.Boolean V_1, MiniCover.HitServices.HitService/MethodContext V_2, System.Boolean V_3) + public override string ExpectedIL => @".locals init (System.Boolean V_0, System.Boolean V_1, MiniCover.HitServices.MethodScope V_2, System.Boolean V_3) IL_0000: ldstr ""/tmp"" IL_0005: ldstr ""MiniCover.UnitTests"" IL_000a: ldstr ""MiniCover.UnitTests.Instrumentation.If/Class"" IL_000f: ldstr ""Method"" -IL_0014: call MiniCover.HitServices.HitService/MethodContext MiniCover.HitServices.HitService::EnterMethod(System.String,System.String,System.String,System.String) +IL_0014: call MiniCover.HitServices.MethodScope MiniCover.HitServices.HitService::EnterMethod(System.String,System.String,System.String,System.String) IL_0019: stloc.2 IL_001a: nop .try @@ -40,7 +40,7 @@ public override void FunctionalTest() IL_001b: nop IL_001c: ldloc.2 IL_001d: ldc.i4.1 - IL_001e: callvirt System.Void MiniCover.HitServices.HitService/MethodContext::Hit(System.Int32) + IL_001e: callvirt System.Void MiniCover.HitServices.MethodScope::Hit(System.Int32) IL_0023: ldarg.1 IL_0024: ldc.i4.2 IL_0025: rem @@ -51,13 +51,13 @@ public override void FunctionalTest() IL_002b: brfalse.s IL_0038 IL_002d: ldloc.2 IL_002e: ldc.i4.2 - IL_002f: callvirt System.Void MiniCover.HitServices.HitService/MethodContext::Hit(System.Int32) + IL_002f: callvirt System.Void MiniCover.HitServices.MethodScope::Hit(System.Int32) IL_0034: ldc.i4.1 IL_0035: stloc.1 IL_0036: br.s IL_0043 IL_0038: ldloc.2 IL_0039: ldc.i4.3 - IL_003a: callvirt System.Void MiniCover.HitServices.HitService/MethodContext::Hit(System.Int32) + IL_003a: callvirt System.Void MiniCover.HitServices.MethodScope::Hit(System.Int32) IL_003f: ldc.i4.0 IL_0040: stloc.1 IL_0041: br.s IL_0043 @@ -69,7 +69,7 @@ public override void FunctionalTest() { IL_0047: nop IL_0048: ldloc.2 - IL_0049: callvirt System.Void MiniCover.HitServices.HitService/MethodContext::Dispose() + IL_0049: callvirt System.Void MiniCover.HitServices.MethodScope::Dispose() IL_004e: endfinally } IL_004f: ldloc.3 diff --git a/tests/MiniCover.UnitTests/Instrumentation/IfInline.cs b/tests/MiniCover.UnitTests/Instrumentation/IfInline.cs index 91d849d..f7414e8 100644 --- a/tests/MiniCover.UnitTests/Instrumentation/IfInline.cs +++ b/tests/MiniCover.UnitTests/Instrumentation/IfInline.cs @@ -26,12 +26,12 @@ public override void FunctionalTest() new Class().Method(2).Should().Be(true); } - public override string ExpectedIL => @".locals init (System.Boolean V_0, MiniCover.HitServices.HitService/MethodContext V_1, System.Boolean V_2) + public override string ExpectedIL => @".locals init (System.Boolean V_0, MiniCover.HitServices.MethodScope V_1, System.Boolean V_2) IL_0000: ldstr ""/tmp"" IL_0005: ldstr ""MiniCover.UnitTests"" IL_000a: ldstr ""MiniCover.UnitTests.Instrumentation.IfInline/Class"" IL_000f: ldstr ""Method"" -IL_0014: call MiniCover.HitServices.HitService/MethodContext MiniCover.HitServices.HitService::EnterMethod(System.String,System.String,System.String,System.String) +IL_0014: call MiniCover.HitServices.MethodScope MiniCover.HitServices.HitService::EnterMethod(System.String,System.String,System.String,System.String) IL_0019: stloc.1 IL_001a: nop .try @@ -39,19 +39,19 @@ public override void FunctionalTest() IL_001b: nop IL_001c: ldloc.1 IL_001d: ldc.i4.1 - IL_001e: callvirt System.Void MiniCover.HitServices.HitService/MethodContext::Hit(System.Int32) + IL_001e: callvirt System.Void MiniCover.HitServices.MethodScope::Hit(System.Int32) IL_0023: ldarg.1 IL_0024: ldc.i4.2 IL_0025: rem IL_0026: brfalse.s IL_0032 IL_0028: ldloc.1 IL_0029: ldc.i4.2 - IL_002a: callvirt System.Void MiniCover.HitServices.HitService/MethodContext::Hit(System.Int32) + IL_002a: callvirt System.Void MiniCover.HitServices.MethodScope::Hit(System.Int32) IL_002f: ldc.i4.0 IL_0030: br.s IL_003a IL_0032: ldloc.1 IL_0033: ldc.i4.3 - IL_0034: callvirt System.Void MiniCover.HitServices.HitService/MethodContext::Hit(System.Int32) + IL_0034: callvirt System.Void MiniCover.HitServices.MethodScope::Hit(System.Int32) IL_0039: ldc.i4.1 IL_003a: stloc.0 IL_003b: br.s IL_003d @@ -63,7 +63,7 @@ public override void FunctionalTest() { IL_0041: nop IL_0042: ldloc.1 - IL_0043: callvirt System.Void MiniCover.HitServices.HitService/MethodContext::Dispose() + IL_0043: callvirt System.Void MiniCover.HitServices.MethodScope::Dispose() IL_0048: endfinally } IL_0049: ldloc.2 diff --git a/tests/MiniCover.UnitTests/Instrumentation/IfInlineNested.cs b/tests/MiniCover.UnitTests/Instrumentation/IfInlineNested.cs index beb9b2d..d545588 100644 --- a/tests/MiniCover.UnitTests/Instrumentation/IfInlineNested.cs +++ b/tests/MiniCover.UnitTests/Instrumentation/IfInlineNested.cs @@ -29,12 +29,12 @@ public override void FunctionalTest() new Class().Method(5).Should().Be(false); } - public override string ExpectedIL => @".locals init (System.Boolean V_0, MiniCover.HitServices.HitService/MethodContext V_1, System.Boolean V_2) + public override string ExpectedIL => @".locals init (System.Boolean V_0, MiniCover.HitServices.MethodScope V_1, System.Boolean V_2) IL_0000: ldstr ""/tmp"" IL_0005: ldstr ""MiniCover.UnitTests"" IL_000a: ldstr ""MiniCover.UnitTests.Instrumentation.IfInlineNested/Class"" IL_000f: ldstr ""Method"" -IL_0014: call MiniCover.HitServices.HitService/MethodContext MiniCover.HitServices.HitService::EnterMethod(System.String,System.String,System.String,System.String) +IL_0014: call MiniCover.HitServices.MethodScope MiniCover.HitServices.HitService::EnterMethod(System.String,System.String,System.String,System.String) IL_0019: stloc.1 IL_001a: nop .try @@ -42,31 +42,31 @@ public override void FunctionalTest() IL_001b: nop IL_001c: ldloc.1 IL_001d: ldc.i4.1 - IL_001e: callvirt System.Void MiniCover.HitServices.HitService/MethodContext::Hit(System.Int32) + IL_001e: callvirt System.Void MiniCover.HitServices.MethodScope::Hit(System.Int32) IL_0023: ldarg.1 IL_0024: ldc.i4.2 IL_0025: rem IL_0026: brfalse.s IL_0048 IL_0028: ldloc.1 IL_0029: ldc.i4.2 - IL_002a: callvirt System.Void MiniCover.HitServices.HitService/MethodContext::Hit(System.Int32) + IL_002a: callvirt System.Void MiniCover.HitServices.MethodScope::Hit(System.Int32) IL_002f: ldarg.1 IL_0030: ldc.i4.3 IL_0031: rem IL_0032: brfalse.s IL_003e IL_0034: ldloc.1 IL_0035: ldc.i4.4 - IL_0036: callvirt System.Void MiniCover.HitServices.HitService/MethodContext::Hit(System.Int32) + IL_0036: callvirt System.Void MiniCover.HitServices.MethodScope::Hit(System.Int32) IL_003b: ldc.i4.0 IL_003c: br.s IL_0046 IL_003e: ldloc.1 IL_003f: ldc.i4.5 - IL_0040: callvirt System.Void MiniCover.HitServices.HitService/MethodContext::Hit(System.Int32) + IL_0040: callvirt System.Void MiniCover.HitServices.MethodScope::Hit(System.Int32) IL_0045: ldc.i4.1 IL_0046: br.s IL_0050 IL_0048: ldloc.1 IL_0049: ldc.i4.3 - IL_004a: callvirt System.Void MiniCover.HitServices.HitService/MethodContext::Hit(System.Int32) + IL_004a: callvirt System.Void MiniCover.HitServices.MethodScope::Hit(System.Int32) IL_004f: ldc.i4.1 IL_0050: stloc.0 IL_0051: br.s IL_0053 @@ -78,7 +78,7 @@ public override void FunctionalTest() { IL_0057: nop IL_0058: ldloc.1 - IL_0059: callvirt System.Void MiniCover.HitServices.HitService/MethodContext::Dispose() + IL_0059: callvirt System.Void MiniCover.HitServices.MethodScope::Dispose() IL_005e: endfinally } IL_005f: ldloc.2 diff --git a/tests/MiniCover.UnitTests/Instrumentation/IfWithAnd.cs b/tests/MiniCover.UnitTests/Instrumentation/IfWithAnd.cs index 33e151c..891d6df 100644 --- a/tests/MiniCover.UnitTests/Instrumentation/IfWithAnd.cs +++ b/tests/MiniCover.UnitTests/Instrumentation/IfWithAnd.cs @@ -27,12 +27,12 @@ public override void FunctionalTest() new Class().Method(3).Should().Be(false); } - public override string ExpectedIL => @".locals init (System.Boolean V_0, System.Boolean V_1, MiniCover.HitServices.HitService/MethodContext V_2, System.Boolean V_3) + public override string ExpectedIL => @".locals init (System.Boolean V_0, System.Boolean V_1, MiniCover.HitServices.MethodScope V_2, System.Boolean V_3) IL_0000: ldstr ""/tmp"" IL_0005: ldstr ""MiniCover.UnitTests"" IL_000a: ldstr ""MiniCover.UnitTests.Instrumentation.IfWithAnd/Class"" IL_000f: ldstr ""Method"" -IL_0014: call MiniCover.HitServices.HitService/MethodContext MiniCover.HitServices.HitService::EnterMethod(System.String,System.String,System.String,System.String) +IL_0014: call MiniCover.HitServices.MethodScope MiniCover.HitServices.HitService::EnterMethod(System.String,System.String,System.String,System.String) IL_0019: stloc.2 IL_001a: nop .try @@ -40,14 +40,14 @@ public override void FunctionalTest() IL_001b: nop IL_001c: ldloc.2 IL_001d: ldc.i4.1 - IL_001e: callvirt System.Void MiniCover.HitServices.HitService/MethodContext::Hit(System.Int32) + IL_001e: callvirt System.Void MiniCover.HitServices.MethodScope::Hit(System.Int32) IL_0023: ldarg.1 IL_0024: ldc.i4.2 IL_0025: rem IL_0026: brtrue.s IL_0037 IL_0028: ldloc.2 IL_0029: ldc.i4.2 - IL_002a: callvirt System.Void MiniCover.HitServices.HitService/MethodContext::Hit(System.Int32) + IL_002a: callvirt System.Void MiniCover.HitServices.MethodScope::Hit(System.Int32) IL_002f: ldarg.1 IL_0030: ldc.i4.3 IL_0031: rem @@ -56,20 +56,20 @@ public override void FunctionalTest() IL_0035: br.s IL_003f IL_0037: ldloc.2 IL_0038: ldc.i4.3 - IL_0039: callvirt System.Void MiniCover.HitServices.HitService/MethodContext::Hit(System.Int32) + IL_0039: callvirt System.Void MiniCover.HitServices.MethodScope::Hit(System.Int32) IL_003e: ldc.i4.0 IL_003f: stloc.0 IL_0040: ldloc.0 IL_0041: brfalse.s IL_004e IL_0043: ldloc.2 IL_0044: ldc.i4.4 - IL_0045: callvirt System.Void MiniCover.HitServices.HitService/MethodContext::Hit(System.Int32) + IL_0045: callvirt System.Void MiniCover.HitServices.MethodScope::Hit(System.Int32) IL_004a: ldc.i4.1 IL_004b: stloc.1 IL_004c: br.s IL_0059 IL_004e: ldloc.2 IL_004f: ldc.i4.5 - IL_0050: callvirt System.Void MiniCover.HitServices.HitService/MethodContext::Hit(System.Int32) + IL_0050: callvirt System.Void MiniCover.HitServices.MethodScope::Hit(System.Int32) IL_0055: ldc.i4.0 IL_0056: stloc.1 IL_0057: br.s IL_0059 @@ -81,7 +81,7 @@ public override void FunctionalTest() { IL_005d: nop IL_005e: ldloc.2 - IL_005f: callvirt System.Void MiniCover.HitServices.HitService/MethodContext::Dispose() + IL_005f: callvirt System.Void MiniCover.HitServices.MethodScope::Dispose() IL_0064: endfinally } IL_0065: ldloc.3 diff --git a/tests/MiniCover.UnitTests/Instrumentation/Lambda.cs b/tests/MiniCover.UnitTests/Instrumentation/Lambda.cs index 623d86d..42bfdc9 100644 --- a/tests/MiniCover.UnitTests/Instrumentation/Lambda.cs +++ b/tests/MiniCover.UnitTests/Instrumentation/Lambda.cs @@ -28,12 +28,12 @@ public override void FunctionalTest() { .method public System.Int32 Method { - .locals init (System.Int32 V_0, MiniCover.HitServices.HitService/MethodContext V_1, System.Int32 V_2) + .locals init (System.Int32 V_0, MiniCover.HitServices.MethodScope V_1, System.Int32 V_2) IL_0000: ldstr ""/tmp"" IL_0005: ldstr ""MiniCover.UnitTests"" IL_000a: ldstr ""MiniCover.UnitTests.Instrumentation.Lambda/Class"" IL_000f: ldstr ""Method"" - IL_0014: call MiniCover.HitServices.HitService/MethodContext MiniCover.HitServices.HitService::EnterMethod(System.String,System.String,System.String,System.String) + IL_0014: call MiniCover.HitServices.MethodScope MiniCover.HitServices.HitService::EnterMethod(System.String,System.String,System.String,System.String) IL_0019: stloc.1 IL_001a: nop .try @@ -41,7 +41,7 @@ .locals init (System.Int32 V_0, MiniCover.HitServices.HitService/MethodContext V IL_001b: nop IL_001c: ldloc.1 IL_001d: ldc.i4.1 - IL_001e: callvirt System.Void MiniCover.HitServices.HitService/MethodContext::Hit(System.Int32) + IL_001e: callvirt System.Void MiniCover.HitServices.MethodScope::Hit(System.Int32) IL_0023: ldarg.1 IL_0024: ldsfld System.Func`2 MiniCover.UnitTests.Instrumentation.Lambda/Class/<>c::<>9__0_0 IL_0029: dup @@ -64,7 +64,7 @@ .locals init (System.Int32 V_0, MiniCover.HitServices.HitService/MethodContext V { IL_0054: nop IL_0055: ldloc.1 - IL_0056: callvirt System.Void MiniCover.HitServices.HitService/MethodContext::Dispose() + IL_0056: callvirt System.Void MiniCover.HitServices.MethodScope::Dispose() IL_005b: endfinally } IL_005c: ldloc.2 @@ -97,19 +97,19 @@ .locals init (System.Int32 V_0, MiniCover.HitServices.HitService/MethodContext V } .method System.Int32 b__0_0 { - .locals init (MiniCover.HitServices.HitService/MethodContext V_0, System.Int32 V_1) + .locals init (MiniCover.HitServices.MethodScope V_0, System.Int32 V_1) IL_0000: ldstr ""/tmp"" IL_0005: ldstr ""MiniCover.UnitTests"" IL_000a: ldstr ""MiniCover.UnitTests.Instrumentation.Lambda/Class"" IL_000f: ldstr ""Method"" - IL_0014: call MiniCover.HitServices.HitService/MethodContext MiniCover.HitServices.HitService::EnterMethod(System.String,System.String,System.String,System.String) + IL_0014: call MiniCover.HitServices.MethodScope MiniCover.HitServices.HitService::EnterMethod(System.String,System.String,System.String,System.String) IL_0019: stloc.0 IL_001a: nop .try { IL_001b: ldloc.0 IL_001c: ldc.i4.2 - IL_001d: callvirt System.Void MiniCover.HitServices.HitService/MethodContext::Hit(System.Int32) + IL_001d: callvirt System.Void MiniCover.HitServices.MethodScope::Hit(System.Int32) IL_0022: ldarg.1 IL_0023: ldc.i4.2 IL_0024: mul @@ -120,7 +120,7 @@ .locals init (MiniCover.HitServices.HitService/MethodContext V_0, System.Int32 V { IL_0028: nop IL_0029: ldloc.0 - IL_002a: callvirt System.Void MiniCover.HitServices.HitService/MethodContext::Dispose() + IL_002a: callvirt System.Void MiniCover.HitServices.MethodScope::Dispose() IL_002f: endfinally } IL_0030: ldloc.1 diff --git a/tests/MiniCover.UnitTests/Instrumentation/Or.cs b/tests/MiniCover.UnitTests/Instrumentation/Or.cs index 90f80f6..fe9ec20 100644 --- a/tests/MiniCover.UnitTests/Instrumentation/Or.cs +++ b/tests/MiniCover.UnitTests/Instrumentation/Or.cs @@ -24,12 +24,12 @@ public override void FunctionalTest() new Class().Method(true, false).Should().Be(true); } - public override string ExpectedIL => @".locals init (System.Boolean V_0, MiniCover.HitServices.HitService/MethodContext V_1, System.Boolean V_2) + public override string ExpectedIL => @".locals init (System.Boolean V_0, MiniCover.HitServices.MethodScope V_1, System.Boolean V_2) IL_0000: ldstr ""/tmp"" IL_0005: ldstr ""MiniCover.UnitTests"" IL_000a: ldstr ""MiniCover.UnitTests.Instrumentation.Or/Class"" IL_000f: ldstr ""Method"" -IL_0014: call MiniCover.HitServices.HitService/MethodContext MiniCover.HitServices.HitService::EnterMethod(System.String,System.String,System.String,System.String) +IL_0014: call MiniCover.HitServices.MethodScope MiniCover.HitServices.HitService::EnterMethod(System.String,System.String,System.String,System.String) IL_0019: stloc.1 IL_001a: nop .try @@ -37,7 +37,7 @@ public override void FunctionalTest() IL_001b: nop IL_001c: ldloc.1 IL_001d: ldc.i4.1 - IL_001e: callvirt System.Void MiniCover.HitServices.HitService/MethodContext::Hit(System.Int32) + IL_001e: callvirt System.Void MiniCover.HitServices.MethodScope::Hit(System.Int32) IL_0023: ldarg.1 IL_0024: ldarg.2 IL_0025: or @@ -51,7 +51,7 @@ public override void FunctionalTest() { IL_002d: nop IL_002e: ldloc.1 - IL_002f: callvirt System.Void MiniCover.HitServices.HitService/MethodContext::Dispose() + IL_002f: callvirt System.Void MiniCover.HitServices.MethodScope::Dispose() IL_0034: endfinally } IL_0035: ldloc.2 diff --git a/tests/MiniCover.UnitTests/Instrumentation/OrWithEquals.cs b/tests/MiniCover.UnitTests/Instrumentation/OrWithEquals.cs index 05b4c2b..60f9bc5 100644 --- a/tests/MiniCover.UnitTests/Instrumentation/OrWithEquals.cs +++ b/tests/MiniCover.UnitTests/Instrumentation/OrWithEquals.cs @@ -24,12 +24,12 @@ public override void FunctionalTest() new Class().Method(5).Should().Be(false); } - public override string ExpectedIL => @".locals init (System.Boolean V_0, MiniCover.HitServices.HitService/MethodContext V_1, System.Boolean V_2) + public override string ExpectedIL => @".locals init (System.Boolean V_0, MiniCover.HitServices.MethodScope V_1, System.Boolean V_2) IL_0000: ldstr ""/tmp"" IL_0005: ldstr ""MiniCover.UnitTests"" IL_000a: ldstr ""MiniCover.UnitTests.Instrumentation.OrWithEquals/Class"" IL_000f: ldstr ""Method"" -IL_0014: call MiniCover.HitServices.HitService/MethodContext MiniCover.HitServices.HitService::EnterMethod(System.String,System.String,System.String,System.String) +IL_0014: call MiniCover.HitServices.MethodScope MiniCover.HitServices.HitService::EnterMethod(System.String,System.String,System.String,System.String) IL_0019: stloc.1 IL_001a: nop .try @@ -37,14 +37,14 @@ public override void FunctionalTest() IL_001b: nop IL_001c: ldloc.1 IL_001d: ldc.i4.1 - IL_001e: callvirt System.Void MiniCover.HitServices.HitService/MethodContext::Hit(System.Int32) + IL_001e: callvirt System.Void MiniCover.HitServices.MethodScope::Hit(System.Int32) IL_0023: ldarg.1 IL_0024: ldc.i4.2 IL_0025: rem IL_0026: brfalse.s IL_0037 IL_0028: ldloc.1 IL_0029: ldc.i4.2 - IL_002a: callvirt System.Void MiniCover.HitServices.HitService/MethodContext::Hit(System.Int32) + IL_002a: callvirt System.Void MiniCover.HitServices.MethodScope::Hit(System.Int32) IL_002f: ldarg.1 IL_0030: ldc.i4.3 IL_0031: rem @@ -53,7 +53,7 @@ public override void FunctionalTest() IL_0035: br.s IL_003f IL_0037: ldloc.1 IL_0038: ldc.i4.3 - IL_0039: callvirt System.Void MiniCover.HitServices.HitService/MethodContext::Hit(System.Int32) + IL_0039: callvirt System.Void MiniCover.HitServices.MethodScope::Hit(System.Int32) IL_003e: ldc.i4.1 IL_003f: stloc.0 IL_0040: br.s IL_0042 @@ -65,7 +65,7 @@ public override void FunctionalTest() { IL_0046: nop IL_0047: ldloc.1 - IL_0048: callvirt System.Void MiniCover.HitServices.HitService/MethodContext::Dispose() + IL_0048: callvirt System.Void MiniCover.HitServices.MethodScope::Dispose() IL_004d: endfinally } IL_004e: ldloc.2 diff --git a/tests/MiniCover.UnitTests/Instrumentation/StaticMethod.cs b/tests/MiniCover.UnitTests/Instrumentation/StaticMethod.cs index 7f9b806..ebdae8d 100644 --- a/tests/MiniCover.UnitTests/Instrumentation/StaticMethod.cs +++ b/tests/MiniCover.UnitTests/Instrumentation/StaticMethod.cs @@ -24,12 +24,12 @@ public override void FunctionalTest() Class.Method(5).Should().Be(10); } - public override string ExpectedIL => @".locals init (System.Int32 V_0, MiniCover.HitServices.HitService/MethodContext V_1, System.Int32 V_2) + public override string ExpectedIL => @".locals init (System.Int32 V_0, MiniCover.HitServices.MethodScope V_1, System.Int32 V_2) IL_0000: ldstr ""/tmp"" IL_0005: ldstr ""MiniCover.UnitTests"" IL_000a: ldstr ""MiniCover.UnitTests.Instrumentation.StaticMethod/Class"" IL_000f: ldstr ""Method"" -IL_0014: call MiniCover.HitServices.HitService/MethodContext MiniCover.HitServices.HitService::EnterMethod(System.String,System.String,System.String,System.String) +IL_0014: call MiniCover.HitServices.MethodScope MiniCover.HitServices.HitService::EnterMethod(System.String,System.String,System.String,System.String) IL_0019: stloc.1 IL_001a: nop .try @@ -37,7 +37,7 @@ public override void FunctionalTest() IL_001b: nop IL_001c: ldloc.1 IL_001d: ldc.i4.1 - IL_001e: callvirt System.Void MiniCover.HitServices.HitService/MethodContext::Hit(System.Int32) + IL_001e: callvirt System.Void MiniCover.HitServices.MethodScope::Hit(System.Int32) IL_0023: ldarg.0 // this IL_0024: ldc.i4.2 IL_0025: mul @@ -51,7 +51,7 @@ public override void FunctionalTest() { IL_002d: nop IL_002e: ldloc.1 - IL_002f: callvirt System.Void MiniCover.HitServices.HitService/MethodContext::Dispose() + IL_002f: callvirt System.Void MiniCover.HitServices.MethodScope::Dispose() IL_0034: endfinally } IL_0035: ldloc.2 diff --git a/tests/MiniCover.UnitTests/Instrumentation/Switch.cs b/tests/MiniCover.UnitTests/Instrumentation/Switch.cs index 45d493e..7949fa8 100644 --- a/tests/MiniCover.UnitTests/Instrumentation/Switch.cs +++ b/tests/MiniCover.UnitTests/Instrumentation/Switch.cs @@ -36,12 +36,12 @@ public override void FunctionalTest() new Class().Method(4).Should().Be(0); } - public override string ExpectedIL => @".locals init (System.Int32 V_0, System.Int32 V_1, System.Int32 V_2, MiniCover.HitServices.HitService/MethodContext V_3, System.Int32 V_4) + public override string ExpectedIL => @".locals init (System.Int32 V_0, System.Int32 V_1, System.Int32 V_2, MiniCover.HitServices.MethodScope V_3, System.Int32 V_4) IL_0000: ldstr ""/tmp"" IL_0005: ldstr ""MiniCover.UnitTests"" IL_000a: ldstr ""MiniCover.UnitTests.Instrumentation.Switch/Class"" IL_000f: ldstr ""Method"" -IL_0014: call MiniCover.HitServices.HitService/MethodContext MiniCover.HitServices.HitService::EnterMethod(System.String,System.String,System.String,System.String) +IL_0014: call MiniCover.HitServices.MethodScope MiniCover.HitServices.HitService::EnterMethod(System.String,System.String,System.String,System.String) IL_0019: stloc.3 IL_001a: nop .try @@ -49,7 +49,7 @@ public override void FunctionalTest() IL_001b: nop IL_001c: ldloc.3 IL_001d: ldc.i4.1 - IL_001e: callvirt System.Void MiniCover.HitServices.HitService/MethodContext::Hit(System.Int32) + IL_001e: callvirt System.Void MiniCover.HitServices.MethodScope::Hit(System.Int32) IL_0023: ldarg.1 IL_0024: stloc.1 IL_0025: ldloc.1 @@ -61,25 +61,25 @@ public override void FunctionalTest() IL_003b: br.s IL_005e IL_003d: ldloc.3 IL_003e: ldc.i4.3 - IL_003f: callvirt System.Void MiniCover.HitServices.HitService/MethodContext::Hit(System.Int32) + IL_003f: callvirt System.Void MiniCover.HitServices.MethodScope::Hit(System.Int32) IL_0044: ldc.i4.1 IL_0045: stloc.2 IL_0046: br.s IL_0069 IL_0048: ldloc.3 IL_0049: ldc.i4.4 - IL_004a: callvirt System.Void MiniCover.HitServices.HitService/MethodContext::Hit(System.Int32) + IL_004a: callvirt System.Void MiniCover.HitServices.MethodScope::Hit(System.Int32) IL_004f: ldc.i4.2 IL_0050: stloc.2 IL_0051: br.s IL_0069 IL_0053: ldloc.3 IL_0054: ldc.i4.5 - IL_0055: callvirt System.Void MiniCover.HitServices.HitService/MethodContext::Hit(System.Int32) + IL_0055: callvirt System.Void MiniCover.HitServices.MethodScope::Hit(System.Int32) IL_005a: ldc.i4.3 IL_005b: stloc.2 IL_005c: br.s IL_0069 IL_005e: ldloc.3 IL_005f: ldc.i4.2 - IL_0060: callvirt System.Void MiniCover.HitServices.HitService/MethodContext::Hit(System.Int32) + IL_0060: callvirt System.Void MiniCover.HitServices.MethodScope::Hit(System.Int32) IL_0065: ldc.i4.0 IL_0066: stloc.2 IL_0067: br.s IL_0069 @@ -91,7 +91,7 @@ public override void FunctionalTest() { IL_006e: nop IL_006f: ldloc.3 - IL_0070: callvirt System.Void MiniCover.HitServices.HitService/MethodContext::Dispose() + IL_0070: callvirt System.Void MiniCover.HitServices.MethodScope::Dispose() IL_0075: endfinally } IL_0076: ldloc.s V_4 diff --git a/tests/MiniCover.UnitTests/Instrumentation/ThrowException.cs b/tests/MiniCover.UnitTests/Instrumentation/ThrowException.cs index 1686c4f..5efc231 100644 --- a/tests/MiniCover.UnitTests/Instrumentation/ThrowException.cs +++ b/tests/MiniCover.UnitTests/Instrumentation/ThrowException.cs @@ -30,12 +30,12 @@ public override void FunctionalTest() } } - public override string ExpectedIL => @".locals init (MiniCover.HitServices.HitService/MethodContext V_0, System.Int32 V_1) + public override string ExpectedIL => @".locals init (MiniCover.HitServices.MethodScope V_0, System.Int32 V_1) IL_0000: ldstr ""/tmp"" IL_0005: ldstr ""MiniCover.UnitTests"" IL_000a: ldstr ""MiniCover.UnitTests.Instrumentation.ThrowException/Class"" IL_000f: ldstr ""Method"" -IL_0014: call MiniCover.HitServices.HitService/MethodContext MiniCover.HitServices.HitService::EnterMethod(System.String,System.String,System.String,System.String) +IL_0014: call MiniCover.HitServices.MethodScope MiniCover.HitServices.HitService::EnterMethod(System.String,System.String,System.String,System.String) IL_0019: stloc.0 IL_001a: nop .try @@ -43,14 +43,14 @@ public override void FunctionalTest() IL_001b: nop IL_001c: ldloc.0 IL_001d: ldc.i4.1 - IL_001e: callvirt System.Void MiniCover.HitServices.HitService/MethodContext::Hit(System.Int32) + IL_001e: callvirt System.Void MiniCover.HitServices.MethodScope::Hit(System.Int32) IL_0023: ldarg.1 IL_0024: ldc.i4.2 IL_0025: mul IL_0026: starg 1 IL_002a: ldloc.0 IL_002b: ldc.i4.2 - IL_002c: callvirt System.Void MiniCover.HitServices.HitService/MethodContext::Hit(System.Int32) + IL_002c: callvirt System.Void MiniCover.HitServices.MethodScope::Hit(System.Int32) IL_0031: ldstr ""Some exception"" IL_0036: newobj System.Void System.Exception::.ctor(System.String) IL_003b: throw @@ -59,7 +59,7 @@ public override void FunctionalTest() { IL_003c: nop IL_003d: ldloc.0 - IL_003e: callvirt System.Void MiniCover.HitServices.HitService/MethodContext::Dispose() + IL_003e: callvirt System.Void MiniCover.HitServices.MethodScope::Dispose() IL_0043: endfinally } IL_0044: ldloc.1 diff --git a/tests/MiniCover.UnitTests/Instrumentation/Using.cs b/tests/MiniCover.UnitTests/Instrumentation/Using.cs index dee47f3..1c7d8fb 100644 --- a/tests/MiniCover.UnitTests/Instrumentation/Using.cs +++ b/tests/MiniCover.UnitTests/Instrumentation/Using.cs @@ -27,12 +27,12 @@ public override void FunctionalTest() new Class().Method().Should().BeEquivalentTo(new byte[] { 0x00 }); } - public override string ExpectedIL => @".locals init (System.IO.MemoryStream stream, System.Byte[] V_1, MiniCover.HitServices.HitService/MethodContext V_2, System.Byte[] V_3) + public override string ExpectedIL => @".locals init (System.IO.MemoryStream stream, System.Byte[] V_1, MiniCover.HitServices.MethodScope V_2, System.Byte[] V_3) IL_0000: ldstr ""/tmp"" IL_0005: ldstr ""MiniCover.UnitTests"" IL_000a: ldstr ""MiniCover.UnitTests.Instrumentation.Using/Class"" IL_000f: ldstr ""Method"" -IL_0014: call MiniCover.HitServices.HitService/MethodContext MiniCover.HitServices.HitService::EnterMethod(System.String,System.String,System.String,System.String) +IL_0014: call MiniCover.HitServices.MethodScope MiniCover.HitServices.HitService::EnterMethod(System.String,System.String,System.String,System.String) IL_0019: stloc.2 IL_001a: nop .try @@ -40,7 +40,7 @@ public override void FunctionalTest() IL_001b: nop IL_001c: ldloc.2 IL_001d: ldc.i4.1 - IL_001e: callvirt System.Void MiniCover.HitServices.HitService/MethodContext::Hit(System.Int32) + IL_001e: callvirt System.Void MiniCover.HitServices.MethodScope::Hit(System.Int32) IL_0023: newobj System.Void System.IO.MemoryStream::.ctor() IL_0028: stloc.0 .try @@ -48,14 +48,14 @@ public override void FunctionalTest() IL_0029: nop IL_002a: ldloc.2 IL_002b: ldc.i4.2 - IL_002c: callvirt System.Void MiniCover.HitServices.HitService/MethodContext::Hit(System.Int32) + IL_002c: callvirt System.Void MiniCover.HitServices.MethodScope::Hit(System.Int32) IL_0031: ldloc.0 IL_0032: ldc.i4.0 IL_0033: callvirt System.Void System.IO.Stream::WriteByte(System.Byte) IL_0038: nop IL_0039: ldloc.2 IL_003a: ldc.i4.3 - IL_003b: callvirt System.Void MiniCover.HitServices.HitService/MethodContext::Hit(System.Int32) + IL_003b: callvirt System.Void MiniCover.HitServices.MethodScope::Hit(System.Int32) IL_0040: ldloc.0 IL_0041: callvirt System.Byte[] System.IO.MemoryStream::ToArray() IL_0046: stloc.1 @@ -78,7 +78,7 @@ public override void FunctionalTest() { IL_0058: nop IL_0059: ldloc.2 - IL_005a: callvirt System.Void MiniCover.HitServices.HitService/MethodContext::Dispose() + IL_005a: callvirt System.Void MiniCover.HitServices.MethodScope::Dispose() IL_005f: endfinally } IL_0060: ldloc.3 From 966f5c7546133556a0f8fd9ce53eb5b2f5dc75ce Mon Sep 17 00:00:00 2001 From: Lucas Lara Date: Fri, 30 Oct 2020 22:06:33 +0100 Subject: [PATCH 3/3] Don't save the same HitContext to different files --- src/MiniCover.HitServices/HitContext.cs | 66 +++++++++---------- src/MiniCover.HitServices/MethodScope.cs | 44 +++++++++---- .../HitContextTests.cs | 2 +- .../Instrumentation/BaseTest.cs | 1 + 4 files changed, 64 insertions(+), 49 deletions(-) diff --git a/src/MiniCover.HitServices/HitContext.cs b/src/MiniCover.HitServices/HitContext.cs index 986b734..c244623 100644 --- a/src/MiniCover.HitServices/HitContext.cs +++ b/src/MiniCover.HitServices/HitContext.cs @@ -1,4 +1,5 @@ -using System.Collections.Generic; +using System; +using System.Collections.Generic; using System.IO; using System.Linq; using System.Text; @@ -16,9 +17,7 @@ public static HitContext Current set => _currentAsyncLocal.Value = value; } - private readonly object _lock = new object(); - - private int _refCount; + private int _methodCount; public HitContext( string assemblyName, @@ -26,38 +25,30 @@ public static HitContext Current string methodName, IDictionary hits = null) { + Id = Guid.NewGuid().ToString(); AssemblyName = assemblyName; ClassName = className; MethodName = methodName; - Hits = hits ?? new Dictionary(); + Hits = hits != null + ? new Dictionary(hits) + : new Dictionary(); } + public string Id { get; } public string AssemblyName { get; } public string ClassName { get; } public string MethodName { get; } public IDictionary Hits { get; } - public int IncrementRef() - { - return Interlocked.Increment(ref _refCount); - } - public int DecrementRef() - { - return Interlocked.Decrement(ref _refCount); - } - public void RecordHit(int id) { - lock (_lock) + if (Hits.TryGetValue(id, out var count)) { - if (Hits.TryGetValue(id, out var count)) - { - Hits[id] = count + 1; - } - else - { - Hits[id] = 1; - } + Hits[id] = count + 1; + } + else + { + Hits[id] = 1; } } @@ -83,21 +74,28 @@ public static IEnumerable MergeDuplicates(IEnumerable so )).ToArray(); } + public int EnterMethod() + { + return Interlocked.Increment(ref _methodCount); + } + + public int ExitMethod() + { + return Interlocked.Decrement(ref _methodCount); + } + public void Serialize(Stream stream) { - lock (_lock) + using (var binaryWriter = new BinaryWriter(stream, Encoding.UTF8, true)) { - using (var binaryWriter = new BinaryWriter(stream, Encoding.UTF8, true)) + binaryWriter.Write(ClassName); + binaryWriter.Write(MethodName); + binaryWriter.Write(AssemblyName); + binaryWriter.Write(Hits.Count); + foreach (var hitedInstruction in Hits) { - binaryWriter.Write(ClassName); - binaryWriter.Write(MethodName); - binaryWriter.Write(AssemblyName); - binaryWriter.Write(Hits.Count); - foreach (var hitedInstruction in Hits) - { - binaryWriter.Write(hitedInstruction.Key); - binaryWriter.Write(hitedInstruction.Value); - } + binaryWriter.Write(hitedInstruction.Key); + binaryWriter.Write(hitedInstruction.Value); } } } diff --git a/src/MiniCover.HitServices/MethodScope.cs b/src/MiniCover.HitServices/MethodScope.cs index 440f65f..6dbf5a7 100644 --- a/src/MiniCover.HitServices/MethodScope.cs +++ b/src/MiniCover.HitServices/MethodScope.cs @@ -7,7 +7,7 @@ public class MethodScope : IDisposable { private readonly HitContext _hitContext; private readonly string _hitsPath; - private readonly bool _createdHitContext; + private readonly bool _isEntryMethod; public MethodScope( string hitsPath, @@ -20,38 +20,54 @@ public class MethodScope : IDisposable if (_hitContext == null) { _hitContext = new HitContext(assemblyName, className, methodName); - _createdHitContext = true; + _isEntryMethod = true; HitContext.Current = _hitContext; } _hitsPath = hitsPath; - _hitContext.IncrementRef(); + + lock (_hitContext) + { + _hitContext.EnterMethod(); + } } public void Hit(int id) { - _hitContext.RecordHit(id); + lock (_hitContext) + { + _hitContext.RecordHit(id); + } } public void Dispose() { - if (_hitContext.DecrementRef() == 0) - SaveHitContext(); - - if (_createdHitContext) + if (_isEntryMethod) HitContext.Current = null; + + lock (_hitContext) + { + if (_hitContext.ExitMethod() == 0) + SaveHitContext(); + } } private void SaveHitContext() { - Directory.CreateDirectory(_hitsPath); + lock (_hitContext) + { + if (_hitContext.Hits.Count == 0) + return; - var fileName = Path.Combine(_hitsPath, $"{Guid.NewGuid()}.hits"); + Directory.CreateDirectory(_hitsPath); - using (var fileStream = File.Open(fileName, FileMode.OpenOrCreate)) - { - _hitContext.Serialize(fileStream); - fileStream.Flush(); + var fileName = Path.Combine(_hitsPath, $"{_hitContext.Id}.hits"); + + using (var fileStream = File.Open(fileName, FileMode.Create)) + { + _hitContext.Serialize(fileStream); + fileStream.Flush(); + } } } } diff --git a/tests/MiniCover.HitServices.UnitTests/HitContextTests.cs b/tests/MiniCover.HitServices.UnitTests/HitContextTests.cs index c48a69d..3e0c7f3 100644 --- a/tests/MiniCover.HitServices.UnitTests/HitContextTests.cs +++ b/tests/MiniCover.HitServices.UnitTests/HitContextTests.cs @@ -35,4 +35,4 @@ public void BinarySerializationShouldWork() } } } -} \ No newline at end of file +} diff --git a/tests/MiniCover.UnitTests/Instrumentation/BaseTest.cs b/tests/MiniCover.UnitTests/Instrumentation/BaseTest.cs index 27e1d58..30448dd 100644 --- a/tests/MiniCover.UnitTests/Instrumentation/BaseTest.cs +++ b/tests/MiniCover.UnitTests/Instrumentation/BaseTest.cs @@ -68,6 +68,7 @@ public void Test() var functionalTestMethod = instrumentedTestType.GetMethod(nameof(FunctionalTest)); HitContext.Current = new HitContext("Assembly", "Class", "Method"); + HitContext.Current.EnterMethod(); var instrumentedTest = Activator.CreateInstance(instrumentedTestType); functionalTestMethod.Invoke(instrumentedTest, new object[0]);