coverlet-coverage / coverlet

Cross platform code coverage for .NET
MIT License
2.94k stars 386 forks source link

Warning : [coverlet] BadImageFormatException during MetadataReaderProvider.FromPortablePdbStream #1348

Closed SamHuoJudiAi closed 2 years ago

SamHuoJudiAi commented 2 years ago

Hi,

I am using the following:

When I run:

dotnet test

I keep getting the following warning (excessively):

C:\<..>\packages\coverlet.msbuild.2.9.0\build\coverlet.msbuild.targets(31,5): warning : [coverlet] BadImageFormatException during MetadataReaderProvider.FromPortablePdbStream in InstrumentationHelper.PortablePd bHasLocalSource, unable to check if module has got local source. [..]

Looking at the code the error seems to be from here on line 156: https://github.com/coverlet-coverage/coverlet/blob/master/src/coverlet.core/Helpers/InstrumentationHelper.cs

I believe the issue is the pdb generated are Full/pdbOnly and not embedded/portable as the code is expecting. Perhaps it is best to check DebugDirectoryEntry.IsPortableCodeView to check if portable and if not use some other way to get MetaData.

MarcoRossignoli commented 2 years ago

At the moment coverlet works with portable pdb and that part of the code is used as heuristic to decide if cover or not the module, we decided to be relaxed and simply instrument with the risk to not be able to get a good coverage(missing pdb info). Can you move to portable pdb?

SamHuoJudiAi commented 2 years ago

@MarcoRossignoli , thanks for the reply. Yes, I have moved to portable pdb to resolve the logging issues.

MarcoRossignoli commented 2 years ago

Glad hear that, feel free to close the issue.