coverlet: Coverlet fails to instrument F# projects that have "unknown" source (inline functions, anonymous records etc)

I have a F# solution with a web sdk api project, two shared libraries and some windows services. Coverlet sucessfully instrument and analyze one of the shared libraries and the windows services but fails to instrument the api project and one of the libraries.

I’ve seen that there are similar issues here in the repo and while this could be a duplicate of one of those I have two detail that I think sets this apart.

  • it works for some projects in my solution and not for others. See below.
  • I get the “unknown” file reference in the Instrumentation log entry for the failing projects none of the other issues does that. See below.

I’ve tested with all three variants of coverlet 3.0.3: msbuild, collector and console and all three give the same result. Inspecting the logs I see this for the failed instrumentations:

Unsuccessful library and unsuccessful api project,

[coverlet] Unable to instrument module: C:\myproject\src\tests\bin\Debug\net5.0\coreLibA.dll, pdb without local source files, [C:\myproject\src\coreLibA\unknown]
[coverlet] Unable to instrument module: C:\myproject\src\tests\bin\Debug\net5.0\myapi.dll, pdb without local source files, [C:\myproject\src\api\unknown]

Things I’ve tried and checked:

  • Creating a new solution with same kind of projects - unable to reproduce.
  • Does changing the name of the assembly with the <AssemblyName> property have any impact? - No, i have one changed and one unchanged assembly name that works and one changed and one unchanged that doesn’t work.

I have two questions:

  • What else can I do to find what the significant difference is between the projects that work and those that don’t?
  • What is the significance of the strange “unknown” file reference at the end that I get [C:\myproject\src\api\unknown]. The word “unknown” is not present in the coverlet repo so I assume it comes from something external to coverlet.

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 25

Most upvoted comments

Problem reproduction repo up: https://github.com/da9l/coverletWithAnonymousRecords In the repo there are two libs and one test project. One of the libs contains an anonymous record and the other one don’t. The one with AR does not show up in the coverlet analysis.

I deleted every old version of coverlet.collecter.dll from my computer, removed all bin/obj folders and rebuilt everything from scratch; and the error is gone now. I also went throught my PDB’s and the changes in #1165 and it seems like everything should be OK. AFAICT updating the version of coverlet.collector in paket.dependencies and restoring was not enough. @daveMueller thanks anyway.

@daveMueller No, I don’t think I am. Here’s the relevant section from my paket.dependencies:

group Test
    source https://api.nuget.org/v3/index.json
    framework: net5.0

    nuget FSharp.Core 5.0.0
    nuget coverlet.collector 3.1.0
    nuget FSharpPlus
    nuget Microsoft.NET.Test.Sdk 16.5.0
    nuget Unquote 5.0.0
    nuget NUnit
    nuget NUnit3TestAdapter
    nuget MySqlConnector
    nuget Dapper
    nuget Simple.Migrations
    nuget Ply
    nuget Microsoft.NETCore.Platforms 5.0.2

I’ll try to set up a minimal repro and get back to you.

I get your idea with ‘just fail if all source files are missing’. The benefit would be to get rid of such issues like this one. The disadvantage would be a higher possibility for false positives if a library has just one same document name like the project.

I’ve moved this part of the discussion to a new issue (#1164) to not distract from the F# situation here.

Hello, I am experiencing the same problem and I have posted a simple example here in the hope that it will help: https://github.com/rhewitt316/coverlet-fsharp-anonymous-records-example

I am using coverlet.console 3.0.3. Coverlet fails to instrument my example as-is. If the anonymous record is removed from my example, then instrumentation succeeds.