Skip to content

Coverlet.Core.Instrumentation.Tracker. runtime Type created in production assemblyΒ #1191

Closed

Description

@apsthisdev

I have simple .NET core assembly

MyAssembly.csproj (src)

MyAssemblyTest.csproj (test)

  • MyAssemblyTest References coverlet to generate the test reports.
  • MyAssemblyTest references the MyAssembly.csproj
  • Defines MSTest that validates MyAssembly types using reflection.

After running the tests I noticed that the coverlet creates a runtime type in MyAssembly and this assembly which does not reference coverlet at all !

Coverlet.Core.Instrumentation.Tracker.MyAssembly_563b4785-5c80-4b10-82c6-9057f0038f04

Why is coverlet creating a tracker inside a production assembly that does not references coverlet at the first place ?

Activity

  1. added
    question
    on Jul 17, 2021
  2. MarcoRossignoli commented on Jul 17, 2021

    @MarcoRossignoli
    Collaborator

    Coverlet injects a static class inside assembly during instrumentation. This class contains method to record the hint. We refer to this method inside user instrumented types. After the instrumentation we "rollback" to the original dlls(original ones are saved in a tmp dir).
    Hits are collected in a in memory array and persisted to a file system on process exits.

    Why is coverlet creating a tracker inside a production assembly that does not references coverlet at the first place ?

    We cannot add dependency to user assembly or we risk to break the real code(our dependencies could influence behavior loading external and not expected assemblies). We simply inject "some helper" class but we don't "inject" any dependency.
    On runtime we rely on BCL(base class library) primitive types(array, mutex, files).

  3. MarcoRossignoli commented on Jul 17, 2021

    @MarcoRossignoli
    Collaborator
  4. apsthisdev commented on Jul 27, 2021

    @apsthisdev
    Author

    Thanks for the explanation, so after the instrumentation the original dlls will not have these trackers. Can we have CompilerGeneratedAttribute on them so that other type inspection algorithms can ignore these trackers ?

  5. MarcoRossignoli commented on Oct 2, 2021

    @MarcoRossignoli
    Collaborator

    I think it's possible and should not have impact.
    Thanks for the advice.

  6. added
    enhancement
    and removed
    question
    on Oct 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions