Giter Site home page Giter Site logo

stevegilham / altcover Goto Github PK

View Code? Open in Web Editor NEW
486.0 12.0 16.0 19.29 MB

Cross-platform coverage gathering and processing tool set for dotnet/.Net Framework and Mono

License: MIT License

F# 88.32% C# 4.93% XSLT 1.49% PowerShell 2.46% HTML 2.80%
mono code-coverage dotnet-framework dotnet-core testing cross-platform powershell-module powershell coverage dotnet

altcover's Introduction

Dashboard

Steve's github stats Top Langs

Main project

ReadMe Card

Tools for the tool builder

ReadMe Card ReadMe Card ReadMe Card ReadMe Card

Socials

Mastodon Follow

Twitter Follow

Blog

Photos

Profile image via diffuse-the-rest

altcover's People

Contributors

dependabot[bot] avatar ffmathy avatar imgbotapp avatar jasongin avatar stevegilham avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

altcover's Issues

Ternary operators, code optimization, and branch coverage

In Release mode, (or with optimizations enabled), the function Gendarme.``detect ternary pattern`` does not detect ternary patterns in methods because the sequence of instructions differs from the non-optimized version.

Additionally, the injected code only appears once for a method with a single ternary statement, so it does not capture the possible branches, and hence the branch coverage is incorrectly reported as 0 in these cases.

This also softly implies that altcover will differ between release and debug in other cases.

I'm wondering if altcover is only intended to run in debug mode? And if not, how difficult would it be to provide a patch? (Perhaps it's not feasible.)

typeFilter not working as expected

I am trying to instrument a net core 2.0 project. I am running version 3.0.475 on a Windows host. This is the command I am running:

$ dotnet path\to\AltCover.dll -i=.\bin\Debug\netcoreapp2.0 -t=Program;Startup --save --opencover

Every time I execute the command, the next error appears:

    ERROR *** Instrumentation phase failed
    Specified argument was out of the range of valid values.
    Parameter name: target
    Details written to path\to\__Saved\AltCover-2018-05-21--11-52-12.log

These are the contents of the log file:

