Repository navigation
Description
Hi Team,
I first want to say thank you for making this tool and continuing to upgrade it to the MTP test runner.
I was exploring moving our project to MTP while upgrading to dotnet 10.0 and one thing I noticed was that I was getting different coverage results between using legacy and MTP. I (really Claude AI) managed to track it down to a few behavior changes between the two and was wondering if we could have a discussion about giving the option to restore the original behavior.
SkipAutoProps is true by default
So, in legacy SkipAutoProps is false by default. This wouldn't be a big deal but you actually can't set this option to false using the option --coverlet-skip-auto-props. The following code fragment shows the bug: if you don't set it, the value is true by default but if you do set it, it is also true.
CoverageConfiguration.cs
public bool SkipAutoProps =>
GetBoolOptionWithDefault(CoverletOptionNames.SkipAutoProps, defaultValue: true);
private bool GetBoolOptionWithDefault(string optionName, bool defaultValue)
{
bool isSet = _commandLineOptions.IsOptionSet(optionName);
if (isSet)
{
_logger?.LogDebug($"[Explicitly set] {optionName}: true");
return true;
}
_logger?.LogDebug($"[Default] {optionName}: {defaultValue}");
return defaultValue;
}Additional default ExcludeByAttributes
In legacy, only the ExcludeFromCodeCoverageAttribute attribute is included by default, but in MTP it includes GeneratedCodeAttribute and CompilerGeneratedAttribute attributes which seems to be added to compiled code automatically by the SDK. This caused coverage discrepencies during testing. There seems to be no way to change the defaults. Maybe we could add an option to exclude defaults as an escape hatch (maybe --coverlet-no-exclude-by-attribute-defaults), or whatever ideas you have.
CoverageConfiguration.cs
private static readonly string[] s_defaultExcludeByAttributes =
[
"ExcludeFromCodeCoverage",
"ExcludeFromCodeCoverageAttribute",
"GeneratedCodeAttribute",
"CompilerGeneratedAttribute"
];Timestamp added to coverage file
This one i can definetly see the benefit of having, but can we make it opt-in or some way to disable it via options? For example, we could have an option --coverlet-postfix-timestamp that when set includes the timestamp in the file, otherwise use the default legacy behavior
Activity
james-newell-forge commentedon Apr 5, 2026
One more thing, I could submit a PR if you wanted some dev help with these changes. I already made them on my local, so it wouldn't take much work.
pinkfloydx33 commentedon Apr 5, 2026
I noticed the same as the above and would also benefit from the same escape hatches
Also missing is a way to specify the output directory. I realize it uses the
results-directoryflag but either an option to completely bypass that or a way to set a sub-folder within said directory would be appreciated. Our CI is expecting coverage to be in a distinct location from test result files. I can manually post-process but its a gap from previous behavior which I could control with msbuild flagsBertk commentedon Apr 6, 2026
Thank you for the helpful information. Could you please try the preview version from the Coverlet nightly build? While it may not resolve all issues, it includes improvements such as “Add timestamp to coverage report filenames for uniqueness” (#1870) and “Add --coverlet-file-prefix option for unique report files” (#1869). The preview version also supports the .NET 10 SDK target framework.
The default values can be avoided using a configuration file.
james-newell-forge commentedon Apr 13, 2026
Hi @Bertk, thank you for fixing part 1. I was using
TestingPlatformCommandLineArgumentsas a quick migration from the old msbuild properties way, but I will take a look at the json file and see if that suffices.james-newell-forge commentedon Apr 13, 2026
Actually after looking at this, this won't work because this is
ExcludeByAttribute, notExcludeFiltersandExcludeByAttributehas the new defaults sets for both command line options or config file.Bertk commentedon Apr 14, 2026
coverlet.MTPis an implementation for the Microsoft Testing Platform and is intended to replacecoverlet.collector. It comes with sensible default settings, but you can customize its behavior using a configuration file if needed.You can also review the effective settings applied during execution by checking the diagnostic log files.
Please use latest version from coverlet nightly build and verify this behavior.
Bump coverlet.collector from 8.0.1 to 10.0.0 (#82)
Merged PR 928: chore(deps): update coverlet.collector to 10.0.0
Merged PR 927: chore(deps): update coverlet.collector to 10.0.0
33 remaining items
chore(csharp): bump coverlet.collector from 6.0.4 to 10.0.1 (#52)
chore(csharp): Bump coverlet.collector from 8.0.1 to 10.0.1 (#4347)
Bump coverlet.msbuild from 8.0.0 to 10.0.1 (#330)
chore(deps): Bump the test-dependencies group with 1 update (#34)
Bump coverlet.collector from 8.0.1 to 10.0.1 (#52)
chore(deps): Bump coverlet.collector from 6.0.2 to 10.0.1 (#13)
Bump coverlet.collector and 3 others (#6)
Bump coverlet.collector from 6.0.4 to 10.0.1 (#19)
Bump coverlet.collector and 7 others (#86)
chore: Bump coverlet.collector from 8.0.1 to 10.0.1 (#283)
Bump coverlet.collector from 6.0.4 to 10.0.1 (#6)
[nuget][Find]- Bump Azure.Identity and 26 others (#705)
Bump the test-dependencies group with 3 updates (#2)
Bump coverlet.msbuild from 8.0.0 to 10.0.1 (#893)
chore(deps): Bump coverlet.collector from 6.0.4 to 10.0.1 (#438)