winget-cli icon indicating copy to clipboard operation
winget-cli copied to clipboard

Test host for in-proc COM module validation

Open JohnMcPMS opened this issue 3 weeks ago • 0 comments

Fixes #5869 and #5870 in the current code and will be backported to 1.12

Change

Adds a test host that leverages the in-proc COM module (as built locally) to validate various lifetime management scenarios. It has numerous options for controlling the scenarios, as well as an extensible model for adding different tests in the future.

It was able to hit the faults described in the linked issues, and the fixes are included:

  • Move the ServerShutdownSynchronization to integrate with the signal monitoring directly, rather than registering as an object. This also means that there is no need to unregister, preventing the construction of a TerminationSignalHandler.
  • Remove the call that terminates COM objects from the DLL_PROCESS_DETACH handler. If the caller is using the module properly via COM, the DllCanUnloadNow calls should take care of things. If the process is exiting without that call, leaking objects will be fine (the caller didn't uninitialize COM, so it is doubtful they care about a clean exit).

Additionally, these changes were made to support additional scenarios:

  • Add the WinRT type names to the manifest file so that WinRT activation can work.
  • Fix the activation factories to be counted objects for the module.
  • Add a setting that allows the caller to prevent DllCanUnloadNow from checking the object state, always returning that it cannot unload now. This can be used to prevent the module from being unloaded (and any active static objects alive) even if no external objects are active.

Validation

The test host is run with various parameters as part of the E2E tests. The linked issues are represented within the set of tests, as are several other scenarios.

Microsoft Reviewers: Open in CodeFlow

JohnMcPMS avatar Dec 05 '25 20:12 JohnMcPMS