Replicate in-proc collector improvements from PR #1987 to MTP handler - #1988
Merged
Bertk merged 1 commit intoJul 22, 2026
Merged
Conversation
This applies the reliability improvements made to the legacy in-proc collector (PR #1987) to the new Microsoft Testing Platform (MTP) in-process handler: 1. Replace assembly scanning with `AppDomain` registry: `GetAssemblies()` + `GetTypes()` scanning silently drops any assembly that throws `ReflectionTypeLoadException`. By using the `ConcurrentBag<EventHandler>` registry populated during module load, we avoid reflection entirely and prevent silent coverage loss. 2. Always log flush failures: Exceptions thrown by `UnloadModule` are now logged unconditionally as errors. The `COVERLET_MTP_INPROC_EXCEPTIONLOG_ENABLED` environment variable now controls whether these exceptions are rethrown to abort the test run, rather than whether they are logged at all. 3. Fix environment variable propagation: Corrected a bug in `CoverletExtensionEnvironmentVariableProvider` where it was mistakenly passing the out-of-proc variable (`COVERLET_MTP_EXCEPTIONLOG_ENABLED`) to the test host instead of the correct in-proc variable (`COVERLET_MTP_INPROC_EXCEPTIONLOG_ENABLED`). Signed-off-by: Bart Koelman <10324372+bkoelman@users.noreply.github.com>
Contributor
Author
|
I have run all tests on Windows and in WSL/Ubuntu, but have not tried with the coverlet-examples. |
bkoelman
marked this pull request as ready for review
July 20, 2026 23:14
bkoelman
force-pushed
the
fix-assembly-scanning-mtp
branch
from
July 20, 2026 23:14
43576d0 to
43680e9
Compare
Bertk
approved these changes
Jul 22, 2026
This was
linked to
issues
Jul 24, 2026
This was referenced Sep 27, 2026
This was referenced Oct 4, 2026
Open
Bump the dotnet-dependencies group with 9 updates
SaiTejaReddyYeldandi/CSharp_RiskFeed_Automation#12
Open
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR applies the reliability improvements made to the legacy in-proc collector (PR #1987) to the new Microsoft Testing Platform (MTP) in-process handler:
AppDomainregistry:GetAssemblies()+GetTypes()scanning silently drops any assembly that throwsReflectionTypeLoadException. By using theConcurrentBag<EventHandler>registry populated during module load, we avoid reflection entirely and prevent silent coverage loss.UnloadModuleare now logged unconditionally as errors. TheCOVERLET_MTP_INPROC_EXCEPTIONLOG_ENABLEDenvironment variable now controls whether these exceptions are rethrown to abort the test run, rather than whether they are logged at all.CoverletExtensionEnvironmentVariableProviderwhere it was mistakenly passing the out-of-proc variable (COVERLET_MTP_EXCEPTIONLOG_ENABLED) to the test host instead of the correct in-proc variable (COVERLET_MTP_INPROC_EXCEPTIONLOG_ENABLED).