System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values.
Parameter name: target
   at Mono.Cecil.Cil.ILProcessor.InsertBefore(Instruction target, Instruction instruction)
   at AltCover.Instrument.InsertVisit(Instruction instruction, ILProcessor methodWorker, MethodReference recordingMethodRef, String moduleId, Int32 point) in C:\projects\altcover\AltCover\Instrument.fs:line 335
   at AltCover.Instrument.VisitBranchPoint$cont@431(Context state, GoTo branch, Unit unitVar) in C:\projects\altcover\AltCover\Instrument.fs:line 453
   at AltCover.Instrument.VisitBranchPoint(Context state, GoTo branch) in C:\projects\altcover\AltCover\Instrument.fs:line 486
   at AltCover.Instrument.InstrumentationVisitorWrapper(FSharpFunc`2 core, Context state, Node node) in C:\projects\altcover\AltCover\Instrument.fs:line 611
   at [email protected](T node) in C:\projects\altcover\AltCover\Visitor.fs:line 567
   at Microsoft.FSharp.Primitives.Basics.List.mapToFreshConsTail[a,b](FSharpList`1 cons, FSharpFunc`2 f, FSharpList`1 x)
   at Microsoft.FSharp.Primitives.Basics.List.map[T,TResult](FSharpFunc`2 mapping, FSharpList`1 x)
   at Microsoft.FSharp.Collections.SeqModule.Fold[T,TState](FSharpFunc`2 folder, TState state, IEnumerable`1 source)
   at AltCover.Visitor.Visit(FSharpList`1 visitors, IEnumerable`1 assemblies) in C:\projects\altcover\AltCover\Visitor.fs:line 554
   at [email protected](Unit unitVar0) in C:\projects\altcover\AltCover\AltCover.fs:line 344
   at AltCover.CommandLine.doPathOperation[a](FSharpFunc`2 f, a defaultValue, Boolean store) in C:\projects\altcover\AltCover\CommandLine.fs:line 127
ActualValue =
<null>
ParamName =
"target"
Data =
seq []
InnerException =
<null>
TargetSite =
Void InsertBefore(Mono.Cecil.Cil.Instruction, Mono.Cecil.Cil.Instruction)
HelpLink =
<null>
Source =
"Mono.Cecil"
HResult =
-2146233086

Note: When I remove the semicolon and just add one type, the command works fine


Edit: The Startup type is the one generating the error. When I only add -t=Startup, the command fails with the same error.

Multiple frameworks

When trying to do multiple frameworks like so

   <AltCover.Prepare 
      InputDirectory="$(OutputPath)/netcoreapp2.0"  
      OutputDirectory="$(OutputPath)/netcoreapp2.0/__Saved$([System.DateTime]::UtcNow.ToString().Replace(':','-').Replace('/','-').Replace(' ','+'))" 
      XmlReport="$(OutputPath)/netcoreapp2.0/_Reports/MSBuildTest.xml"
      CallContext="@(CallContext)"
      />
    <AltCover.Prepare 
      InputDirectory="$(OutputPath)/net461"  
      OutputDirectory="$(OutputPath)/net461/__Saved$([System.DateTime]::UtcNow.ToString().Replace(':','-').Replace('/','-').Replace(' ','+'))" 
      XmlReport="$(OutputPath)/net461/_Reports/MSBuildTest.xml"
      CallContext="@(CallContext)"
      />

or with msbuild batching

    <ItemGroup>
      <_TargetFramework Include="$(TargetFrameworks)" />
    </ItemGroup>
    <AltCover.Prepare 
      InputDirectory="$(OutputPath)/%(_TargetFramework.Identity)"  
      OutputDirectory="$(OutputPath)/%(_TargetFramework.Identity)/__Saved$([System.DateTime]::UtcNow.ToString().Replace(':','-').Replace('/','-').Replace(' ','+'))" 
      XmlReport="$(OutputPath)/%(_TargetFramework.Identity)/_Reports/MSBuildTest.xml"
      CallContext="@(CallContext)"
      /> 

I get an error message telling me specify this only once

Creating folder /Users/myuser/Documents/GitHub/classLibTemplate/Content/tests/MyLib.Tests/bin/Debug/netcoreapp2.0/__Saved4-15-18+9-58-00+PM
  Saving files to /Users/myuser/Documents/GitHub/classLibTemplate/Content/tests/MyLib.Tests/bin/Debug/netcoreapp2.0/__Saved4-15-18+9-58-00+PM
  Instrumenting files in /Users/myuser/Documents/GitHub/classLibTemplate/Content/tests/MyLib.Tests/bin/Debug/netcoreapp2.0
     => /Users/myuser/Documents/GitHub/classLibTemplate/Content/tests/MyLib.Tests/bin/Debug/netcoreapp2.0/__Saved4-15-18+9-58-00+PM/MyLib.dll
     => /Users/myuser/Documents/GitHub/classLibTemplate/Content/tests/MyLib.Tests/bin/Debug/netcoreapp2.0/__Saved4-15-18+9-58-00+PM/MyLib.Tests.dll

  Coverage Report: /Users/myuser/Documents/GitHub/classLibTemplate/Content/tests/MyLib.Tests/bin/Debug/netcoreapp2.0/_Reports/MSBuildTest.xml


      /Users/myuser/Documents/GitHub/classLibTemplate/Content/tests/MyLib.Tests/bin/Debug/netcoreapp2.0/MyLib.dll
                  <=  MyLib, Version=0.1.0.0, Culture=neutral, PublicKeyToken=null
      /Users/myuser/Documents/GitHub/classLibTemplate/Content/tests/MyLib.Tests/bin/Debug/netcoreapp2.0/MyLib.Tests.dll
                  <=  MyLib.Tests, Version=0.1.0.0, Culture=neutral, PublicKeyToken=null
/Users/myuser/Documents/GitHub/classLibTemplate/Content/tests/MyLib.Tests/Directory.Build.targets(29,5): error : --save : specify this only once [/Users/myuser/Documents/GitHub/classLibTemplate/Content/tests/MyLib.Tests/MyLib.Tests.fsproj]
/Users/myuser/Documents/GitHub/classLibTemplate/Content/tests/MyLib.Tests/Directory.Build.targets(29,5): error : --inplace : specify this only once [/Users/myuser/Documents/GitHub/classLibTemplate/Content/tests/MyLib.Tests/MyLib.Tests.fsproj]
/Users/myuser/Documents/GitHub/classLibTemplate/Content/tests/MyLib.Tests/Directory.Build.targets(29,5): error : --opencover : specify this only once [/Users/myuser/Documents/GitHub/classLibTemplate/Content/tests/MyLib.Tests/MyLib.Tests.fsproj]
/Users/myuser/Documents/GitHub/classLibTemplate/Content/tests/MyLib.Tests/Directory.Build.targets(29,5): error : --xmlReport : specify this only once [/Users/myuser/Documents/GitHub/classLibTemplate/Content/tests/MyLib.Tests/MyLib.Tests.fsproj]
/Users/myuser/Documents/GitHub/classLibTemplate/Content/tests/MyLib.Tests/Directory.Build.targets(29,5): error : --outputDirectory : specify this only once [/Users/myuser/Documents/GitHub/classLibTemplate/Content/tests/MyLib.Tests/MyLib.Tests.fsproj]
/Users/myuser/Documents/GitHub/classLibTemplate/Content/tests/MyLib.Tests/Directory.Build.targets(29,5): error : --inputDirectory : specify this only once [/Users/myuser/Documents/GitHub/classLibTemplate/Content/tests/MyLib.Tests/MyLib.Tests.fsproj]

What do I need to do to support multiple frameworks?

Thanks!!

Codecov.io can't process generated reports

When attempting to upload a coverage report generated by altcover to Codecov.io, codecov accepts the file and appears to consume it, but fails with an error message on the service, claiming that no files were found in the report.

I'm unsure if this is an issue with Codecov's parsing engine, or if the format that Altcover generates is doing something funny along the line. I've reported the issue to Codecov as well (codecov/support#479), and I've included what logs I could gather.

codecov.log
coverage.xml.txt
travis-log (1).txt

Provide a use case for a web application and describe better the role of the "runner"

I have instrumented a web application (with the --opencover flag) however while the cover.xml file has been correctly created the results obtained weren't meaningful at all.
I have used an application compiled in release mode with symbols enabled ( so I had the pdb for the release assemblies). I have not used the runner mode. Is there any catch that must be known about collecting coverage for web applications?
Also the role and purpose of the runner is not clear. Reading trough the documentation I had the impression that it's only used to translate the raw coverage data collected at a previous step into a more elaborated one ( such as open cover xml).

AltCover fails when tests target net471

AltCover fails on a new empty xunit test project (dotnet new xunit) that only has AltCover added and targetFramework changed to net471:

> dotnet test /p:AltCover=true
Build started, please wait...
Build completed.

Test run for d:\git\test\bin\Debug\net471\test.dll(.NETFramework,Version=v4.7.1)
Microsoft (R) Test Execution Command Line Tool Version 15.7.0
Copyright (c) Microsoft Corporation.  All rights reserved.

Starting test execution, please wait...
[xUnit.net 00:00:00.5293235]     test.UnitTest1.Test1 [FAIL]
Failed   test.UnitTest1.Test1
Error Message:
 System.IO.FileLoadException : Could not load file or assembly 'AltCover.Recorder.g, Version=3.5.0.0, Culture=neutral, PublicKeyToken=c02b1a9f5b7cade8' or one of its dependencies. Strong name signature could not be verified.  The assembly may have been tampered with, or it was delay signed but not fully signed with the correct private key. (Exception from HRESULT: 0x80131045)
Stack Trace:
   at test.UnitTest1..ctor()

Total tests: 1. Passed: 0. Failed: 1. Skipped: 0.
Test Run Failed.
Test execution time: 1,0335 Seconds

Unable to cover .NET 4.0 web application

I am trying to use altcover for the coverage measurement of a .NET 4.0 web application deployed on IIS 8.5.

Therefore, I execute the following command:
altcover --save --inplace -i $(OutputDir)

where $(OutputDir) is the bin folder of the desired website.

Besides the instrumend assemblies, this results in two additional files in the bin folder: AltCover.Recorder.g.dll and AltCover.Recorder.g.pdb.

After restarting the w3wp.exe, the website fails with a runtime error.

The Event Viewer retrieves the following error:

Exception information: 
Exception type: ConfigurationErrorsException 
Exception message: Could not load file or assembly 'AltCover.Recorder.g, Version=4.0.0.0, Culture=neutral, PublicKeyToken=4ebffcaabf10ce6a' or one of its dependencies. Strong name signature could not be verified. The assembly may have been tampered with, or it was delay signed but not fully signed with the correct private key. (Exception from HRESULT: 0x80131045)
at System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective)
at System.Web.Configuration.CompilationSection.LoadAllAssembliesFromAppDomainBinDirectory()
at System.Web.Configuration.CompilationSection.LoadAssembly(AssemblyInfo ai)
at System.Web.Compilation.BuildManager.GetReferencedAssemblies(CompilationSection compConfig)
at System.Web.Compilation.BuildManager.GetPreStartInitMethodsFromReferencedAssemblies()
at System.Web.Compilation.BuildManager.CallPreStartInitMethods(String preStartInitListPath, Boolean& isRefAssemblyLoaded)
at System.Web.Compilation.BuildManager.ExecutePreAppStart()
at System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters, PolicyLevel policyLevel, Exception appDomainCreationException)

What am I doing wrong? Is my approach possible/correct?
I should also add that modifying the web application before the build is not possible.

Thank you!

AltCover.Prepare msbuild task throws System.InvalidOperationException when instrumenting some assemblies

Version: altcover.3.0.466.nupkg

: error MSB4018: The "AltCover.Prepare" task failed unexpectedly. []
: error MSB4018: System.InvalidOperationException: tried to skip The input sequence has an insufficient number of elements. 1 past the end of the seq []
: error MSB4018:    at [email protected](IEnumerable`1& next) []
: error MSB4018:    at Microsoft.FSharp.Core.CompilerServices.GeneratedSequenceBase`1.MoveNextImpl() []
: error MSB4018:    at Microsoft.FSharp.Collections.Internal.IEnumerator.map@74.DoMoveNext(b& curr) []
: error MSB4018:    at Microsoft.FSharp.Collections.Internal.IEnumerator.MapEnumerator`1.System-Collections-IEnumerator-MoveNext() []
: error MSB4018:    at Microsoft.FSharp.Collections.Internal.IEnumerator.next@187[T](FSharpFunc`2 f, IEnumerator`1 e, FSharpRef`1 started, Unit unitVar0) []
: error MSB4018:    at Microsoft.FSharp.Collections.Internal.IEnumerator.filter@182.System-Collections-IEnumerator-MoveNext() []
: error MSB4018:    at Microsoft.FSharp.Collections.Internal.IEnumerator.map@74.DoMoveNext(b& curr) []
: error MSB4018:    at Microsoft.FSharp.Collections.Internal.IEnumerator.MapEnumerator`1.System-Collections-IEnumerator-MoveNext() []
: error MSB4018:    at Microsoft.FSharp.Core.CompilerServices.RuntimeHelpers.takeOuter@274[T,TResult](ConcatEnumerator`2 x, Unit unitVar0) []
: error MSB4018:    at Microsoft.FSharp.Collections.Internal.IEnumerator.mapi@88.DoMoveNext(b& curr) []
: error MSB4018:    at Microsoft.FSharp.Collections.Internal.IEnumerator.MapEnumerator`1.System-Collections-IEnumerator-MoveNext() []
: error MSB4018:    at Microsoft.FSharp.Collections.Internal.IEnumerator.choose@165.System-Collections-IEnumerator-MoveNext() []
: error MSB4018:    at Microsoft.FSharp.Collections.SeqModule.ToList[T](IEnumerable`1 source) []
: error MSB4018:    at AltCover.Visitor.VisitMethod(MethodDefinition m, Inspect included) in C:\projects\altcover\AltCover\Visitor.fs:line 451 []
: error MSB4018:    at AltCover.Visitor.BuildSequence(Node node) in C:\projects\altcover\AltCover\Visitor.fs:line 497 []
: error MSB4018:    at Microsoft.FSharp.Collections.Internal.IEnumerator.map@74.DoMoveNext(b& curr) []
: error MSB4018:    at Microsoft.FSharp.Collections.Internal.IEnumerator.MapEnumerator`1.System-Collections-IEnumerator-MoveNext() []
: error MSB4018:    at Microsoft.FSharp.Core.CompilerServices.RuntimeHelpers.takeOuter@274[T,TResult](ConcatEnumerator`2 x, Unit unitVar0) []
: error MSB4018:    at Microsoft.FSharp.Core.CompilerServices.RuntimeHelpers.takeInner@267[T,TResult](ConcatEnumerator`2 x, Unit unitVar0) []
: error MSB4018:    at Microsoft.FSharp.Core.CompilerServices.RuntimeHelpers.takeInner@267[T,TResult](ConcatEnumerator`2 x, Unit unitVar0) []
: error MSB4018:    at Microsoft.FSharp.Core.CompilerServices.RuntimeHelpers.takeInner@267[T,TResult](ConcatEnumerator`2 x, Unit unitVar0) []
: error MSB4018:    at Microsoft.FSharp.Core.CompilerServices.RuntimeHelpers.takeInner@267[T,TResult](ConcatEnumerator`2 x, Unit unitVar0) []
: error MSB4018:    at Microsoft.FSharp.Core.CompilerServices.RuntimeHelpers.takeInner@267[T,TResult](ConcatEnumerator`2 x, Unit unitVar0) []
: error MSB4018:    at Microsoft.FSharp.Core.CompilerServices.RuntimeHelpers.takeInner@267[T,TResult](ConcatEnumerator`2 x, Unit unitVar0) []
: error MSB4018:    at Microsoft.FSharp.Core.CompilerServices.RuntimeHelpers.takeInner@267[T,TResult](ConcatEnumerator`2 x, Unit unitVar0) []
: error MSB4018:    at Microsoft.FSharp.Collections.SeqModule.Fold[T,TState](FSharpFunc`2 folder, TState state, IEnumerable`1 source) []
: error MSB4018:    at AltCover.Visitor.Visit(FSharpList`1 visitors, IEnumerable`1 assemblies) in C:\projects\altcover\AltCover\Visitor.fs:line 510 []
: error MSB4018:    at [email protected](Unit unitVar0) in C:\projects\altcover\AltCover\AltCover.fs:line 344 []
: error MSB4018:    at AltCover.CommandLine.doPathOperation[a](FSharpFunc`2 f, a defaultValue, Boolean store) in C:\projects\altcover\AltCover\CommandLine.fs:line 131 []
: error MSB4018:    at AltCover.Main.DoInstrumentation(String[] arguments) in C:\projects\altcover\AltCover\AltCover.fs:line 330 []
: error MSB4018:    at AltCover.Prepare.Execute() in C:\projects\altcover\AltCover\Tasks.fs:line 50 []
: error MSB4018:    at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute() []
: error MSB4018:    at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__25.MoveNext() []```

AltCoverThreshold inconsistency

I'm trying to use the AltCoverThreshold parameter to help with making sure my code has enough coverage however, it seems to be inconsistent with what ReportGenerator says.

I've set it to 10 percent but it claims to be not be that high.

 error : Coverage percentage achieved is 1% below the threshold of 10%. [/private/var/folders/14/mp4bnvkn3fq5mqcgqscm5c040000gn/T/foowhat/tests/foowhat.Tests/foowhat.Tests.fsproj]

However ReportGenerator says it's 100% covered.

screen shot 2018-08-24 at 5 13 21 pm

foowhat.zip

build.fsx line 104 is where I'm setting it.

Build instructions don't work.

Hi,
I have tried to build the solution from a clean machine VM with the latest version of VS 2017.
The solution doesn't build and it's very difficult to understand the root cause for somebody that doesn't have F# specific experience.
The restore command installs FSharp.Core 4.3.4. as first thing however it's unclear whether this is the source of error. If this is the case then I believe that the bootstrap instructions should be made more explicit by adding the necessary instructions for installing FSharp.Core 2.3.0.0.
I attache here the logs of the restore, fake run setup and fake run build commands.
restore.log.txt
fake run setup.txt
fake run build.txt

Failed to resolve assembly while trying to run AltCover on .NET Core

Hi there,
I am trying to run AltCover on .NET Core 2.0 project (SDK 2.1.4), and I got the following error, either running it via dotnet test /p:AltCover=true or via directly calling AltCover.dll.

Mono.Cecil.AssemblyResolutionException: Failed to resolve assembly: 'Microsoft.Extensions.DependencyInjection.Abstractions, Version=2.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'
   at Mono.Cecil.BaseAssemblyResolver.Resolve(AssemblyNameReference name, ReaderParameters parameters)
   at Mono.Cecil.DefaultAssemblyResolver.Resolve(AssemblyNameReference name)
   at Mono.Cecil.MetadataResolver.Resolve(TypeReference type)
   at Mono.Cecil.Mixin.CheckedResolve(TypeReference self)
   at Mono.Cecil.MetadataBuilder.GetConstantType(TypeReference constant_type, Object constant)
   at Mono.Cecil.MetadataBuilder.AddConstant(IConstantProvider owner, TypeReference type)
   at Mono.Cecil.MetadataBuilder.AddParameter(UInt16 sequence, ParameterDefinition parameter, ParamTable table)
   at Mono.Cecil.MetadataBuilder.AddParameters(MethodDefinition method)
   at Mono.Cecil.MetadataBuilder.AddMethod(MethodDefinition method)
   at Mono.Cecil.MetadataBuilder.AddMethods(TypeDefinition type)
   at Mono.Cecil.MetadataBuilder.AddType(TypeDefinition type)
   at Mono.Cecil.MetadataBuilder.AddTypes()
   at Mono.Cecil.MetadataBuilder.BuildTypes()
   at Mono.Cecil.MetadataBuilder.BuildModule()
   at Mono.Cecil.MetadataBuilder.BuildMetadata()
   at Mono.Cecil.ModuleWriter.<>c.<BuildMetadata>b__2_0(MetadataBuilder builder, MetadataReader _)
   at Mono.Cecil.ModuleDefinition.Read[TItem,TRet](TItem item, Func`3 read)
   at Mono.Cecil.ModuleWriter.BuildMetadata(ModuleDefinition module, MetadataBuilder metadata)
   at Mono.Cecil.ModuleWriter.Write(ModuleDefinition module, Disposable`1 stream, WriterParameters parameters)
   at Mono.Cecil.ModuleWriter.WriteModule(ModuleDefinition module, Disposable`1 stream, WriterParameters parameters)
   at Mono.Cecil.ModuleDefinition.Write(Stream stream, WriterParameters parameters)
   at AltCover.Instrument.WriteAssembly(AssemblyDefinition assembly, String path) in C:\projects\altcover\AltCover\Instrument.fs:line 282
   at AltCover.Instrument.VisitAfterAssembly[a](a state, AssemblyDefinition assembly) in C:\projects\altcover\AltCover\Instrument.fs:line 570
   at AltCover.Instrument.InstrumentationVisitorWrapper(FSharpFunc`2 core, Context state, Node node) in C:\projects\altcover\AltCover\Instrument.fs:line 611
   at [email protected](T node) in C:\projects\altcover\AltCover\Visitor.fs:line 576
   at Microsoft.FSharp.Primitives.Basics.List.mapToFreshConsTail[a,b](FSharpList`1 cons, FSharpFunc`2 f, FSharpList`1 x)
   at Microsoft.FSharp.Primitives.Basics.List.map[T,TResult](FSharpFunc`2 mapping, FSharpList`1 x)
   at Microsoft.FSharp.Collections.SeqModule.Fold[T,TState](FSharpFunc`2 folder, TState state, IEnumerable`1 source)
   at AltCover.Visitor.Visit(FSharpList`1 visitors, IEnumerable`1 assemblies) in C:\projects\altcover\AltCover\Visitor.fs:line 563
   at [email protected](Unit unitVar0) in C:\projects\altcover\AltCover\AltCover.fs:line 344
   at AltCover.CommandLine.doPathOperation[a](FSharpFunc`2 f, a defaultValue, Boolean store) in C:\projects\altcover\AltCover\CommandLine.fs:line 133
AssemblyReference = 
Microsoft.Extensions.DependencyInjection.Abstractions, Version=2.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60
FileName = 
<null>
FusionLog = 
<null>
Data = 
seq []
InnerException = 
<null>
TargetSite = 
Mono.Cecil.AssemblyDefinition Resolve(Mono.Cecil.AssemblyNameReference, Mono.Cecil.ReaderParameters)
HelpLink = 
<null>
Source = 
"Mono.Cecil"
HResult = 
-2147024894

Is there any fix/workaround for that?

Tests using FsUnit fail with InvalidProgramException (tail.call ...)

FsUnitTyped.TopLevelOperators.shouldEqual is tailcall'd so the instrumented code is invalid.

namespace Tests

open NUnit.Framework
open FsUnitTyped

module Tested =
    let add6To n =
        n + 6

open Tested

module Problematic =
    [<Test>]
    let ``Using FsUnit`` () =
        add6To 3 |> shouldEqual 9

when instrumented using

packages\altcover\tools\net45\AltCover.exe  /i=Tests\bin\Debug\net471 /o=Tests\bin\Debug\net471\Instrumented /c=[Test]
packages\altcover\tools\net45\AltCover.exe  runner /r=Tests\bin\Debug\net471\Instrumented /x=packages\NUnit.ConsoleRunner\tools\nunit3-console.exe -- Tests\bin\Debug\net471\Instrumented\Tests.dll 

Creates an instrumented body

.class public abstract sealed auto ansi 
  Tests.Problematic
    extends [mscorlib]System.Object
{
  .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) 
    = (01 00 07 00 00 00 00 00 ) // ........
    // int32(7) // 0x00000007

  .method public static void 
    'Using FsUnit'() cil managed 
  {
    .custom instance void [nunit.framework]NUnit.Framework.TestAttribute::.ctor() 
      = (01 00 00 00 )
    .maxstack 2

    // [21 7 - 21 23]
    IL_0000: ldc.i4       1 // 0x00000001
    IL_0005: call         void [AltCover.Recorder.g]AltCover.Recorder.Instance::Push(int32)
    .try
    {

      // [24 9 - 24 66]
      IL_000a: ldstr        "5ad74b52-3811-9909-a745-0383524bd75a"
      IL_000f: ldc.i4.0     
      IL_0010: call         void [AltCover.Recorder.g]AltCover.Recorder.Instance::Visit(string, int32)

      // [25 9 - 25 64]
      IL_0015: ldc.i4.s     9 // 0x09
      IL_0017: ldc.i4.3     
      IL_0018: call         int32 Tests.Tested::add6To(int32)
      IL_001d: tail.        
      IL_001f: call         void [FsUnit.NUnit]FsUnitTyped.TopLevelOperators::shouldEqual<int32>(!!0/*int32*/, !!0/*int32*/)

      IL_0024: leave        IL_002f
    } // end of .try
    finally
    {

      // [29 9 - 29 23]
      IL_0029: call         void [AltCover.Recorder.g]AltCover.Recorder.Instance::Pop()

      IL_002e: endfinally   
    } // end of finally
    IL_002f: ret          

  } // end of method Problematic::'Using FsUnit'
} // end of class Tests.Problematic

Which PEVerify reports as:
Tests.Problematic::Using FsUnit][offset 0x0000001D] The tail.call (or calli or callvirt) instruction cannot be used to transfer control out of a try, filter, catch, or finally block.

Test with OpenCover format and nested loop causes InvalidProgramException (StackDepthDiffers depending on path)

The following test:

module Tests

open NUnit.Framework

type Size(width : int, height : int) =
    struct
        member __.Width  = width
        member __.Height = height
    end

type Thing(size : Size) =
    member val Height = size.Height
    member val Width  = size.Width
    member __.Rectangle (x, y) =
        System.Drawing.Rectangle(x, y, x, y)

[<Test>]
let ``Thing Rectangle`` () = 
    let g = Thing (Size(11, 21))
    for row = 0 to g.Height do
        for col = 0 to g.Width do
            Assert.AreEqual(System.Drawing.Rectangle(col, row, col, row), g.Rectangle(col, row))

When instrumented with

packages\altcover\tools\net45\AltCover.exe  /i=Tests\bin\Debug\net471 /o=Tests\bin\Debug\net471\Instrumented /c=[Test] /opencover
packages\altcover\tools\net45\AltCover.exe  runner /r=Tests\bin\Debug\net471\Instrumented /x=packages\NUnit.ConsoleRunner\tools\nunit3-console.exe -- Tests\bin\Debug\net471\Instrumented\Tests.dll  

Produces the MSIL:

 .method public static void 
    'Thing Rectangle'() cil managed 
  {
    .custom instance void [nunit.framework]NUnit.Framework.TestAttribute::.ctor() 
      = (01 00 00 00 )
    .maxstack 4
    .locals init (
      [0] class Tests/Thing V_0,
      [1] int32 V_1,
      [2] int32 V_2,
      [3] int32 V_3,
      [4] int32 V_4
    )

    IL_0000: ldc.i4       1 // 0x00000001
    IL_0005: call         void [AltCover.Recorder.g]AltCover.Recorder.Instance::Push(int32)
    .try
    {
      IL_000a: ldstr        "7B-14-7C-65-00-66-5A-8D-2F-5A-25-9E-7F-9A-0C-20-CB-16-D6-2D"
      IL_000f: ldc.i4.5     
      IL_0010: call         void [AltCover.Recorder.g]AltCover.Recorder.Instance::Visit(string, int32)
      IL_0015: ldc.i4.s     11 // 0x0b
      IL_0017: ldc.i4.s     21 // 0x15
      IL_0019: newobj       instance void Tests/Size::.ctor(int32, int32)
      IL_001e: newobj       instance void Tests/Thing::.ctor(valuetype Tests/Size)
      IL_0023: stloc.0      // V_0
      IL_0024: ldstr        "7B-14-7C-65-00-66-5A-8D-2F-5A-25-9E-7F-9A-0C-20-CB-16-D6-2D"
      IL_0029: ldc.i4.4     
      IL_002a: call         void [AltCover.Recorder.g]AltCover.Recorder.Instance::Visit(string, int32)
      IL_002f: ldc.i4.0     
      IL_0030: stloc.2      // V_2
      IL_0031: ldloc.0      // V_0
      IL_0032: callvirt     instance int32 Tests/Thing::get_Height()
      IL_0037: stloc.1      // V_1
      IL_0038: ldloc.1      // V_1
      IL_0039: ldloc.2      // V_2
      IL_003a: blt.s        IL_003e
      IL_003c: br.s         IL_0052
      IL_003e: ldstr        "7B-14-7C-65-00-66-5A-8D-2F-5A-25-9E-7F-9A-0C-20-CB-16-D6-2D"
      IL_0043: ldc.i4       -2147483647 // 0x80000001
      IL_0048: call         void [AltCover.Recorder.g]AltCover.Recorder.Instance::Visit(string, int32)
      IL_004d: br           IL_0138
      IL_0052: ldstr        "7B-14-7C-65-00-66-5A-8D-2F-5A-25-9E-7F-9A-0C-20-CB-16-D6-2D"
      IL_0057: ldc.i4       -2147483648 // 0x80000000
      IL_005c: call         void [AltCover.Recorder.g]AltCover.Recorder.Instance::Visit(string, int32)
      // start of loop, entry point: IL_0061
        IL_0061: ldstr        "7B-14-7C-65-00-66-5A-8D-2F-5A-25-9E-7F-9A-0C-20-CB-16-D6-2D"
        IL_0066: ldc.i4.3     
        IL_0067: call         void [AltCover.Recorder.g]AltCover.Recorder.Instance::Visit(string, int32)
        IL_006c: ldc.i4.0     
        IL_006d: stloc.s      V_4
        IL_006f: ldloc.0      // V_0
        IL_0070: callvirt     instance int32 Tests/Thing::get_Width()
        IL_0075: stloc.3      // V_3
        IL_0076: ldloc.3      // V_3
        IL_0077: ldloc.s      V_4
        IL_0079: blt.s        IL_007d
        IL_007b: br.s         IL_0091
        IL_007d: ldstr        "7B-14-7C-65-00-66-5A-8D-2F-5A-25-9E-7F-9A-0C-20-CB-16-D6-2D"
        IL_0082: ldc.i4       -2147483645 // 0x80000003
        IL_0087: call         void [AltCover.Recorder.g]AltCover.Recorder.Instance::Visit(string, int32)
        IL_008c: br           IL_0108
        IL_0091: ldstr        "7B-14-7C-65-00-66-5A-8D-2F-5A-25-9E-7F-9A-0C-20-CB-16-D6-2D"
        IL_0096: ldc.i4       -2147483646 // 0x80000002
        IL_009b: call         void [AltCover.Recorder.g]AltCover.Recorder.Instance::Visit(string, int32)
        // start of loop, entry point: IL_00a0
          IL_00a0: ldstr        "7B-14-7C-65-00-66-5A-8D-2F-5A-25-9E-7F-9A-0C-20-CB-16-D6-2D"
          IL_00a5: ldc.i4.2     
          IL_00a6: call         void [AltCover.Recorder.g]AltCover.Recorder.Instance::Visit(string, int32)
          IL_00ab: ldloc.s      V_4
          IL_00ad: ldloc.2      // V_2
          IL_00ae: ldloc.s      V_4
          IL_00b0: ldloc.2      // V_2
          IL_00b1: newobj       instance void [System.Drawing]System.Drawing.Rectangle::.ctor(int32, int32, int32, int32)
          IL_00b6: box          [System.Drawing]System.Drawing.Rectangle
          IL_00bb: ldloc.0      // V_0
          IL_00bc: ldloc.s      V_4
          IL_00be: ldloc.2      // V_2
          IL_00bf: callvirt     instance valuetype [System.Drawing]System.Drawing.Rectangle Tests/Thing::Rectangle(int32, int32)
          IL_00c4: box          [System.Drawing]System.Drawing.Rectangle
          IL_00c9: call         void [nunit.framework]NUnit.Framework.Assert::AreEqual(object, object)
          IL_00ce: ldloc.s      V_4
          IL_00d0: ldc.i4.1     
          IL_00d1: add          
          IL_00d2: stloc.s      V_4
          IL_00d4: ldstr        "7B-14-7C-65-00-66-5A-8D-2F-5A-25-9E-7F-9A-0C-20-CB-16-D6-2D"
          IL_00d9: ldc.i4.1     
          IL_00da: call         void [AltCover.Recorder.g]AltCover.Recorder.Instance::Visit(string, int32)
          IL_00df: ldloc.s      V_4
          IL_00e1: ldloc.3      // V_3
          IL_00e2: ldc.i4.1     
          IL_00e3: add          
          IL_00e4: bne.un.s     IL_00e8
          IL_00e6: br.s         IL_00f9
          IL_00e8: ldstr        "7B-14-7C-65-00-66-5A-8D-2F-5A-25-9E-7F-9A-0C-20-CB-16-D6-2D"
          IL_00ed: ldc.i4       -2147483643 // 0x80000005
          IL_00f2: call         void [AltCover.Recorder.g]AltCover.Recorder.Instance::Visit(string, int32)
          IL_00f7: br.s         IL_00a0
        // end of loop
        IL_00f9: ldstr        "7B-14-7C-65-00-66-5A-8D-2F-5A-25-9E-7F-9A-0C-20-CB-16-D6-2D"
        IL_00fe: ldc.i4       -2147483644 // 0x80000004
        IL_0103: call         void [AltCover.Recorder.g]AltCover.Recorder.Instance::Visit(string, int32)
        IL_0108: ldloc.2      // V_2
        IL_0109: ldc.i4.1     
        IL_010a: add          
        IL_010b: stloc.2      // V_2
        IL_010c: ldstr        "7B-14-7C-65-00-66-5A-8D-2F-5A-25-9E-7F-9A-0C-20-CB-16-D6-2D"
        IL_0111: ldc.i4.0     
        IL_0112: call         void [AltCover.Recorder.g]AltCover.Recorder.Instance::Visit(string, int32)
        IL_0117: ldloc.2      // V_2
        IL_0118: ldloc.1      // V_1
        IL_0119: ldc.i4.1     
        IL_011a: add          
        IL_011b: bne.un.s     IL_011f
        IL_011d: br.s         IL_0133
        IL_011f: ldstr        "7B-14-7C-65-00-66-5A-8D-2F-5A-25-9E-7F-9A-0C-20-CB-16-D6-2D"
        IL_0124: ldc.i4       -2147483641 // 0x80000007
        IL_0129: call         void [AltCover.Recorder.g]AltCover.Recorder.Instance::Visit(string, int32)
        IL_012e: br           IL_0061
      // end of loop
      IL_0133: ldstr        "7B-14-7C-65-00-66-5A-8D-2F-5A-25-9E-7F-9A-0C-20-CB-16-D6-2D"
      IL_0138: ldc.i4       -2147483642 // 0x80000006
      IL_013d: call         void [AltCover.Recorder.g]AltCover.Recorder.Instance::Visit(string, int32)
      IL_0142: leave        IL_014d
    } // end of .try
    finally
    {
      IL_0147: call         void [AltCover.Recorder.g]AltCover.Recorder.Instance::Pop()
      IL_014c: endfinally   
    } // end of finally
    IL_014d: ret          

  } // end of method Tests::'Thing Rectangle'
} // end of class Tests

Which makes PEVerify say

Tests::Thing Rectangle][offset 0x0000004D] Stack depth differs depending on path.

