You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Having a const field on a PowerShell cmdlet causes the warning:
Unable to instrument module: ...../....MyModule.dll
Coverlet.Core.Exceptions.CecilAssemblyResolutionException: AssemblyResolutionException for 'System.Management.Automation, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. Try to add true to test projects or pass '/p:CopyLocalLockFileAssemblies=true' option to the 'dotnet test' command-line
---> Mono.Cecil.AssemblyResolutionException: Failed to resolve assembly: 'System.Management.Automation, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'
Open src\PSCompression\Commands\GetZipEntryCommand.cs and move the const WildcardOptions options from BeginProcessing method to a class field
Run .\build.ps1 -Task Build, Test
Expected behavior
No warnings when testing the project.
Actual behavior
Unable to instrument module: /home/runner/work/PSCompression/PSCompression/output/PSCompression/2.1.0/bin/netstandard2.0/PSCompression.dll
Coverlet.Core.Exceptions.CecilAssemblyResolutionException: AssemblyResolutionException for 'System.Management.Automation, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. Try to add <PreserveCompilationContext>true</PreserveCompilationContext> to test projects </PropertyGroup> or pass '/p:CopyLocalLockFileAssemblies=true' option to the 'dotnet test' command-line
---> Mono.Cecil.AssemblyResolutionException: Failed to resolve assembly: 'System.Management.Automation, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'
--- End of inner exception stack trace ---
at Coverlet.Core.Instrumentation.NetstandardAwareAssemblyResolver.TryWithCustomResolverOnDotNetCore(AssemblyNameReference name) in /_/src/coverlet.core/Instrumentation/CecilAssemblyResolver.cs:line 217
at Coverlet.Core.Instrumentation.NetstandardAwareAssemblyResolver.Resolve(AssemblyNameReference name) in /_/src/coverlet.core/Instrumentation/CecilAssemblyResolver.cs:line 1[29](https://github.com/santisq/PSCompression/actions/runs/12713283173/job/35440961122#step:6:30)
at Mono.Cecil.MetadataResolver.Resolve(TypeReference type)
at Mono.Cecil.ModuleDefinition.Resolve(TypeReference type)
at Mono.Cecil.TypeReference.Resolve()
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.AddField(FieldDefinition field)
at Mono.Cecil.MetadataBuilder.AddFields(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.<BuildMetadata>b__2_0(MetadataBuilder builder, MetadataReader _)
at Mono.Cecil.ModuleDefinition.Read[TItem,TRet](TItem item, Func`3 read)
at Mono.Cecil.ModuleWriter.BuildMetadata(ModuleDefinition module, MetadataBuilder metadata)
at Mono.Cecil.ModuleWriter.Write(ModuleDefinition module, Disposable`1 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 [32](https://github.com/santisq/PSCompression/actions/runs/12713283173/job/35440961122#step:6:33)5
at Coverlet.Core.Instrumentation.Instrumenter.Instrument() in /_/src/coverlet.core/Instrumentation/Instrumenter.cs:line 148
at Coverlet.Core.Coverage.PrepareModules() in /_/src/coverlet.core/Coverage.cs:line 134
Configuration (please complete the following information):
Please provide more information on your .NET configuration:
Which coverlet package and version was used? 6.0.3 - This issue also happened when testing different versions too.
Which version of .NET is the code running on? I'm not sure if this question relates to the target framework I'm compiling for (netstandard2.0) or what .NET version PowerShell is running on (PowerShell 7 runs on .NET 8 and PowerShell 5.1 runs on .NET Framework 4)
What OS and version, and what distro if applicable? This happened to me locally on Windows 10, and also in GitHub workers using windows-latest and ubuntu-latest.
What is the architecture (x64, x86, ARM, ARM64)? x64
Do you know whether it is specific to that configuration? Not sure
Describe the bug
Having a
const
field on a PowerShell cmdlet causes the warning:The field in question:
And, in turn, this also cause the coverage result to be all
0%
:To Reproduce
Moving the
const
in https://github.com/santisq/PSCompression/blob/main/src/PSCompression/Commands/GetZipEntryCommand.cs#L50-L52 as a field causes the warning. If changing it to astatic readonly
also solves the problem.Steps to reproduce:
const WildcardOptions options
fromBeginProcessing
method to a class field.\build.ps1 -Task Build, Test
Expected behavior
No warnings when testing the project.
Actual behavior
Configuration (please complete the following information):
Please provide more information on your .NET configuration:
netstandard2.0
) or what .NET version PowerShell is running on (PowerShell 7 runs on .NET 8 and PowerShell 5.1 runs on .NET Framework 4)Additional context
As you can see this issue happens on the 3 workers (Linux PowerShell 7 / Windows PowerShell 7 / Windows PowerShell 5.1) when running tests: https://github.com/santisq/PSCompression/actions/runs/12713283173/job/35440961122 (Expand "Run Tests - ....").
The text was updated successfully, but these errors were encountered: