-
Notifications
You must be signed in to change notification settings - Fork 6k
Description
Description
Running dotnet test --collect:"Code Coverage" disables dynamic native instrumentation by default. This change affects how code coverage is collected from native code. It does not affect how code coverage is collected from managed code.
<EnableDynamicNativeInstrumentation>false</EnableDynamicNativeInstrumentation> option is set by default from dotnet test / vstest. If the option was explicitly set by user in runsettings, it will not be overriden.
Version
.NET 10 GA
Previous behavior
Dynamic native instrumentation was enabled by default, and used a fallback for native modules when static native instrumentation could not be used. As described in https://learn.microsoft.com/visualstudio/test/customizing-code-coverage-analysis?view=vs-2022#static-and-dynamic-native-instrumentation
New behavior
Dynamic native instrumentation is disabled by default. When re-enabled, it might fail with "The code execution cannot proceed because covrun64.dlls was not found." This error can also happen for covrun32.dll in 32-bit process.
Type of breaking change
- Binary incompatible: Existing binaries might encounter a breaking change in behavior, such as failure to load or execute, and if so, require recompilation.
- Source incompatible: When recompiled using the new SDK or component or to target the new runtime, existing source code might require source changes to compile successfully.
- Behavioral change: Existing binaries might behave differently at run time.
Reason for change
Dynamic native instrumentation was enabled by default, to keep backwards compatibility in dotnet test, but its way of injecting dlls into the process is not standard, and with security hardening changes in .NET 10 runtime it fails to find the linked dll. Causing process crash, and the following error: dotnet/sdk#50950
The error might not be visible in non-interactive sessions or in command line, but the process crash happens.
The dynamic native instrumentation is already disabled by default by dotnet-coverage, an alternative way to collect code coverage using the same underlying tools. And by default disabled for solutions in Visual Studio that don't have native projects.
Recommended action
Users that collect coverage on solutions that don't have any native components should not be affected. They might observe increased performance of collecting coverage.
Users that collect coverage on solutions that include native component, such as C++ projects and wish to re-enable dynamic native instrumentation should remain on NET9, or disable collecting code coverage until the problem is solved.
Users who wish to globally opt-out from this new default can set VSTEST_DISABLE_DYNAMICNATIVE_CODECOVERAGE_DEFAULT_SETTING=1 environment variable.
Feature area
SDK
Affected APIs
No response
Metadata
Metadata
Assignees
Labels
Type
Projects
Status