'A total of 0 visits recorded' on Linux ARM runner

Hi!
Cannot get coverage information on ARM cpu-powered Linux CI runner machine because of getting 'A total of 0 visits recorded' message while the real coverage of my project is ~80%.
Can also notice, that running 'dotnet test' with AltCover switch on normal x86 machine produces coverage data.

dotnet SDK version: 2.1.500
OS: Debian Jessie softfloat

Steps to reproduce:

  1. Download any project from github, that is covered by unit-tests to your's ARM board (Raspberry Pi for example, can be done in emulated environment?) ;
  2. Add altcover .nuget package to test project;
  3. Run 'dotnet test /p:AltCover=true'.

Can provide additional info on your request. Thanks in advance!

Issue generating coverage with AttributeFilter

I have many test projects in my solution so I am using AltCover as my coverage calculator for each project and ReportGenerator (https://github.com/danielpalme/ReportGenerator) as my coverage aggregator. When I run

$  dotnet test /p:AltCover=true /p:AltCoverAttributeFilter=ExcludeFromCodeCoverage
$ dotnet reportgenerator "-reports:coverage.xml" "-targetdir:coverage" "-reporttypes:Html;Xml"

on any project, the coverage file is generated but ReportGenerator can't parse it (it throws an Object Reference exception). When I remove the attribute filter, everything works fine.

I am using the latest version of altcover and reportgenerator-cli
I have reported the issue both here and in danielpalme/ReportGenerator#146

coverage.xml and multiple target frameworks

I'm updating to the latest version of Altcover in MiniScaffold TheAngryByrd/MiniScaffold#94.

The issue I'm seeing is when running dotnet test /p:AltCover=true and having multiple target frameworks such as <TargetFrameworks>netcoreapp2.1;netcoreapp2.0;net461</TargetFrameworks>, it will constantly wipe over the coverage.xml.

The options I can think of are

  1. Put the coverage.xml in the output folder bin/Release/netcoreapp2.1
  2. Template the coverage.xml to something like coverage.netcoreapp2.1.xml
  3. Somehow merge the results

Thanks for the help!

ASP.NET MVC 4.5 Razor template compilation error - CS0433

I'm trying to collect code coverage using AltCover v4.0.659 of my ASP.NET MVC app targeting .NET v4.5 using "Instrument now, then gather coverage from a running application" scenario. I run AltCover.exe from net45 folder in nupkg using following command arguments: --save --opencover --single + some filters to skip all 3rd party assemblies. Assembly weaving stage was successful. But when I try to run my web app, I see following error during Razor template compilation by ASP.NET:

Compilation Error
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately. 

Compiler Error Message: CS0433: The type 'System.Tuple' exists in both 'c:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files\root\631ec658\1bdf8089\assembly\dl3\0cf7232c\7de5f968_e993d401\AltCover.Recorder.g.DLL' and 'c:\Windows\Microsoft.NET\Framework64\v4.0.30319\mscorlib.dll'

.NET reflector says that AltCover.Recorder.g.DLL really contains type System.Tuple<> (and others from System.* namespace) and not referencing System.Core. I'm not an expert in F#, but I suppose it's because it's targeting .NET v3.5 framework instead of .NET 4+.
Is there any known workaround for this problem?

Unhandled Exception thrown when no arguments are passed, should show help instead

Version: altcover.3.0.466.nupkg


Unhandled Exception: System.ArgumentException: The input sequence was empty.
Parameter name: source
   at Microsoft.FSharp.Collections.SeqModule.Head[T](IEnumerable`1 source)
   at AltCover.Main.Main(String[] arguments) in C:\projects\altcover\AltCover\AltCover.fs:line 352```

BTW: Love the tool 

Working with Expecto Test Runner

I'm just opening here as initial starting point. We can move to other repo's based on if they need PR's.

So I was trying to mimic coverlet's msbuild targets as much as I could like https://github.com/TheAngryByrd/ExpectoAltCover-Test/blob/master/tests/Directory.Build.targets. However when I go to run dotnet test I'm getting an issue with the Expecto Test adapter

An exception occurred while invoking executor 'executor://yolodev/expecto': Symbols were found but are not matching the assembly

This error seems to come from inside Mono.Cecil. https://github.com/jbevain/cecil/blob/master/Mono.Cecil/ModuleDefinition.cs#L1077

Repo: https://github.com/TheAngryByrd/ExpectoAltCover-Test

just run dotnet test in the tests folder to see the behavior.

Do you have any input as to what needs to change to make this work?

Thanks!

cc: @Alxandr @haf @AnthonyLloyd

Instrumentation hangs when the yield keyword is used in a property that's part of an explicit interface implementation

I've encountered a really peculiar bug. If altcover is told to instrument a .dll that contains a property with a getter that returns an IEnumerable and uses the yield keyword anywhere in its body AND that property is part of an explicit interface implementation then altcover will get permanently stuck in an infinite loop and never finish the instrumentation process. It will use up to 25% of my CPU and never give an error. The instrumented AltCoverRepro2.dll seems to be generated during this process, but the XML file, AltCover.Recorder.g.dll, and AltCover.Recorder.g.pdb are not generated which prevents me from using a runner.

This is the command I used:

H:\Programe\altcover\tools\net45\AltCover.exe --opencover -s=nunit -t=System. -s=Microsoft -i=F:\GitRepos\AltCoverRepro2\AltCoverRepro2\bin\Debug -o=F:\GitRepos\AltCoverRepro2\AltCoverRepro2\bin\Debug\instr -x=F:\GitRepos\AltCoverRepro2\AltCoverRepro2\bin\Debug\coverage.xml

As soon as the offending yield usage is stubbed out with a throw new NotImplementedException() then the exact same command will successfully instrument the project. The three previously missing files are successfully generated. The project is also instrumented successfully if the property is switched from being explicit to being public.

I have attached a repro project at the bottom but will include a reproduction inline here as well. It's also worth noting that I'm on Windows 10 Pro and this is being compiled with .NET Framework / Roslyn. I opted for this mode of operation because I wanted to be doing similar steps to what I'd do on Linux with Mono, since I'd like to move to developing on Linux.

public class EnumerableGetterExplicit_DoesNotWork<T, K>
    : IReadOnlyDictionary<T, K>
{
    private int counter;

    // Replace the content of this property's getter with
    // "=> throw new NotImplementedException();"
    // and the whole project is instrumented successfully.
    // As long as this getter is left alone, instrumentation enters an
    // infinite loop.
    IEnumerable<K> IReadOnlyDictionary<T, K>.Values
    {
        get { yield break; }
    }

    // This works as is. It seems the problem doesn't appear unless the
    // property is specifically part of an explicit interface
    // implementation.
    public IEnumerable<K> ValuesWorks
    {
        get
        {
            yield return default(K);
            yield break;
        }
    }

    // This works as is. As long as there isn't a yield used inside this
    // getter then the property won't cause any trouble to the
    // instrumentation process.
    IEnumerable<T> IReadOnlyDictionary<T, K>.Keys
    {
        get { counter++; throw new NotImplementedException(); }
        // The counter variable is just a blind hedge against the compiler
        // doing something weird. It might optimize the getter out somehow
        // if the body of the getter was just the exception throw.
    }

    K IReadOnlyDictionary<T, K>.this[T key] => throw new NotImplementedException();
    int IReadOnlyCollection<KeyValuePair<T, K>>.Count => throw new NotImplementedException();
    bool IReadOnlyDictionary<T, K>.ContainsKey(T key) => throw new NotImplementedException();
    IEnumerator<KeyValuePair<T, K>> IEnumerable<KeyValuePair<T, K>>.GetEnumerator() => throw new NotImplementedException();
    IEnumerator IEnumerable.GetEnumerator() => throw new NotImplementedException();
    bool IReadOnlyDictionary<T, K>.TryGetValue(T key, out K value) => throw new NotImplementedException();
}

AltCoverRepro_ExplicitGetterYieldInfiniteLoop2.zip

I've struggled literally all day to get this work until I managed to condense it down to this one bizarre case. My actual project is much larger than this but I managed to confirm this is the problem by stubbing out all occurrences of the keyword yield in explicit interface members - this made altcover successfully instrument the project right away. Usage of strong name keys did not seem to matter. My guess is that whatever code generates the IL necessary for instrumentation is somehow failing to parse this specific case.

OpenCover format: Missing feature 'Tracked methods'

Thanks for this great tool. I started replacing OpenCover with altcover in my projects.

OpenCover has an advanced feature that is currently not supported by altcover.
Maybe you have a chance to add it with acceptable effort.

TrackedMethods

With the command line parameter -coverbytest:* coverage is recorded by test method. That allows you to evaluate which line has been covered by which test (see usage guide).

Instead of:

<SequencePoint vc="8" uspid="249" ordinal="0" offset="0" sl="45" sc="46" el="45" ec="51" bec="0" bev="0" fileid="21" />

The output of OpenCover contains an additional element TrackedMethodRefs which contains the number of hits per TrackedMethodRef in the attribute vc.

<SequencePoint vc="8" uspid="249" ordinal="0" offset="0" sl="45" sc="46" el="45" ec="51" bec="0" bev="0" fileid="21">
  <TrackedMethodRefs>
    <TrackedMethodRef uid="1" vc="4" />
    <TrackedMethodRef uid="2" vc="4" />
  </TrackedMethodRefs>
</SequencePoint>

The <module> contains a list of all relevant test methods:

<TrackedMethods>
   <TrackedMethod uid="1" token="100663342" name="System.Void Test.Program::CSharp_ExecuteTest1()" strategy="MSTestTest" />
   <TrackedMethod uid="2" token="100663343" name="System.Void Test.Program::CSharp_ExecuteTest2()" strategy="MSTestTest" />
</TrackedMethods>

Here's a complete sample coverage report: OpenCoverWithTrackedMethods.zip
Here's a good starting point for the implementation in OpenCover.

How to provide arguments to the executable of the runner

When using executable in the runner with Altcover to run the instrumented tests i.e.

Altcover runner --executable=nunit3-console.exe

I am not able to pass arguments to nunit3-console.exe and no test in being executed (just getting the help menu of the nunit console runner)

Current workaround is to generate the full command in a run-tests.cmd file with content:

path\to\nunit3-console.exe path\to\test-assembly.dll

and using run-tests.cmd as the executable

This method however doesn't seem to work for linux when I try the same command (executed by mono) inside a run-tests.sh shell script, I get the error:

Command line : '/opt/atlassian/pipelines/agent/build/run-tests.sh '
System.ComponentModel.Win32Exception (0x80004005): ApplicationName='/opt/atlassian/pipelines/agent/build/run-tests.sh', CommandLine='', CurrentDirectory='/opt/atlassian/pipelines/agent/build/TestsCombined/bin/Release/__Instrumented', Native error= Access denied
  at System.Diagnostics.Process.StartWithCreateProcess (System.Diagnostics.ProcessStartInfo startInfo) [0x002dc] in <b3d41b23de534128a4f18a6e1312f79c>:0 
  at System.Diagnostics.Process.Start () [0x0003a] in <b3d41b23de534128a4f18a6e1312f79c>:0 
  at (wrapper remoting-invoke-with-check) System.Diagnostics.Process.Start()
  at AltCover.CommandLine.Launch (System.String cmd, System.String args, System.String toDirectory) [0x000f0] in <19b84ce907604472a3ab9ae78ef53f56>:0 
  at AltCover.CommandLine.ProcessTrailingArguments (Microsoft.FSharp.Collections.FSharpList`1[T] rest, System.IO.DirectoryInfo toInfo) [0x00037] in <19b84ce907604472a3ab9ae78ef53f56>:0 
  at [email protected] (Microsoft.FSharp.Core.Unit unitVar0) [0x00015] in <19b84ce907604472a3ab9ae78ef53f56>:0 
  at AltCover.CommandLine.doPathOperation[a] (Microsoft.FSharp.Core.FSharpFunc`2[T,TResult] f, a defaultValue, System.Boolean store) [0x000a1] in <19b84ce907604472a3ab9ae78ef53f56>:0 
  at AltCover.Runner.PayloadBase (Microsoft.FSharp.Collections.FSharpList`1[T] rest) [0x00006] in <19b84ce907604472a3ab9ae78ef53f56>:0 
  at [email protected] (Microsoft.FSharp.Collections.FSharpList`1[T] rest) [0x00000] in <19b84ce907604472a3ab9ae78ef53f56>:0 
  at AltCover.Runner.RunProcess (System.String report, Microsoft.FSharp.Core.FSharpFunc`2[T,TResult] payload, Microsoft.FSharp.Collections.FSharpList`1[T] args) [0x00017] in <19b84ce907604472a3ab9ae78ef53f56>:0 
  at AltCover.Runner.MonitorBase (System.Collections.Generic.ICollection`1[T] hits, System.String report, Microsoft.FSharp.Core.FSharpFunc`2[T,TResult] payload, Microsoft.FSharp.Collections.FSharpList`1[T] args) [0x00011] in <19b84ce907604472a3ab9ae78ef53f56>:0 
  at [email protected] (System.Collections.Generic.ICollection`1[T] hits, System.String report, Microsoft.FSharp.Core.FSharpFunc`2[T,TResult] payload, Microsoft.FSharp.Collections.FSharpList`1[T] args) [0x00000] in <19b84ce907604472a3ab9ae78ef53f56>:0 
  at [email protected] (Microsoft.FSharp.Core.Unit unitVar0) [0x00058] in <19b84ce907604472a3ab9ae78ef53f56>:0 
  at AltCover.CommandLine.doPathOperation[a] (Microsoft.FSharp.Core.FSharpFunc`2[T,TResult] f, a defaultValue, System.Boolean store) [0x000a1] in <19b84ce907604472a3ab9ae78ef53f56>:0 
  at AltCover.Runner.DoCoverage[a] (System.String[] arguments, a options1) [0x00051] in <19b84ce907604472a3ab9ae78ef53f56>:0 
  at AltCover.Main.Main (System.String[] arguments) [0x00035] in <19b84ce907604472a3ab9ae78ef53f56>:0 
  at [email protected] (System.String[] arguments) [0x00000] in <19b84ce907604472a3ab9ae78ef53f56>:0 

I am using Full .NET Framework with a solution targeting net461 trying to get coverage results from bibucket pipelines (linux based)

Any ideas?

Question about merging results

Since dotnetcore's behavior when testing entire solution is trying also test non testing projects and then whole process is evaluated as non successful at least on linux, then I need to run test on one by one testing project separately I need to somehow then merge altcover results into one xml file, is that possible?

nunit3-console with altcover 0% coverage

For some strange reason i get 0% coverage with altocover (monocov reports 90%). Am i missing something? Any hints would be greatly appreciated.

altcover.5.0.663
MacOSX 17.7.0.0
CLR Version: 4.0.30319.42000

Step 1: create pcl and nunit test dll

nuget restore
/Library/Frameworks/Mono.framework/Versions/Current/Commands/msbuild TESTReport.sln /t:TESTReportPCL /p:Configuration="Debug" /p:BuildProjectReferences=false /m  /verbosity:m
/Library/Frameworks/Mono.framework/Versions/Current/Commands/msbuild TESTReport.sln /t:NUnit_TESTReport /p:BuildProjectReferences=false /m  /verbosity:m

Step 2

cd NUnit.TESTReport/bin/Debug/

Step 3

mono ../../../packages/altcover.5.0.663/tools/net45/AltCover.exe --opencover --linecover  --assemblyFilter=.+.TESTReport+ --assemblyFilter=TESTReport+ --assemblyExcludeFilter=nunit+ --assemblyExcludeFilter=.+\.Tests --assemblyExcludeFilter=NUnit+ --assemblyExcludeFilter=AltCover.+ --assemblyExcludeFilter=Xamarin+ --assemblyExcludeFilter=SQL+ --assemblyExcludeFilter=System+ --assemblyExcludeFilter=Plugin+ --assemblyExcludeFilter=PCLExt+ --assemblyExcludeFilter=FFImage+ --assemblyExcludeFilter=Newtonsoft+  --outputDirectory=__Instrumented

Output:

Instrumenting files from /Users/jenkins/workspace/TestClientForEditors/NUnit.TestReport/bin/Debug
Writing files to /Users/jenkins/workspace/TestClientForEditors/NUnit.TestReport/bin/Debug/__Instrumented
   => /Users/jenkins/workspace/TestClientForEditors/NUnit.TestReport/bin/Debug/TestReportPCL.dll
   => /Users/jenkins/workspace/TestClientForEditors/NUnit.TestReport/bin/Debug/FFImageLoading.Forms.dll
   => /Users/jenkins/workspace/TestClientForEditors/NUnit.TestReport/bin/Debug/FFImageLoading.dll
   => /Users/jenkins/workspace/TestClientForEditors/NUnit.TestReport/bin/Debug/NUnit.TestReport.dll
   => /Users/jenkins/workspace/TestClientForEditors/NUnit.TestReport/bin/Debug/Newtonsoft.Json.dll
   => /Users/jenkins/workspace/TestClientForEditors/NUnit.TestReport/bin/Debug/Plugin.Connectivity.Abstractions.dll
   => /Users/jenkins/workspace/TestClientForEditors/NUnit.TestReport/bin/Debug/Plugin.Connectivity.dll
   => /Users/jenkins/workspace/TestClientForEditors/NUnit.TestReport/bin/Debug/SQLite-net.dll
   => /Users/jenkins/workspace/TestClientForEditors/NUnit.TestReport/bin/Debug/SQLiteNetExtensions.dll
   => /Users/jenkins/workspace/TestClientForEditors/NUnit.TestReport/bin/Debug/Xamarin.Forms.Core.dll
   => /Users/jenkins/workspace/TestClientForEditors/NUnit.TestReport/bin/Debug/Xamarin.Forms.Xaml.dll
   => /Users/jenkins/workspace/TestClientForEditors/NUnit.TestReport/bin/Debug/nunit.framework.dll

Coverage Report: /Users/jenkins/workspace/TestClientForEditors/NUnit.TestReport/bin/Debug/coverage.xml


    /Users/jenkins/workspace/TestClientForEditors/NUnit.TestReport/bin/Debug/__Instrumented/nunit.framework.dll
                <=  nunit.framework, Version=3.11.0.0, Culture=neutral, PublicKeyToken=null
    /Users/jenkins/workspace/TestClientForEditors/NUnit.TestReport/bin/Debug/__Instrumented/Xamarin.Forms.Core.dll
                <=  Xamarin.Forms.Core, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null
    /Users/jenkins/workspace/TestClientForEditors/NUnit.TestReport/bin/Debug/__Instrumented/SQLite-net.dll
                <=  SQLite-net, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
    /Users/jenkins/workspace/TestClientForEditors/NUnit.TestReport/bin/Debug/__Instrumented/Plugin.Connectivity.Abstractions.dll
                <=  Plugin.Connectivity.Abstractions, Version=3.2.0.0, Culture=neutral, PublicKeyToken=null
    /Users/jenkins/workspace/TestClientForEditors/NUnit.TestReport/bin/Debug/__Instrumented/Newtonsoft.Json.dll
                <=  Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=null
    /Users/jenkins/workspace/TestClientForEditors/NUnit.TestReport/bin/Debug/__Instrumented/FFImageLoading.dll
                <=  FFImageLoading, Version=2.4.4.859, Culture=neutral, PublicKeyToken=null
    /Users/jenkins/workspace/TestClientForEditors/NUnit.TestReport/bin/Debug/__Instrumented/Xamarin.Forms.Xaml.dll
                <=  Xamarin.Forms.Xaml, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null
    /Users/jenkins/workspace/TestClientForEditors/NUnit.TestReport/bin/Debug/__Instrumented/SQLiteNetExtensions.dll
                <=  SQLiteNetExtensions, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
    /Users/jenkins/workspace/TestClientForEditors/NUnit.TestReport/bin/Debug/__Instrumented/Plugin.Connectivity.dll
                <=  Plugin.Connectivity, Version=3.2.0.0, Culture=neutral, PublicKeyToken=null
    /Users/jenkins/workspace/TestClientForEditors/NUnit.TestReport/bin/Debug/__Instrumented/FFImageLoading.Forms.dll
                <=  FFImageLoading.Forms, Version=2.4.4.859, Culture=neutral, PublicKeyToken=null
    /Users/jenkins/workspace/TestClientForEditors/NUnit.TestReport/bin/Debug/__Instrumented/TestReportPCL.dll
                <=  TestReportPCL, Version=1.0.6941.28281, Culture=neutral, PublicKeyToken=null
    /Users/jenkins/workspace/TestClientForEditors/NUnit.TestReport/bin/Debug/__Instrumented/NUnit.TestReport.dll
                <=  NUnit.TestReport, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null

Generated files:

AltCover.Recorder.g.dll
TestReportPCL.dll
TestReportPCL.dll.config
TestReportPCL.pdb
CarouselView.FormsPlugin.Abstractions.dll
coverage.xml
FFImageLoading.dll
FFImageLoading.Forms.dll
FFImageLoading.Forms.pdb
FFImageLoading.Forms.xml
FFImageLoading.pdb
FFImageLoading.Platform.dll
FFImageLoading.Platform.xml
FFImageLoading.Transformations.dll
FFImageLoading.Transformations.xml
FFImageLoading.xml
I18NPortable.dll
libe_sqlite3.dylib
Newtonsoft.Json.dll
Newtonsoft.Json.pdb
Newtonsoft.Json.xml
NUnit.TestReport.dll
NUnit.TestReport.dll.config
NUnit.TestReport.pdb
nunit.framework.dll
nunit.framework.pdb
nunit.framework.xml
PCLExt.FileStorage.Abstractions.dll
PCLExt.FileStorage.Abstractions.xml
PCLExt.FileStorage.dll
PCLExt.FileStorage.xml
Plugin.Connectivity.Abstractions.dll
Plugin.Connectivity.Abstractions.pdb
Plugin.Connectivity.Abstractions.xml
Plugin.Connectivity.dll
Plugin.Connectivity.pdb
Plugin.Connectivity.xml
Plugin.Media.dll
Plugin.Media.xml
Plugin.Permissions.dll
Plugin.Permissions.xml
SignaturePad.Forms.dll
SignaturePad.Forms.xml
SQLite-net.dll
SQLite-net.pdb
SQLite-net.xml
SQLiteNetExtensions.dll
SQLiteNetExtensions.pdb
SQLitePCLRaw.batteries_green.dll
SQLitePCLRaw.batteries_v2.dll
SQLitePCLRaw.core.dll
SQLitePCLRaw.provider.e_sqlite3.dll
System.Data.Common.dll
System.Diagnostics.StackTrace.dll
System.Diagnostics.Tracing.dll
System.Globalization.Extensions.dll
System.IO.Compression.dll
System.IO.dll
System.Linq.dll
System.Linq.Expressions.dll
System.Net.Http.dll
System.Net.Sockets.dll
System.Reflection.dll
System.Runtime.dll
System.Runtime.Extensions.dll
System.Runtime.InteropServices.dll
System.Runtime.InteropServices.RuntimeInformation.dll
System.Runtime.Serialization.Primitives.dll
System.Security.Cryptography.Algorithms.dll
System.Security.Cryptography.Encoding.dll
System.Security.Cryptography.Primitives.dll
System.Security.Cryptography.X509Certificates.dll
System.Security.SecureString.dll
System.Text.RegularExpressions.dll
System.Threading.Overlapped.dll
System.Xml.ReaderWriter.dll
System.Xml.XPath.XDocument.dll
Xamarin.Forms.Core.dll
Xamarin.Forms.Core.pdb
Xamarin.Forms.Core.xml
Xamarin.Forms.Platform.dll
Xamarin.Forms.Xaml.dll
Xamarin.Forms.Xaml.pdb
Xamarin.Forms.Xaml.xml

coverage xml looks fine

Step 4:

mono ../../../packages/altcover.5.0.663/tools/net45/AltCover.exe Runner --recorderDirectory __Instrumented  --executable ../../../packages/NUnit.ConsoleRunner.3.9.0/tools/nunit3-console.exe   -- ../../../NUnit.TESTReport/bin/Debug/NUnit.TESTReport.dll

Output:

Beginning run...
Command line : '../../../packages/NUnit.ConsoleRunner.3.9.0/tools/nunit3-console.exe ../../../NUnit.TestReport/bin/Debug/NUnit.TestReport.dll'
NUnit Console Runner 3.9.0
Copyright (c) 2018 Charlie Poole, Rob Prouse
Runtime Environment
   OS Version: MacOSX 17.7.0.0 
  CLR Version: 4.0.30319.42000
Test Files
    ../../../NUnit.TestReport/bin/Debug/NUnit.TestReport.dll
Run Settings
    DisposeRunners: True
    WorkDirectory: /Users/jenkins/workspace/TestClientForEditors/NUnit.TestReport/bin/Debug
    ImageRuntimeVersion: 4.0.30319
    ImageTargetFrameworkName: .NETFramework,Version=v4.7.1
    ImageRequiresX86: False
    ImageRequiresDefaultAppDomainAssemblyResolver: False
    NumberOfTestWorkers: 8
Test Run Summary
  Overall result: Passed
  Test Count: 99, Passed: 99, Failed: 0, Warnings: 0, Inconclusive: 0, Skipped: 0
  Start time: 2019-01-03 08:34:47Z
    End time: 2019-01-03 08:34:56Z
    Duration: 9.515 seconds
Results (nunit3) saved as TestResult.xml
Getting results...
A total of 0 visits recorded
Coverage statistics flushing took 0.13 seconds
Visited Classes 0 of 39 (0)
Visited Methods 0 of 71 (0)
Visited Points 0 of 649 (0)
Visited Branches 0 of 71 (0)
==== Alternative Results (includes all methods including those without corresponding source) ====
Alternative Visited Classes 0 of 46 (0)
Alternative Visited Methods 0 of 119 (0)

Common Language Runtime detected an invalid program

I'm try to use altcover (globaltool 3.5.569) to generate coverage for my netcore 2.1 app, using "Instrument now, test later, runner mode"

But half of my tests failed with the error message "System.InvalidProgramException : Common Language Runtime detected an invalid program."

And then the report can still be generated (reportgenerator) but is partial.

I use theses commands :

altcover --opencover -o=__saved_cart --inplace -c=0 "-c=[Fact]" -x cart.opencover.xml -i api-cart/src/Cart.Tests/bin/Debug/netcoreapp2.1/ --fileFilter=Reference.cs
altcover Runner -x dotnet -r api-cart/src/Cart.Tests/bin/Debug/netcoreapp2.1 -- test api-cart/src/Cart.Tests --no-build --no-restore
Nombre total de tests : 57. Rรฉussis : 34. Non rรฉussis : 23. Ignorรฉs : 0.
ร‰chec de la sรฉrie de tests.
Durรฉe d'exรฉcution des tests : 12,4410 Secondes
Getting results...
... /Users/xxx/xxx/cart.opencover.xml.0.acv (32 175b)
13 420 visits recorded in 00:00:00.1235400 (108 629 visits/sec)
A total of 13 420 visits recorded
Coverage statistics flushing took 0,513 seconds
Visited Classes 33 of 332 (9.94)
Visited Methods 125 of 689 (18.14)
Visited Points 510 of 4748 (10.74)
Visited Branches 60 of 1512 (3.97)
==== Alternative Results (includes all methods including those without corresponding source) ====
Alternative Visited Classes 33 of 449 (7.35)
Alternative Visited Methods 125 of 1135 (11.01)

If a use the nuget package AltCover everything seem ok.

Way to filter out compiler generated classes

I try to filter compiler generated classes like those used to deconstruct dictionary key/value pairs in a foreach loop. If I use the /p:AltCoverAttributeFilter=CompilerGenerated parameter, it seems that the async methods are removed too (although AsyncStateMachinAttribute doesn't inherit from CompilerGeneratedAttribute).
What should I do?

Generating cobertura output doesnt seem to be possible like the wiki suggests

I tried running dotnet test /p:AltCover=true /p:CopyLocalLockFileAssemblies=true /p:Cobertura=coverage.xml however the Cobertura parameter is ignored and the default open cover format is still generated.

When I manually build, inject the altcover IL and the collect using the runner it is able to output to cobertura format.

ArgumentNullException when running nunit3-console

It looks like the DataReceivedEventArgs.Data property can be null. The sample code in msdn has a String.IsNullOrEmpty test.

The stack trace was:

Unhandled Exception: System.ArgumentNullException: Parameter "message" cannot be null.
   at Microsoft.Build.Shared.ErrorUtilities.VerifyThrowArgumentNull(Object parameter, String parameterName, String resourceName)
   at Microsoft.Build.Utilities.TaskLoggingHelper.LogMessage(MessageImportance importance, String message, Object[] messageArgs)
   at AltCover.Collect.Message(String x)
   at <StartupCode$AltCover>[email protected](String arg00)
   at Microsoft.FSharp.Control.CommonExtensions.SubscribeToObservable@1741.System-IObserver`1-OnNext(T args)
   at Microsoft.FSharp.Core.CompilerServices.RuntimeHelpers.h@349.Invoke(Object _arg1, TArgs args)
   at [email protected](Object delegateArg0, DataReceivedEventArgs delegateArg1)
   at System.Diagnostics.Process.OutputReadNotifyUser(String data)
   at System.Diagnostics.AsyncStreamReader.FlushMessageQueue()
   at System.Diagnostics.AsyncStreamReader.ReadBuffer(IAsyncResult ar)
   at System.IO.Stream.ReadWriteTask.InvokeAsyncCallback(Object completedTask)
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.IO.Stream.ReadWriteTask.System.Threading.Tasks.ITaskCompletionAction.Invoke(Task completingTask)
   at System.Threading.Tasks.Task.FinishContinuations()
   at System.Threading.Tasks.Task.FinishStageThree()
   at System.Threading.Tasks.Task.FinishStageTwo()
   at System.Threading.Tasks.Task.Finish(Boolean bUserDelegateExecuted)
   at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot)
   at System.Threading.Tasks.Task.ExecuteEntry(Boolean bPreventDoubleExecution)
   at System.Threading.Tasks.Task.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem()
   at System.Threading.ThreadPoolWorkQueue.Dispatch()
   at System.Threading._ThreadPoolWaitCallback.PerformWaitCallback()

Unhandled Exception: System.ArgumentNullException: Parameter "message" cannot be null.
   at Microsoft.Build.Shared.ErrorUtilities.VerifyThrowArgumentNull(Object parameter, String parameterName, String resourceName)
   at Microsoft.Build.Utilities.TaskLoggingHelper.LogError(String subcategory, String errorCode, String helpKeyword, String file, Int32 lineNumber, Int32 columnNumber, Int32 endLineNumber, Int32 endColumnNumber, String message, Object[] messageArgs)
   at Microsoft.Build.Utilities.TaskLoggingHelper.LogError(String message, Object[] messageArgs)
   at <StartupCode$AltCover>[email protected](String arg00)
   at Microsoft.FSharp.Control.CommonExtensions.SubscribeToObservable@1741.System-IObserver`1-OnNext(T args)
   at Microsoft.FSharp.Core.CompilerServices.RuntimeHelpers.h@349.Invoke(Object _arg1, TArgs args)
   at [email protected](Object delegateArg0, DataReceivedEventArgs delegateArg1)
   at System.Diagnostics.Process.ErrorReadNotifyUser(String data)
   at System.Diagnostics.AsyncStreamReader.FlushMessageQueue()
   at System.Diagnostics.AsyncStreamReader.ReadBuffer(IAsyncResult ar)
   at System.IO.Stream.ReadWriteTask.InvokeAsyncCallback(Object completedTask)
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.IO.Stream.ReadWriteTask.System.Threading.Tasks.ITaskCompletionAction.Invoke(Task completingTask)
   at System.Threading.Tasks.Task.FinishContinuations()
   at System.Threading.Tasks.Task.FinishStageThree()
   at System.Threading.Tasks.Task.FinishStageTwo()
   at System.Threading.Tasks.Task.Finish(Boolean bUserDelegateExecuted)
   at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot)
   at System.Threading.Tasks.Task.ExecuteEntry(Boolean bPreventDoubleExecution)
   at System.Threading.Tasks.Task.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem()
   at System.Threading.ThreadPoolWorkQueue.Dispatch()
   at System.Threading._ThreadPoolWaitCallback.PerformWaitCallback()


Unable to Exclude Folders

Maybe I'm misreading the command line parameters and instructions, but its unclear if I'm able to call AltCover to completely ignore a subset of directories.

Calling from (based on instructions its regex so the .* should define wildcard path):
dotnet test -v n /p:AltCover=true /p:AltCoverMethodFilter=.\*/src/Data/Generated/.\*/.\*.cs

all files matching our generated code in src/Data/Generated still show up in the output report. The usage instructions could use some concrete examples of how to properly use these flags as I'm expecting it to take standard wildcard paths which doesn't seem to be the case.

OutOfMemoryException

I'm using altcover to cover my unit tests written with xUnit.
Sometimes it happens that I get an OutOfMemoryException when the coverage tool is generating the result file.
The PC hat 8GB RAM that should be sufficient.
The exception looks like this:
.....coverage.xml.0.acv (8.628.739b)

Unhandled Exception:
System.OutOfMemoryException: Insufficient memory to continue the execution of the program.
at (wrapper alloc) System.Object.AllocVector(intptr,intptr)
at System.Collections.Generic.List1[T].set_Capacity (System.Int32 value) <0x7fdffebcd190 + 0x00053> in <0f8aeac9d63d4b8aa575761bb4e65b79>:0 at System.Collections.Generic.List1[T].AddWithResize (T item) <0x7fdffebcd560 + 0x00063> in <0f8aeac9d63d4b8aa575761bb4e65b79>:0
at System.Collections.Generic.List1[T].Add (T item) <0x7fdffebcd510 + 0x00048> in <0f8aeac9d63d4b8aa575761bb4e65b79>:0 at AltCover.Runner.sink@432 (System.Collections.Generic.ICollection1[T] hits, System.IO.BinaryReader formatter, Microsoft.FSharp.Core.Unit unitVar0) [0x000d5] in :0
at [email protected] (System.String f) [0x00076] in :0
at Microsoft.FSharp.Collections.SeqModule.Iterate[T] (Microsoft.FSharp.Core.FSharpFunc2[T,TResult] action, System.Collections.Generic.IEnumerable1[T] source) [0x0002c] in <5b5a6cc1904cf4daa7450383c16c5a5b>:0
at AltCover.Runner.CollectResults (System.Collections.Generic.ICollection1[T] hits, System.String report) [0x00044] in <ff776df29b8d4500bb9107f1fcd3295d>:0 at AltCover.Runner.MonitorBase (System.Collections.Generic.ICollection1[T] hits, System.String report, Microsoft.FSharp.Core.FSharpFunc2[T,TResult] payload, Microsoft.FSharp.Collections.FSharpList1[T] args) [0x0001b] in :0
at [email protected] (System.Collections.Generic.ICollection1[T] hits, System.String report, Microsoft.FSharp.Core.FSharpFunc2[T,TResult] payload, Microsoft.FSharp.Collections.FSharpList1[T] args) [0x00000] in <ff776df29b8d4500bb9107f1fcd3295d>:0 at [email protected] (Microsoft.FSharp.Core.Unit unitVar0) [0x00058] in <ff776df29b8d4500bb9107f1fcd3295d>:0 at AltCover.CommandLine.doPathOperation[a] (Microsoft.FSharp.Core.FSharpFunc2[T,TResult] f, a defaultValue, System.Boolean store) [0x000a1] in :0
at AltCover.Runner.DoCoverage[a] (System.String[] arguments, a options1) [0x00051] in :0
at AltCover.Main.Main (System.String[] arguments) [0x00035] in :0
at [email protected] (System.String[] arguments) [0x00000] in :0
[ERROR] FATAL UNHANDLED EXCEPTION: System.OutOfMemoryException: Insufficient memory to continue the execution of the program.
at (wrapper alloc) System.Object.AllocVector(intptr,intptr)
at System.Collections.Generic.List1[T].set_Capacity (System.Int32 value) <0x7fdffebcd190 + 0x00053> in <0f8aeac9d63d4b8aa575761bb4e65b79>:0 at System.Collections.Generic.List1[T].AddWithResize (T item) <0x7fdffebcd560 + 0x00063> in <0f8aeac9d63d4b8aa575761bb4e65b79>:0
at System.Collections.Generic.List1[T].Add (T item) <0x7fdffebcd510 + 0x00048> in <0f8aeac9d63d4b8aa575761bb4e65b79>:0 at AltCover.Runner.sink@432 (System.Collections.Generic.ICollection1[T] hits, System.IO.BinaryReader formatter, Microsoft.FSharp.Core.Unit unitVar0) [0x000d5] in :0
at [email protected] (System.String f) [0x00076] in :0
at Microsoft.FSharp.Collections.SeqModule.Iterate[T] (Microsoft.FSharp.Core.FSharpFunc2[T,TResult] action, System.Collections.Generic.IEnumerable1[T] source) [0x0002c] in <5b5a6cc1904cf4daa7450383c16c5a5b>:0
at AltCover.Runner.CollectResults (System.Collections.Generic.ICollection1[T] hits, System.String report) [0x00044] in <ff776df29b8d4500bb9107f1fcd3295d>:0 at AltCover.Runner.MonitorBase (System.Collections.Generic.ICollection1[T] hits, System.String report, Microsoft.FSharp.Core.FSharpFunc2[T,TResult] payload, Microsoft.FSharp.Collections.FSharpList1[T] args) [0x0001b] in :0
at [email protected] (System.Collections.Generic.ICollection1[T] hits, System.String report, Microsoft.FSharp.Core.FSharpFunc2[T,TResult] payload, Microsoft.FSharp.Collections.FSharpList1[T] args) [0x00000] in <ff776df29b8d4500bb9107f1fcd3295d>:0 at [email protected] (Microsoft.FSharp.Core.Unit unitVar0) [0x00058] in <ff776df29b8d4500bb9107f1fcd3295d>:0 at AltCover.CommandLine.doPathOperation[a] (Microsoft.FSharp.Core.FSharpFunc2[T,TResult] f, a defaultValue, System.Boolean store) [0x000a1] in :0
at AltCover.Runner.DoCoverage[a] (System.String[] arguments, a options1) [0x00051] in :0
at AltCover.Main.Main (System.String[] arguments) [0x00035] in :0
at [email protected] (System.String[] arguments) [0x00000] in :0

Mono version used is:
mono --version
Mono JIT compiler version 5.16.0.220 (tarball Mon Nov 26 17:17:59 UTC 2018)
Copyright (C) 2002-2014 Novell, Inc, Xamarin Inc and Contributors. www.mono-project.com
TLS: __thread
SIGSEGV: altstack
Notifications: epoll
Architecture: amd64
Disabled: none
Misc: softdebug
Interpreter: yes
LLVM: yes(3.6.0svn-mono-/)
GC: sgen (concurrent by default)

OS is: Ubuntu 18.04

Unable to build on Linux

I'm currently attempting to build the latest Master branch on Linux (Mint 18.3). I have the Core SDK installed, as well as Mono with the FSharp tooling.

Everything works out up until the fake setup runs, at which point some form of version mismatch occurs and the restore operation fails.

jarl@jax ~/Programming/altcover $ dotnet fake run ./Build/setup.fsx
Could not find AppDataFolder, try to set the APPDATA environment variable. Using '/home/jarl/Programming/altcover/.paket' instead.
Could not find LocalApplicationData folder, try to set the 'LocalAppData' environment variable. Using '/home/jarl/Programming/altcover/.paket' instead
/usr/bin/mono --version
/usr/bin/dotnet  restore  ./Build/dotnet-nuget.csproj --packages "./packages"
  Restore completed in 40.56 ms for /home/jarl/Programming/altcover/Build/dotnet-nuget.csproj.
/usr/bin/mono --debug "/home/jarl/Programming/altcover/packages/nuget.commandline/4.5.1/tools/NuGet.exe" "restore" "/home/jarl/Programming/altcover/AltCover.sln" "-OutputDirectory" "/home/jarl/Programming/altcover/packages"
MSBuild auto-detection: using msbuild version '14.0' from '/usr/lib/mono/xbuild/14.0/bin'.
MSBUILD : warning MSB4010: The "*.tasks" files could not be successfully loaded from their expected location "/usr/lib/mono/xbuild/15.0/bin". Default tasks will not be available. Could not find a part of the path '/usr/lib/mono/xbuild/15.0/bin'. [/tmp/NuGetScratch/lielhzwp.zn4.nugetinputs.targets]
/tmp/NuGetScratch/b8k937yz.q15.nugetrestore.targets(219,5): error MSB4036: The "RemoveDuplicates" task was not found. Check the following: 1.) The name of the task in the project file is the same as the name of the task class. 2.) The task class is "public" and implements the Microsoft.Build.Framework.ITask interface. 3.) The task is correctly declared with <UsingTask> in the project file, or in the *.tasks files located in the "/usr/lib/mono/xbuild/15.0/bin" directory. [/tmp/NuGetScratch/lielhzwp.zn4.nugetinputs.targets]

WARNING: Error reading msbuild project information, ensure that your input solution or project file is valid. NETCore and UAP projects will be skipped, only packages.config files will be restored.
All packages listed in packages.config are already installed.

A fake.sh script is nonetheless generated. When ran, another error (assuming it is related to the above issue) prevents compilation.

jarl@jax ~/Programming/altcover $ chmod +x fake.sh 
jarl@jax ~/Programming/altcover $ ./fake.sh 
FsiEvaluationException:

Error: 
	
	/home/jarl/Programming/altcover/Build/actions.fsx(7,11): error FS0039: The namespace 'Core' is not defined.

I'm using Mono 5.10.0.118, and dotnet 2.1.3.

Test calling an inline assertion method fails with InvalidProgramException (jmp / exception into the middle of an instruction)

The test code

module Tests

open NUnit.Framework

let add6To n =
    n + 6

let inline shouldBeOdd x =
    if x % 2 = 0 then Assert.Fail "Not odd enough"

[<Test>]
let ``add6To3 should be odd`` () =
    add6To 3 |> shouldBeOdd

When instrumented with

packages\altcover\tools\net45\AltCover.exe  /i=Tests\bin\Debug\net471 /o=Tests\bin\Debug\net471\Instrumented /c=[Test]
packages\altcover\tools\net45\AltCover.exe  runner /r=Tests\bin\Debug\net471\Instrumented /x=packages\NUnit.ConsoleRunner\tools\nunit3-console.exe -- Tests\bin\Debug\net471\Instrumented\Tests.dll  

Produces the IL:

.method public static void 
    'add6To3 should be odd'() cil managed 
  {
    .custom instance void [nunit.framework]NUnit.Framework.TestAttribute::.ctor() 
      = (01 00 00 00 )
    .maxstack 2
    .locals init (
      [0] int32 V_0,
      [1] int32 V_1
    )

    IL_0000: ldc.i4       1 // 0x00000001
    IL_0005: call         void [AltCover.Recorder.g]AltCover.Recorder.Instance::Push(int32)
    .try
    {
      IL_000a: ldstr        "5ad7571b-3811-9909-a745-03831b57d75a"
      IL_000f: ldc.i4.3     
      IL_0010: call         void [AltCover.Recorder.g]AltCover.Recorder.Instance::Visit(string, int32)
      IL_0015: ldc.i4.3     
      IL_0016: call         int32 Tests::add6To(int32)
      IL_001b: stloc.0      // V_0
      IL_001c: ldloc.0      // V_0
      IL_001d: stloc.1      // V_1
      IL_001e: ldloc.1      // V_1
      IL_001f: ldc.i4.2     
      IL_0020: rem          
      IL_0021: brtrue.s     IL_0025
      IL_0023: br.s         IL_0027
      IL_0025: br.s         IL_0028
      IL_0027: ldstr        "Not odd enough"
      IL_002c: call         void [nunit.framework]NUnit.Framework.Assert::Fail(string)
      IL_0031: leave        IL_0041
      IL_0036: leave        IL_0041
    } // end of .try
    finally
    {
      IL_003b: call         void [AltCover.Recorder.g]AltCover.Recorder.Instance::Pop()
      IL_0040: endfinally   
    } // end of finally
    IL_0041: ret          

  } // end of method Tests::'add6To3 should be odd'

Which PEVerify reports as:
Tests::add6To3 should be odd][offset 0x00000025] jmp / exception into the middle of an instruction.

Support sampling or other ways to reduce coverage data collection

Currently, AltCover seems to collect data every time a given line in the code is visited. This slows down the coverage testing significantly, by several orders of magnitude โ€” especially when I only want to know whether each line of code was visited, not necessarily how often it was visited or which methods called the code in question.

Therefore, to reduce coverage testing time, AltCover should support statistical sampling and/or options for choosing the level of detail of data to collect.

Error generating coverage for net461 project ...

Hi,

I tried the following to get coverage for a net461 project with NUnit:

cd MyTestProject
dotnet new -i NUnit3.DotNetNew.Template
dotnet new nunit --framework net461
dotnet test

... outputs ...

Total tests: 1. Passed: 1. Failed: 0. Skipped: 0.
Test Run Successful.

Then ...

dotnet add package AltCover
dotnet test /p:AltCover=true

... outputs ...

An exception occurred while invoking executor 'executor://nunit3testexecutor/': Exception has been thrown by the target of an invocation.
Could not load file or assembly 'AltCover.Recorder.g, Version=3.5.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. A strongly-named assembly is required. (Exception from HRESULT: 0x80131044)

Test Run Failed.

Let me know if there's any more information needed. (If you miss out the --framework net461 it works correctly.)

.Net Core 2.1 UnitTest Got 0% Coverage

Hi,there is a question when I use Altcover:
Previously,I can use altcover and reportgenerator to get the coverage of my project when the classlib project is .net standard 2.0 and the unittest project is .netcore 2.0.
But recently,I update the unittest project to .netcore 2.1,I got the coverage is 0%,and I found it can't modify the coverage.xml when I "dotnet test ".
How can I get the coverage at .netcore 2.1 unittest project? Thank you.
Best wish!

Which GTK+3 theme does altcover.visualizer require?

I've installed altcover.visualizer as a global dotnet core tool and am launching it from iTerm on macOS. Upon launch, a whole bunch of errors appear in the console relating to assets missing from the theme Adwaita (see below). I've tried to find reference to a required theme in the docs, but have not found anything. Does altcover require a particular theme?

I can open my coverage XML despite the errors, but the visualizer is blank. I'm not sure if this is related to the theming issue or is something else. Any tips appreciated!

image


(AltCover.Visualizer:20783): Gtk-WARNING **: 17:30:42.907: Error loading theme icon 'document-open' for stock: Icon 'document-open' not present in theme Adwaita

(AltCover.Visualizer:20783): Gtk-WARNING **: 17:30:42.950: Error loading theme icon 'view-refresh' for stock: Icon 'view-refresh' not present in theme Adwaita

(AltCover.Visualizer:20783): Gtk-WARNING **: 17:30:42.951: Error loading theme icon 'help-about' for stock: Icon 'help-about' not present in theme Adwaita

(AltCover.Visualizer:20783): Gtk-WARNING **: 17:30:42.951: Error loading theme icon 'application-exit' for stock: Icon 'application-exit' not present in theme Adwaita

(AltCover.Visualizer:20783): Gtk-WARNING **: 17:30:54.719: Error loading theme icon 'document-open' for stock: Icon 'document-open' not present in theme Adwaita

(AltCover.Visualizer:20783): Gtk-WARNING **: 17:30:54.724: Error loading theme icon 'document-open' for stock: Icon 'document-open' not present in theme Adwaita

(AltCover.Visualizer:20783): Gtk-WARNING **: 17:30:55.732: Error loading theme icon 'document-open' for stock: Icon 'document-open' not present in theme Adwaita

(AltCover.Visualizer:20783): Gtk-WARNING **: 17:30:57.981: Error loading theme icon 'document-open' for stock: Icon 'document-open' not present in theme Adwaita

(AltCover.Visualizer:20783): Gtk-WARNING **: 17:30:57.982: Error loading theme icon 'view-refresh' for stock: Icon 'view-refresh' not present in theme Adwaita

(AltCover.Visualizer:20783): Gtk-WARNING **: 17:30:57.982: Error loading theme icon 'help-about' for stock: Icon 'help-about' not present in theme Adwaita

(AltCover.Visualizer:20783): Gtk-WARNING **: 17:30:57.982: Error loading theme icon 'application-exit' for stock: Icon 'application-exit' not present in theme Adwaita

(AltCover.Visualizer:20783): Gtk-WARNING **: 17:30:57.996: Error loading theme icon 'document-open' for stock: Icon 'document-open' not present in theme Adwaita

(AltCover.Visualizer:20783): Gtk-WARNING **: 17:30:57.997: Error loading theme icon 'view-refresh' for stock: Icon 'view-refresh' not present in theme Adwaita

(AltCover.Visualizer:20783): Gtk-WARNING **: 17:30:57.997: Error loading theme icon 'help-about' for stock: Icon 'help-about' not present in theme Adwaita

(AltCover.Visualizer:20783): Gtk-WARNING **: 17:30:57.997: Error loading theme icon 'application-exit' for stock: Icon 'application-exit' not present in theme Adwaita

(AltCover.Visualizer:20783): Gtk-WARNING **: 17:30:58.027: Error loading theme icon 'document-open' for stock: Icon 'document-open' not present in theme Adwaita

(AltCover.Visualizer:20783): Gtk-WARNING **: 17:30:58.028: Error loading theme icon 'view-refresh' for stock: Icon 'view-refresh' not present in theme Adwaita

(AltCover.Visualizer:20783): Gtk-WARNING **: 17:30:58.028: Error loading theme icon 'help-about' for stock: Icon 'help-about' not present in theme Adwaita

(AltCover.Visualizer:20783): Gtk-WARNING **: 17:30:58.028: Error loading theme icon 'application-exit' for stock: Icon 'application-exit' not present in theme Adwaita

(AltCover.Visualizer:20783): Gtk-WARNING **: 17:30:58.030: Error loading theme icon 'document-open' for stock: Icon 'document-open' not present in theme Adwaita

(AltCover.Visualizer:20783): Gtk-WARNING **: 17:30:58.030: Error loading theme icon 'view-refresh' for stock: Icon 'view-refresh' not present in theme Adwaita

(AltCover.Visualizer:20783): Gtk-WARNING **: 17:30:58.031: Error loading theme icon 'help-about' for stock: Icon 'help-about' not present in theme Adwaita

(AltCover.Visualizer:20783): Gtk-WARNING **: 17:30:58.031: Error loading theme icon 'application-exit' for stock: Icon 'application-exit' not present in theme Adwaita

(AltCover.Visualizer:20783): Gtk-WARNING **: 17:30:58.050: Error loading theme icon 'document-open' for stock: Icon 'document-open' not present in theme Adwaita

(AltCover.Visualizer:20783): Gtk-WARNING **: 17:30:58.050: Error loading theme icon 'view-refresh' for stock: Icon 'view-refresh' not present in theme Ad

Attribute order changes when run under AltCover

Hi,

We have a test where we are testing Swagger generating descriptions from method attributes.

when we are running this under altcover it seems as though the attributes are being processed in the reverse order.

Please let me know if this makes sense, or if you need a sample project to demo the issue?

FileNotFoundException when running dotnet test on 5.0.663

When running version 5.0.663 with command
dotnet test SolutionName.sln /p:AltCover=true /p:AltCoverAssemblyExcludeFilter="\.Tests" /p:CopyLocalLockFileAssemblies="true" /p:DebugType="pdbonly" /p:AltCoverXmlreport="altcover.xml" FileNotFoundException errors occur.
I think it may somehow be related to the change with portable PDBs.

The following error is being logged in the log file:

System.IO.FileNotFoundException: Could not find file '/app/*****/Enums.NET.pdb'.
File name: '/app/*****/Enums.NET.pdb'
   at Interop.ThrowExceptionForIoErrno(ErrorInfo errorInfo, String path, Boolean isDirectory, Func`2 errorRewriter)
   at Microsoft.Win32.SafeHandles.SafeFileHandle.Open(String path, OpenFlags flags, Int32 mode)
   at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options)
   at Mono.Cecil.Mixin.IsPortablePdb(String fileName)
   at Mono.Cecil.Pdb.PdbReaderProvider.GetSymbolReader(ModuleDefinition module, String fileName)
   at [email protected](String pdbpath) in C:\projects\altcover\AltCover\ProgramDatabase.fs:line 65
   at Microsoft.FSharp.Core.OptionModule.Iterate[T](FSharpFunc`2 action, FSharpOption`1 option)
   at AltCover.Visitor.func2@1(AssemblyDefinition x) in C:\projects\altcover\AltCover\Visitor.fs:line 262
   at [email protected](String x) in C:\projects\altcover\AltCover\Visitor.fs:line 248
   at Microsoft.FSharp.Collections.Internal.IEnumerator.map@74.DoMoveNext(b& curr)
   at Microsoft.FSharp.Collections.Internal.IEnumerator.MapEnumerator`1.System-Collections-IEnumerator-MoveNext()
   at Microsoft.FSharp.Core.CompilerServices.RuntimeHelpers.takeOuter@274[T,TResult](ConcatEnumerator`2 x, Unit unitVar0)
   at Microsoft.FSharp.Core.CompilerServices.RuntimeHelpers.takeInner@267[T,TResult](ConcatEnumerator`2 x, Unit unitVar0)
   at Microsoft.FSharp.Collections.SeqModule.Fold[T,TState](FSharpFunc`2 folder, TState state, IEnumerable`1 source)
   at AltCover.Visitor.Visit(IEnumerable`1 visitors, IEnumerable`1 assemblies) in C:\projects\altcover\AltCover\Visitor.fs:line 695
   at [email protected](Unit unitVar0) in C:\projects\altcover\AltCover\AltCover.fs:line 445
   at AltCover.CommandLine.doPathOperation[a](FSharpFunc`2 f, a defaultValue, Boolean store) in C:\projects\altcover\AltCover\CommandLine.fs:line 183
