SteveGilham / altcover

Cross-platform coverage gathering and processing tool set for dotnet/.Net Framework and Mono
MIT License
498 stars 18 forks source link

Attempting to follow guidance from #102 for protobuf but it continues to be instrumented. #176

Closed simkin2004 closed 1 year ago

simkin2004 commented 1 year ago

Using AltCover 8.3.838, this line worked on Github build servers ubuntu 20.04.5 successfully at least until 27 OCT 2022.

dotnet test /p:AltCover="true" /p:CopyLocalLockFileAssemblies="true" /p:AltCoverLocalSource=true /p:AltCoverAttributeFilter=ExcludeFromCodeCoverage --configuration Release --no-build --no-restore --verbosity normal

I re-tested on 6 DEC 2022 and it began failing on ubuntu 22.04.1 with the same error as #102.

I attempted to add the following arguments one at a time to the command line above and each failed with the same issue. I followed the guidance for usage from #124 /p:AltCoverAssemblyFilter=protobuf-net /p:AltCoverAssemblyFilter=protobuf-net.Core /p:AltCoverAssemblyExcludeFilter=protobuf-net /p:AltCoverAssemblyExcludeFilter=protobuf-net.Core

I downgraded back to ubuntu 20.04.5 and retested each of these scenarios which all failed with the same error as #102.

I changed to windows-latest to see if I could reproduce the behavior from 27 OCT 2022 on windows and it failed with the same error as #102.

I will upgrade to the latest version to see if that changes anything, but I wanted to check with you to see if I am using the parameters incorrectly.

SteveGilham commented 1 year ago

In between those dates, .net 7.0 was released and adopted as the default environment by the GitHub servers. At the initial release, SDK 7.0.100, there is a serious regression with dotnet test in which properties on the command line are not accurately forwarded. In your case, the effective command line being executed is

dotnet test /p:AltCover="true" --configuration Release --no-build --no-restore --verbosity normal

as for some strange reason a property specified as the first argument to dotnet test is still forwarded, unlike any others appearing later.

Until SDK 7.0.101 is released (which is promised to have the fix), the following workrounds are possible - 1) ensure a dotnet 6.0 SDK is installed, and lock to it in a global.json, carrying on as if it were still October 2) set properties in the environment instead e.g. in a Bash script

export AltCover=true
export CopyLocalLockFileAssemblies=true
export AltCoverLocalSource=true
export AltCoverAttributeFilter=ExcludeFromCodeCoverage
dotnet test --configuration Release --no-build --no-restore --verbosity normal

See the FAQ for more details

simkin2004 commented 1 year ago

Apologies for opening a duplicate of #174.
I just found it with the same information. Thank you for your kindness, sir.