coverlet-coverage / coverlet

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

[BUG] System.MissingMethodException: Method not found: System.Collections.Immutable.ImmutableArray 1<System.Reflection.PortableExecutable.DebugDirectoryEntry> #1536

Closed cforbesywam closed 4 months ago

cforbesywam commented 9 months ago

Describe the bug System.MissingMethodException: Method not found: 'System.Collections.Immutable.ImmutableArray`1

To Reproduce .Net 7 Project with XUnit using coverlet collector (6.0.1-preview.17.g473777) with VSTest.

Expected behavior No error and actually generate coverage file that is not empty.

Actual behavior Repeated Errors: TpTrace Warning: 0 : 6332, 1, 2023/09/20, 21:26:41.391, 6181671638940, datacollector.exe, [coverlet]Unable to instrument module: 'C:\agent\devops_work\31\s\JusticeNext\CMIJustice.Tests\publish\AutoFixture.AutoMoq.dll' System.MissingMethodException: Method not found: 'System.Collections.Immutable.ImmutableArray1<System.Reflection.PortableExecutable.DebugDirectoryEntry> System.Reflection.PortableExecutable.PEReader.ReadDebugDirectory()'. at Coverlet.Core.Helpers.InstrumentationHelper.HasPdb(String module, Boolean& embedded) at Coverlet.Core.Instrumentation.Instrumenter.CanInstrument() in /_/src/coverlet.core/Instrumentation/Instrumenter.cs:line 107 TpTrace Warning: 0 : 6332, 1, 2023/09/20, 21:26:41.391, 6181671642758, datacollector.exe, [coverlet]Unable to instrument module: 'C:\agent\devops\_work\31\s\JusticeNext\CMIJustice.Tests\publish\AutoFixture.dll' System.MissingMethodException: Method not found: 'System.Collections.Immutable.ImmutableArray1 System.Reflection.PortableExecutable.PEReader.ReadDebugDirectory()'. at Coverlet.Core.Helpers.InstrumentationHelper.HasPdb(String module, Boolean& embedded) at Coverlet.Core.Instrumentation.Instrumenter.CanInstrument() in //src/coverlet.core/Instrumentation/Instrumenter.cs:line 107 TpTrace Warning: 0 : 6332, 1, 2023/09/20, 21:26:41.391, 6181671645780, datacollector.exe, [coverlet]Unable to instrument module: 'C:\agent\devops_work\31\s\JusticeNext\CMIJustice.Tests\publish\AutoFixture.Xunit2.dll' System.MissingMethodException: Method not found: 'System.Collections.Immutable.ImmutableArray`1 System.Reflection.PortableExecutable.PEReader.ReadDebugDirectory()'. at Coverlet.Core.Helpers.InstrumentationHelper.HasPdb(String module, Boolean& embedded) at Coverlet.Core.Instrumentation.Instrumenter.CanInstrument() in //src/coverlet.core/Instrumentation/Instrumenter.cs:line 107 TpTrace Warning: 0 : 6332, 1, 2023/09/20, 21:26:41.391, 6181671649294, datacollector.exe, [coverlet]Unable to instrument module: 'C:\agent\devops_work\31\s\JusticeNext\CMIJustice.Tests\publish\AutoMapper.dll' System.MissingMethodException: Method not found: 'System.Collections.Immutable.ImmutableArray1<System.Reflection.PortableExecutable.DebugDirectoryEntry> System.Reflection.PortableExecutable.PEReader.ReadDebugDirectory()'. at Coverlet.Core.Helpers.InstrumentationHelper.HasPdb(String module, Boolean& embedded) at Coverlet.Core.Instrumentation.Instrumenter.CanInstrument() in /_/src/coverlet.core/Instrumentation/Instrumenter.cs:line 107 TpTrace Warning: 0 : 6332, 1, 2023/09/20, 21:26:41.391, 6181671652176, datacollector.exe, [coverlet]Unable to instrument module: 'C:\agent\devops\_work\31\s\JusticeNext\CMIJustice.Tests\publish\Castle.Core.dll' System.MissingMethodException: Method not found: 'System.Collections.Immutable.ImmutableArray1 System.Reflection.PortableExecutable.PEReader.ReadDebugDirectory()'. at Coverlet.Core.Helpers.InstrumentationHelper.HasPdb(String module, Boolean& embedded)