FileName =
"/app/*****/Enums.NET.pdb"
FusionLog =
<null>
Data =
seq []
InnerException =
<null>
TargetSite =
Void ThrowExceptionForIoErrno(ErrorInfo, System.String, Boolean, System.Func`2[Interop+ErrorInfo,Interop+ErrorInfo])
HelpLink =
<null>
Source =
"System.Private.CoreLib"
HResult =
-2147024894
System.IO.FileNotFoundException: Could not find file '/app/*****/Enums.NET.pdb'.
File name: '/app/*****/Enums.NET.pdb'
   at Interop.ThrowExceptionForIoErrno(ErrorInfo errorInfo, String path, Boolean isDirectory, Func`2 errorRewriter)
   at Microsoft.Win32.SafeHandles.SafeFileHandle.Open(String path, OpenFlags flags, Int32 mode)
   at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options)
   at Mono.Cecil.Mixin.IsPortablePdb(String fileName)
   at Mono.Cecil.Pdb.PdbReaderProvider.GetSymbolReader(ModuleDefinition module, String fileName)
   at [email protected](String pdbpath) in C:\projects\altcover\AltCover\ProgramDatabase.fs:line 65
   at Microsoft.FSharp.Core.OptionModule.Iterate[T](FSharpFunc`2 action, FSharpOption`1 option)
   at AltCover.Visitor.func2@1(AssemblyDefinition x) in C:\projects\altcover\AltCover\Visitor.fs:line 262
   at [email protected](String x) in C:\projects\altcover\AltCover\Visitor.fs:line 248
   at Microsoft.FSharp.Collections.Internal.IEnumerator.map@74.DoMoveNext(b& curr)
   at Microsoft.FSharp.Collections.Internal.IEnumerator.MapEnumerator`1.System-Collections-IEnumerator-MoveNext()
   at Microsoft.FSharp.Core.CompilerServices.RuntimeHelpers.takeOuter@274[T,TResult](ConcatEnumerator`2 x, Unit unitVar0)
   at Microsoft.FSharp.Core.CompilerServices.RuntimeHelpers.takeInner@267[T,TResult](ConcatEnumerator`2 x, Unit unitVar0)
   at Microsoft.FSharp.Collections.SeqModule.Fold[T,TState](FSharpFunc`2 folder, TState state, IEnumerable`1 source)
   at AltCover.Visitor.Visit(IEnumerable`1 visitors, IEnumerable`1 assemblies) in C:\projects\altcover\AltCover\Visitor.fs:line 695
   at [email protected](Unit unitVar0) in C:\projects\altcover\AltCover\AltCover.fs:line 445
   at AltCover.CommandLine.doPathOperation[a](FSharpFunc`2 f, a defaultValue, Boolean store) in C:\projects\altcover\AltCover\CommandLine.fs:line 183
