Skip to content

Fix WinRT.Host assembly probing boundary - #2551

Open
Chris Guzak (ChrisGuzak) wants to merge 6 commits into
microsoft:masterfrom
ChrisGuzak:fix/winrt-host-probe-boundary
Open

Fix WinRT.Host assembly probing boundary#2551
Chris Guzak (ChrisGuzak) wants to merge 6 commits into
microsoft:masterfrom
ChrisGuzak:fix/winrt-host-probe-boundary

Conversation

@ChrisGuzak

@ChrisGuzak Chris Guzak (ChrisGuzak) commented Sep 7, 2026

Copy link
Copy Markdown
Member

Fixes #2550.

WinRT.Host.dll is 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:

  • Mixed-case generic host: MixedCaseGeneric\wInRt.HoSt.dll has a conflicting wInRt.dll; fixed logic treats it as the generic host and probes by class name.
  • Dotted-directory positive: class-name fallback finds TestHost.ProbeByClass.dll inside the dotted host directory instead of accepting an outside Dotted.dll.
  • Dotted-directory negative: when the class-derived target is absent, probing returns ERROR_MOD_NOT_FOUND instead of accepting the outside Dotted.dll.
  • Multi-dot renamed host: Alpha.Beta.Host.dll stays within its host directory and preserves .Server.dll precedence. The .Server.dll test assembly intentionally lacks the requested class, so CLASS_E_CLASSNOTAVAILABLE proves .Server.dll was selected before .dll.
  • Generic-host class fallback: when both TestHost.Server.dll and TestHost.dll exist, the expected CLASS_E_CLASSNOTAVAILABLE proves .Server.dll wins 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:

  • Built src\Authoring\WinRT.Host\WinRT.Host.vcxproj successfully.
  • Built src\Tests\HostTest\HostTest.vcxproj for Debug|x64 and ran HostTest.exe: 14 tests run, 14 passed.
  • Temporarily reset only src\Authoring\WinRT.Host\WinRT.Host.cpp to 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's test_component_fast VS 18.0 toolset fallback to v143 instead of missing v140, and used a temporary local SkipLocalSourceGeneratorAnalyzer gate to avoid an unrelated WinRT.SourceGenerator.Roslyn4080 BadImageFormatException. Those environment workarounds are not part of this PR.

Chris Guzak (WINDOWS) 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

WinRT.Host misidentifies standard casing and probes outside its directory

1 participant