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

Coverlet failing to instrument module [Mono.Cecil Exception] #1355

Closed
skerr0 opened this issue Jun 22, 2022 · 3 comments
Closed

Coverlet failing to instrument module [Mono.Cecil Exception] #1355

skerr0 opened this issue Jun 22, 2022 · 3 comments
Labels
duplicate This issue or pull request already exists

Comments

@skerr0
Copy link

skerr0 commented Jun 22, 2022

Hello, I'm currently using coverlet on a wpf project with the following setup:

  • NetFramework 4.8
  • WPF
  • XUnit 2.4.1
  • Coverlet 3.1.2

I have gone through the troubleshooting guide and have determined that my main executable in the project is failing to instrument. Other .net standard and .net framework libraries generate proper coverage results. This occurs when running coverlet either as collector or build. There is an exception thrown when instrumentation is attempted.

Any advice or suggestions would be appreciated

TpTrace Warning: 0 : 35112, 1, 2022/06/22, 11:18:44.245, 4166831566790, datacollector.dll, [coverlet]Unable to instrument module: C:\Users\kerr\source\repos\VaxArraySoftware\VaxArraySoftware\InDevR.VaxArray.WPFTests\bin\x64\Debug\net48\InDevR.VaxArray.WPF.exe
Mono.Cecil.ResolutionException: Failed to resolve System.Windows.Threading.DispatcherPriority
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.b__2_0(MetadataBuilder builder, MetadataReader )
at Mono.Cecil.ModuleDefinition.Read[TItem,TRet](TItem item, Func3 read) at Mono.Cecil.ModuleWriter.BuildMetadata(ModuleDefinition module, MetadataBuilder metadata) at Mono.Cecil.ModuleWriter.Write(ModuleDefinition module, Disposable1 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 Coverlet.Core.Instrumentation.Instrumenter.InstrumentModule() in /
/src/coverlet.core/Instrumentation/Instrumenter.cs:line 335
at Coverlet.Core.Instrumentation.Instrumenter.Instrument() in /
/src/coverlet.core/Instrumentation/Instrumenter.cs:line 145
at Coverlet.Core.Coverage.PrepareModules() in //src/coverlet.core/Coverage.cs:line 135

@MarcoRossignoli
Copy link
Collaborator

Can you try temporary to manually copy WindowsBase.dll to the bin folder? I think it's a dup of #1221

@MarcoRossignoli MarcoRossignoli added the duplicate This issue or pull request already exists label Jun 24, 2022
@skerr0
Copy link
Author

skerr0 commented Jun 24, 2022

The executable which was failing to instrument does so now with the WindowsBase.dll added.

I don't mind applying this solution for local development, but Is the root cause planned to be addressed? Or is it potentially an issue with how my project is set up?

Thanks

@MarcoRossignoli
Copy link
Collaborator

MarcoRossignoli commented Jun 24, 2022

It's planned but not yet on the right place in the queue of prio, you can check in the linked issue where's the problem.

We should add the Windows resolver to this list https://github.com/coverlet-coverage/coverlet/blob/master/src/coverlet.core/Instrumentation/CecilAssemblyResolver.cs#L75

We accept PR if you're interested, not mandatory.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
duplicate This issue or pull request already exists
Projects
None yet
Development

No branches or pull requests

2 participants