FileName =
"/app/*****/Enums.NET.pdb"
FusionLog =
<null>
Data =
seq []
InnerException =
<null>
TargetSite =
Void ThrowExceptionForIoErrno(ErrorInfo, System.String, Boolean, System.Func`2[Interop+ErrorInfo,Interop+ErrorInfo])
HelpLink =
<null>
Source =
"System.Private.CoreLib"
HResult =
-2147024894
System.IO.FileNotFoundException: Could not find file '/app/*****/System.ComponentModel.Annotations.pdb'.
File name: '/app/*****/System.ComponentModel.Annotations.pdb'
   at Interop.ThrowExceptionForIoErrno(ErrorInfo errorInfo, String path, Boolean isDirectory, Func`2 errorRewriter)
   at Microsoft.Win32.SafeHandles.SafeFileHandle.Open(String path, OpenFlags flags, Int32 mode)
   at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options)
   at Mono.Cecil.Mixin.IsPortablePdb(String fileName)
   at Mono.Cecil.Pdb.PdbReaderProvider.GetSymbolReader(ModuleDefinition module, String fileName)
   at [email protected](String pdbpath) in C:\projects\altcover\AltCover\ProgramDatabase.fs:line 65
   at Microsoft.FSharp.Core.OptionModule.Iterate[T](FSharpFunc`2 action, FSharpOption`1 option)
   at AltCover.Visitor.func2@1(AssemblyDefinition x) in C:\projects\altcover\AltCover\Visitor.fs:line 262
   at [email protected](String x) in C:\projects\altcover\AltCover\Visitor.fs:line 248
   at Microsoft.FSharp.Collections.Internal.IEnumerator.map@74.DoMoveNext(b& curr)
   at Microsoft.FSharp.Collections.Internal.IEnumerator.MapEnumerator`1.System-Collections-IEnumerator-MoveNext()
   at Microsoft.FSharp.Core.CompilerServices.RuntimeHelpers.takeOuter@274[T,TResult](ConcatEnumerator`2 x, Unit unitVar0)
   at Microsoft.FSharp.Core.CompilerServices.RuntimeHelpers.takeInner@267[T,TResult](ConcatEnumerator`2 x, Unit unitVar0)
   at Microsoft.FSharp.Collections.SeqModule.Fold[T,TState](FSharpFunc`2 folder, TState state, IEnumerable`1 source)
   at AltCover.Visitor.Visit(IEnumerable`1 visitors, IEnumerable`1 assemblies) in C:\projects\altcover\AltCover\Visitor.fs:line 695
   at [email protected](Unit unitVar0) in C:\projects\altcover\AltCover\AltCover.fs:line 445
   at AltCover.CommandLine.doPathOperation[a](FSharpFunc`2 f, a defaultValue, Boolean store) in C:\projects\altcover\AltCover\CommandLine.fs:line 183
