Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Mono.Cecil dependency version to 0.11.4 #1351

Closed
searoz opened this issue Jun 15, 2022 · 3 comments · Fixed by #1510
Closed

Update Mono.Cecil dependency version to 0.11.4 #1351

searoz opened this issue Jun 15, 2022 · 3 comments · Fixed by #1510
Labels
enhancement General enhancement request

Comments

@searoz
Copy link

searoz commented Jun 15, 2022

Hello.

The latest (at the time of this post - 3.1.2) version of Coverlet uses Mono.Cecil 0.11.1. Unfortunately, this is an outdated version of Mono.Cecil that contains some bugs. For example, const null arrays are not processed correctly:

using Mono.Cecil;
using Mono.Cecil.Rocks;

await using var moduleStream = File.OpenRead(typeof(TestClass).Assembly.Location);

using var module = ModuleDefinition.ReadModule(moduleStream, new ReaderParameters { ReadSymbols = true });
var type = module.GetType(string.Empty, nameof(TestClass));
var method = type.GetMethods().Single();

try
{
    var debugInformation = method.DebugInformation; // fails on Mono.Cecil 0.11.1, works fine on 0.11.4
    Console.WriteLine("Success");
}
catch (Exception ex)
{
    Console.WriteLine("Error: {0}", ex);
}

public class TestClass
{
    public void TestMethod()
    {
        const object[]? testVariable = null;
    }
}

This prevents Coverlet from instumenting modules and calculating code coverage correctly.

It would be nice if you could update Mono.Cecil dependency to 0.11.4. Thanks in advance.

@MarcoRossignoli MarcoRossignoli added the enhancement General enhancement request label Jun 24, 2022
@MarcoRossignoli
Copy link
Collaborator

MarcoRossignoli commented Jun 24, 2022

Do you have real scenarios where we're failing to instrument/get coverage?
We can bump the deps but it's always risky(we can clash with users deps in some scenarios) and I prefer to do if we've real needs.

@searoz
Copy link
Author

searoz commented Jun 24, 2022

Unfortunately, I cannot share any real-world scenarios because of NDAs, but my example from the original post should suffice. Coverlet fails to instrument any assembly that has const array variables like const object[]? foo = null. I can create a pull request with some unit tests for you if you want

@MarcoRossignoli
Copy link
Collaborator

Feel free to open the PR and add some tests we can try to merge 🤞

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement General enhancement request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants