Fix WinRT.Host assembly probing boundary - #2551
Open
Chris Guzak (ChrisGuzak) wants to merge 6 commits into
Open
Conversation
added 6 commits
September 7, 2026 13:11
Recognize the standard generic host filename without regard to case and generate renamed-host candidates only within the host directory. Fixes microsoft#2550 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 987e3253-f16a-4979-8175-d9ed9cea06ca
Exercise renamed-host fallback from a dotted host directory while a conflicting assembly exists outside it. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 987e3253-f16a-4979-8175-d9ed9cea06ca
Collapse HostTest deployment metadata and add a negative regression that rejects an escaped parent-directory candidate when the class-derived target is absent. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 987e3253-f16a-4979-8175-d9ed9cea06ca
Replace capture-based local probe lambdas with helper functions that take immutable inputs and shared probe history explicitly. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 987e3253-f16a-4979-8175-d9ed9cea06ca
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.
Fixes #2550.
WinRT.Host.dllis the standard authoring target spelling, but the host compared it case-sensitively against a lowercase literal. That sent generic hosts through renamed-host probing. The probe loop also shortened the entire host path, so it could remove a dotted directory segment and select an unrelated parent-directory assembly.Recognize the generic host filename with an ordinal case-insensitive comparison. Keep the host directory separate from the target filename, shorten suffixes only within that filename, and join every candidate to the unchanged host directory. The probing flow now uses explicit helper parameters instead of capture-based local lambdas: the initial target name is copied into local shortening state, and the probe history is intentionally shared across host-name and class-name phases.
The input path and class ID helpers now take immutable references rather than copies.
Added HostTest coverage for the bug and nearby special cases:
MixedCaseGeneric\wInRt.HoSt.dllhas a conflictingwInRt.dll; fixed logic treats it as the generic host and probes by class name.TestHost.ProbeByClass.dllinside the dotted host directory instead of accepting an outsideDotted.dll.ERROR_MOD_NOT_FOUNDinstead of accepting the outsideDotted.dll.Alpha.Beta.Host.dllstays within its host directory and preserves.Server.dllprecedence. The.Server.dlltest assembly intentionally lacks the requested class, soCLASS_E_CLASSNOTAVAILABLEproves.Server.dllwas selected before.dll.TestHost.Server.dllandTestHost.dllexist, the expectedCLASS_E_CLASSNOTAVAILABLEproves.Server.dllwins without depending on CLR assembly-load order.Also collapsed HostTest deployment metadata that was redundantly conditioned for every configuration/platform even though every value was
true.Validation:
src\Authoring\WinRT.Host\WinRT.Host.vcxprojsuccessfully.src\Tests\HostTest\HostTest.vcxprojforDebug|x64and ranHostTest.exe: 14 tests run, 14 passed.src\Authoring\WinRT.Host\WinRT.Host.cppto the pre-fix base while keeping the new tests, rebuilt, and reran the bug-focused tests. Old code fails the three defect regressions: mixed-case generic host, dotted-directory positive, and dotted-directory negative all fail, 0 passed / 3 failed.Local validation notes: this ARM64 dev box has only VS 18 installed. To run HostTest locally, I fetched
src\TestWinRT, restored NuGet packages, locally mapped TestWinRT'stest_component_fastVS 18.0 toolset fallback tov143instead of missingv140, and used a temporary localSkipLocalSourceGeneratorAnalyzergate to avoid an unrelatedWinRT.SourceGenerator.Roslyn4080BadImageFormatException. Those environment workarounds are not part of this PR.