FileName =
"/app/*****/System.ComponentModel.Annotations.pdb"
FusionLog =
<null>
Data =
seq []
InnerException =
<null>
TargetSite =
Void ThrowExceptionForIoErrno(ErrorInfo, System.String, Boolean, System.Func`2[Interop+ErrorInfo,Interop+ErrorInfo])
HelpLink =
<null>
Source =
"System.Private.CoreLib"
HResult =
-2147024894
System.IO.FileNotFoundException: Could not find file '/app/*****/System.ComponentModel.Annotations.pdb'.
File name: '/app/*****/System.ComponentModel.Annotations.pdb'
   at Interop.ThrowExceptionForIoErrno(ErrorInfo errorInfo, String path, Boolean isDirectory, Func`2 errorRewriter)
   at Microsoft.Win32.SafeHandles.SafeFileHandle.Open(String path, OpenFlags flags, Int32 mode)
   at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options)
   at Mono.Cecil.Mixin.IsPortablePdb(String fileName)
   at Mono.Cecil.Pdb.PdbReaderProvider.GetSymbolReader(ModuleDefinition module, String fileName)
   at [email protected](String pdbpath) in C:\projects\altcover\AltCover\ProgramDatabase.fs:line 65
   at Microsoft.FSharp.Core.OptionModule.Iterate[T](FSharpFunc`2 action, FSharpOption`1 option)
   at AltCover.Visitor.func2@1(AssemblyDefinition x) in C:\projects\altcover\AltCover\Visitor.fs:line 262
   at [email protected](String x) in C:\projects\altcover\AltCover\Visitor.fs:line 248
   at Microsoft.FSharp.Collections.Internal.IEnumerator.map@74.DoMoveNext(b& curr)
   at Microsoft.FSharp.Collections.Internal.IEnumerator.MapEnumerator`1.System-Collections-IEnumerator-MoveNext()
   at Microsoft.FSharp.Core.CompilerServices.RuntimeHelpers.takeOuter@274[T,TResult](ConcatEnumerator`2 x, Unit unitVar0)
   at Microsoft.FSharp.Core.CompilerServices.RuntimeHelpers.takeInner@267[T,TResult](ConcatEnumerator`2 x, Unit unitVar0)
   at Microsoft.FSharp.Collections.SeqModule.Fold[T,TState](FSharpFunc`2 folder, TState state, IEnumerable`1 source)
   at AltCover.Visitor.Visit(IEnumerable`1 visitors, IEnumerable`1 assemblies) in C:\projects\altcover\AltCover\Visitor.fs:line 695
   at [email protected](Unit unitVar0) in C:\projects\altcover\AltCover\AltCover.fs:line 445
   at AltCover.CommandLine.doPathOperation[a](FSharpFunc`2 f, a defaultValue, Boolean store) in C:\projects\altcover\AltCover\CommandLine.fs:line 183