Coverage files are created but are empty - no code cover results created

Configuration (please complete the following information): Please provide more information on your .NET configuration:

Bertk commented 8 months ago

Thanks for reporting 🙏

Please try again with latest version e.g. <PackageVersion Include="coverlet.collector" Version="6.0.1-preview.20.g3ec85e7a33" />

This version was used to generate this code coverage report (azure devops, net7.0)

cforbesywam commented 8 months ago

Hi Bert,

Thank you so much. I loaded up the latest nightly build as per your suggestion: 6.0.1-preview.20.g3ec85e7a33

Unfortunately, we are still not getting code coverage results:

Data collector 'XPlat code coverage' message: [coverlet]Coverlet.Collector.Utilities.CoverletDataCollectorException: CoverletCoverageDataCollector: Failed to get coverage result ---> System.IO.FileNotFoundException: Could not load file or assembly 'System.Buffers, Version=4.0.2.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' or one of its dependencies. The system cannot find the file specified. at System.Text.Json.JsonDocument.ParseValue(ReadOnlyMemory1 json, JsonDocumentOptions options) at System.Text.Json.Nodes.JsonNode.Parse(String json, Nullable1 nodeOptions, JsonDocumentOptions documentOptions) at Coverlet.Core.Coverage.CalculateCoverage() in //src/coverlet.core/Coverage.cs:line 375 at Coverlet.Core.Coverage.GetCoverageResult() in //src/coverlet.core/Coverage.cs:line 163 at Coverlet.Collector.DataCollection.CoverageManager.GetCoverageResult() in //src/coverlet.collector/DataCollection/CoverageManager.cs:line 95 --- End of inner exception stack trace --- at Coverlet.Collector.DataCollection.CoverageManager.GetCoverageResult() in //src/coverlet.collector/DataCollection/CoverageManager.cs:line 100 at Coverlet.Collector.DataCollection.CoverletCoverageCollector.OnSessionEnd(Object sender, SessionEndEventArgs e) in /_/src/coverlet.collector/DataCollection/CoverletCoverageCollector.cs:line 164.

coverage files are empty:

<?xml version="1.0" encoding="utf-8"?> <!DOCTYPE coverage SYSTEM http://cobertura.sourceforge.net/xml/coverage-04.dtd>

Are then any changes needed on my end to get this working or is this strictly an issue with the collector?

Colin

From: Bert @.> Sent: Thursday, October 26, 2023 2:11 AM To: coverlet-coverage/coverlet @.> Cc: Colin Forbes @.>; Author @.> Subject: Re: [coverlet-coverage/coverlet] [BUG] System.MissingMethodException: Method not found: System.Collections.Immutable.ImmutableArray 1 (Issue #1536)

Thanks for reporting 🙏

Please try again with latest version e.g.

This version was used to generate this code coverage report (azure devops, net7.0)https://dev.azure.com/bertk0374/arcade-light/_build/results?buildId=1381&view=codecoverage-tab

— Reply to this email directly, view it on GitHubhttps://github.com/coverlet-coverage/coverlet/issues/1536#issuecomment-1780623291, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ACMU5I6JBB2K7BCDTM4P4GTYBILI3AVCNFSM6AAAAAA5A5MAZWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTOOBQGYZDGMRZGE. You are receiving this because you authored the thread.Message ID: @.**@.>>

Bertk commented 8 months ago

Thank you for the update. Please add this statements to your test project and run again your test project.

<PackageReference Include="System.Buffers" Version="4.5.1" />
<PackageReference Include="System.Memory" Version="4.5.5" />

Which net7.0 SDK are you using? My test project uses version "7.0.403".

cforbesywam commented 8 months ago

Which net7.0 SDK are you using? My test project uses version "7.0.403".

It looks like I'm using 7.0.402 locally but just upgraded to 7.0.403. The build server is running 7.0.11 which is the same as VS SDK 7.0.401

I can see about getting the build server upgraded to the latest as well.

Hope that helps. I'll try adding missing references manually as per your suggestions and let you.

Bertk commented 7 months ago

Hope that helps. I'll try adding missing references manually as per your suggestions and let you.

Can you please share the latest status on this issue.

Bertk commented 4 months ago

coverlet V6.0.1 is released.