FileName =
"/app/*****/System.ComponentModel.Annotations.pdb"
FusionLog =
<null>
Data =
seq []
InnerException =
<null>
TargetSite =
Void ThrowExceptionForIoErrno(ErrorInfo, System.String, Boolean, System.Func`2[Interop+ErrorInfo,Interop+ErrorInfo])
HelpLink =
<null>
Source =
"System.Private.CoreLib"
HResult =
-2147024894
System.IO.FileNotFoundException: Could not find file '/app/*****/System.ComponentModel.Annotations.pdb'.
File name: '/app/*****/System.ComponentModel.Annotations.pdb'
   at Interop.ThrowExceptionForIoErrno(ErrorInfo errorInfo, String path, Boolean isDirectory, Func`2 errorRewriter)
   at Microsoft.Win32.SafeHandles.SafeFileHandle.Open(String path, OpenFlags flags, Int32 mode)
   at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options)
   at Mono.Cecil.Mixin.IsPortablePdb(String fileName)
   at Mono.Cecil.Pdb.PdbReaderProvider.GetSymbolReader(ModuleDefinition module, String fileName)
   at [email protected](String pdbpath) in C:\projects\altcover\AltCover\ProgramDatabase.fs:line 65
   at Microsoft.FSharp.Core.OptionModule.Iterate[T](FSharpFunc`2 action, FSharpOption`1 option)
   at AltCover.Visitor.func2@1(AssemblyDefinition x) in C:\projects\altcover\AltCover\Visitor.fs:line 262
   at [email protected](String x) in C:\projects\altcover\AltCover\Visitor.fs:line 248
   at Microsoft.FSharp.Collections.Internal.IEnumerator.map@74.DoMoveNext(b& curr)
   at Microsoft.FSharp.Collections.Internal.IEnumerator.MapEnumerator`1.System-Collections-IEnumerator-MoveNext()
   at Microsoft.FSharp.Core.CompilerServices.RuntimeHelpers.takeOuter@274[T,TResult](ConcatEnumerator`2 x, Unit unitVar0)
   at Microsoft.FSharp.Core.CompilerServices.RuntimeHelpers.takeInner@267[T,TResult](ConcatEnumerator`2 x, Unit unitVar0)
   at Microsoft.FSharp.Collections.SeqModule.Fold[T,TState](FSharpFunc`2 folder, TState state, IEnumerable`1 source)
   at AltCover.Visitor.Visit(IEnumerable`1 visitors, IEnumerable`1 assemblies) in C:\projects\altcover\AltCover\Visitor.fs:line 695
   at [email protected](Unit unitVar0) in C:\projects\altcover\AltCover\AltCover.fs:line 445
   at AltCover.CommandLine.doPathOperation[a](FSharpFunc`2 f, a defaultValue, Boolean store) in C:\projects\altcover\AltCover\CommandLine.fs:line 183
FileName =
"/app/*****/System.ComponentModel.Annotations.pdb"
FusionLog =
<null>
Data =
seq []
InnerException =
<null>
TargetSite =
Void ThrowExceptionForIoErrno(ErrorInfo, System.String, Boolean, System.Func`2[Interop+ErrorInfo,Interop+ErrorInfo])
HelpLink =
<null>
Source =
"System.Private.CoreLib"
HResult =
-2147024894

dotnet info :

.NET Core SDK (reflecting any global.json):
 Version:   2.1.502
 Commit:    c74ce8f29f

Runtime Environment:
 OS Name:     debian
 OS Version:  9
 OS Platform: Linux
 RID:         debian.9-x64
 Base Path:   /usr/share/dotnet/sdk/2.1.502/

Host (useful for support):
  Version: 2.1.6
  Commit:  3f4f8eebd8

.NET Core SDKs installed:
  2.1.502 [/usr/share/dotnet/sdk]

.NET Core runtimes installed:
  Microsoft.AspNetCore.All 2.1.6 [/usr/share/dotnet/shared/Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.App 2.1.6 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 2.1.6 [/usr/share/dotnet/shared/Microsoft.NETCore.App]

Getting AltCover.Recorder.g.dll not found in --the nominated directory.

Until yesterday I was successfully able to run the following command for projects
dotnet test /p:AltCover=true /p:AltCoverOpenCover=true /p:AltCoverXmlreport="C:\xxxx\temp\Unittesting\AltCover\AltCover1.json" c:\projects\xxxx\platform\tests\server\xxx.xxxxxxx.Admin.Tests\xxx.xxxxxxx.Admin.Tests.csproj

suddenly yesterday it started throwing an error as below. The Build Starts and Completes after that the error it throws is

C:\Users\xxxxxxxx\.nuget\packages\altcover\4.0.661\build\netstandard2.0\AltCover.targets(33,5): error : Output directory for saved files c:\projects\xxxxxxx\platform\tests\server\xxx.xxxxxxx.xxxxx.Export.Tests\bin\Debug\netcoreapp2.1\__Saved already exists [c:\projects\xxxxxxx\platform\tests\server\xxx.xxxxxxx.xxxxx.Export.Tests\xxx.xxxxxxx.xxxxxxxxxxx.Tests.csproj]

Error - usage is:
  -i, --inputDirectory=VALUE Optional: The folder containing assemblies to
                               instrument (default: current directory)
  -o, --outputDirectory=VALUE
                             Optional: The folder to receive the instrumented
                               assemblies and their companions (default: sub-
                               folder '__Instrumented' of the current directory;
                                or '__Saved' if 'inplace' is set)

after the list of help text is printed it gives the following error

Error - usage is:
C:\Users\xxxxxxxx\.nuget\packages\altcover\4.0.661\build\netstandard2.0\AltCover.targets(87,5): error : Recorder assembly c:\projects\xxxxxxx\platform\tests\server\xxx.xxxxxxx.xxxxx.Export.Tests\bin\Debug\netcoreapp2.1\AltCover.Recorder.g.dll not found in   -the nominated directory. [c:\projects\xxxxxxx\platform\tests\server\xxx.xxxxxxx.xxxxx.Export.Tests\xxx.xxxxxxx.xxxxxxxxxxx.Tests.csproj]

i, --inputDirectory=VALUE Optional: The folder containing assemblies to                           
                               instrument (default: current directory)                            
  -o, --outputDirectory=VALUE                                                                     
                             Optional: The folder to receive the instrumented                     
                               assemblies and their companions (default: sub-                     
                               folder '__Instrumented' of the current directory;                  
                                or '__Saved' if 'inplace' is set)                                 
  -y, --symbolDirectory=VALUE                                                                     

Any idea why this is happening? My work is stuck due to this error.

AltCoverAssemblyExcludeFilter does not work on Linux

When running dotnet test with AltCoverAssemblyExcludeFilter set to exclude \.Tests, that does not work on Debian Linux (Docker).
(it does not matter, if it contains also xunit for version 5.x.x, or not, for version 4.x.x of AltCover)
The command:
dotnet test code\MyProject.sln /p:AltCover=true /p:AltCoverAssemblyExcludeFilter="\.Tests|xunit" /p:CopyLocalLockFileAssemblies="true" /p:DebugType="pdbonly" /p:AltCoverXmlreport="altcover.xml"

The files below are ready-to-run scripts for Docker, with an assumption in run-coverage.sh, that this code would be placed in c:/altcover-repro/ - that is a volume binding which is only possible with an absolute path.

altcover-exclude-filter-repro.zip

Dotnet info:

.NET Core SDK (reflecting any global.json):
 Version:   2.1.502
 Commit:    c74ce8f29f

Runtime Environment:
 OS Name:     debian
 OS Version:  9
 OS Platform: Linux
 RID:         debian.9-x64
 Base Path:   /usr/share/dotnet/sdk/2.1.502/

Host (useful for support):
  Version: 2.1.6
  Commit:  3f4f8eebd8

.NET Core SDKs installed:
  2.1.502 [/usr/share/dotnet/sdk]

.NET Core runtimes installed:
  Microsoft.AspNetCore.All 2.1.6 [/usr/share/dotnet/shared/Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.App 2.1.6 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 2.1.6 [/usr/share/dotnet/shared/Microsoft.NETCore.App]

No recorder dll in nominated directory

When using the latest release (v3.0.404), no recorder dll is produced in the selected instrumentation directory. This prevents any coverage from being generated or collected.

The following is a log from instrumentation to collection, including test execution. Disregard any error messages in the test run; these are intentional.

https://hastebin.com/buzayixida.sql

This issues was not present in the previously used version in the project, that is, 2.0.324. The issue presents itself in both --inplace and non-inplace runs.

Looking to add expecto support

Hey Steve, if I were looking to add expecto support to altcover what do you expect the workload would be?

haf/expecto#219

In here I talk about what sort of steps could give us partial support in OpenCover, by leveraging attribute based test tracking, however it would also be nice to track certain methods by name such as runTestsInAssembly
runTestsWithArgs
runTests. Hopefully I can be of use?

Performance issue when running on .NET Core with XUnit

Hello,
I've faced quite serious performance problem on one of my test projects.
When run normally with dotnet test .\ProjectName.csproj the outcome was:

[xUnit.net 00:00:06.6818029]   Finished:    *.Tests

Total tests: 409. Passed: 406. Failed: 0. Skipped: 3.
Test Run Successful.
Test execution time: 7.5661 Seconds

When run with Altcover with a command:
dotnet test .\ProjectName.csproj /p:AltCover=true /p:AltCoverAssemblyExcludeFilter=".Tests" /p:AltCoverXmlreport="altcover.xml"
the outcome is:

[xUnit.net 00:13:51.3911961]   Finished:    *.Tests

Total tests: 409. Passed: 406. Failed: 0. Skipped: 3.
Test Run Successful.
Test execution time: 13.8718 Minutes

Furthermore, after the tests finished executing, it took another 13 minutes to finish coverage computation (or whatever is being done underneath).

After test were run, the following files were present in the folder (just to indicate their size):

-a----       05/06/2018     18:33        3983736 altcover.xml
-a----       05/06/2018     18:47      595349084 altcover.xml.0.acv
-a----       05/06/2018     18:33              0 altcover.xml.acv

And the metrics, just to indicate the complexity of the test run:

Assemblies:		6
Classes:		656
Files:			404
Covered lines:		2808
Uncovered lines:	5555
Coverable lines:	8363
Total lines:		18450

dotnet --info outcome:

.NET Command Line Tools (2.1.4)

Product Information:
 Version:            2.1.4
 Commit SHA-1 hash:  5e8add2190

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.17134
 OS Platform: Windows
 RID:         win10-x64
 Base Path:   C:\Program Files\dotnet\sdk\2.1.4\

Host (useful for support):
  Version: 2.1.0
  Commit:  caa7b7e2ba

Any clue what may be happening or how it can be fixed/workarounded?

Usage with .NET Core

I'm having a hard time figuring out how to run my unit tests and generate the coverage.xml report for my assemblies... I spotted you added some more documentation this morning (thanks!), so now I'm running from inside my unit test project directory:

$ dotnet build
$ dotnet run --project ~/Downloads/altcover.1.4.150-beta/tools/netcoreapp2.0/AltCover/ -- /i:bin/Debug/netcoreapp2.0
$ cp -R __Instrumented/* bin/Debug/netcoreapp2.0
$ dotnet test --no-build

The tests run successfully (and I think they're instrumented), but my coverage.xml file is the same before and after (i.e. it says no code points were hit). I've tried a bunch of different command combinations (e.g. dotnet run --project ~/Downloads/altcover.1.4.150-beta/tools/netcoreapp2.0/AltCover/ -- /o:bin/Debug/netcoreapp2.0 -- dotnet test --no-build) but no dice :(

Any pointers, or plain commands that you've been using?

P.S. Thanks for being the guy to finally bring code coverage to .NET Core!

FSharp code coverage on mono using altcover, generates 0% sequenceCoverage

Quite happy to find this library that works pretty much out of the box, and the docs are fairly good - could have been a bit more clear with more examples.

Just now I have it working (partially) i.e. generates a coverage.xml file with 0% sequenceCoverage, although running this command:

mono packages/altcover.3.5.569/tools/net45/AltCover.exe --inputDirectory src/TestProject/bin/Debug --xmlReport coverage/coverage.xml --opencover --assemblyExcludeFilter=.+\.Tests --assemblyExcludeFilter=AltCover.+ --assemblyExcludeFilter=Mono\.DllMap.+ --inplace --save

gives this output:

Creating folder fsharp-project/__Saved
Saving files to fsharp-project/__Saved
Instrumenting files in fsharp-project/src/fsharp-project-tests/bin/Debug
   => fsharp-project/__Saved/Apache.NMS.ActiveMQ.dll
   => fsharp-project/__Saved/Apache.NMS.dll
   => fsharp-project/__Saved/fsharp-project-tests.dll
   => fsharp-project/__Saved/fsharp-project.exe
   => fsharp-project/__Saved/BeFaster.Runner.dll
   => fsharp-project/__Saved/TDL.Client.dll

Coverage Report: fsharp-project/coverage/coverage.xml


    fsharp-project/src/fsharp-project-tests/bin/Debug/Apache.NMS.dll
                <=  Apache.NMS, Version=1.7.1.3894, Culture=neutral, PublicKeyToken=82756feee3957618
    fsharp-project/src/fsharp-project-tests/bin/Debug/Apache.NMS.ActiveMQ.dll
                <=  Apache.NMS.ActiveMQ, Version=1.7.2.4108, Culture=neutral, PublicKeyToken=82756feee3957618
    fsharp-project/src/fsharp-project-tests/bin/Debug/TDL.Client.dll
                <=  TDL.Client, Version=0.14.0.0, Culture=neutral, PublicKeyToken=null
    fsharp-project/src/fsharp-project-tests/bin/Debug/BeFaster.Runner.dll
                <=  BeFaster.Runner, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
    fsharp-project/src/fsharp-project-tests/bin/Debug/fsharp-project.exe
                <=  fsharp-project, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
    fsharp-project/src/fsharp-project-tests/bin/Debug/fsharp-project-tests.dll
                <=  fsharp-project-tests, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null

What am I doing wrong? Must be missing a step after this? I'm using MSBuild to build my project prior to running the above command.

Is instrumentation idempotent?

Is the instrumentation operation idempotent in the sense that instrumenting an already instrumented assembly has no additional effect, i.e. line coverage, etc...?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.