diff --git a/dev/AppLifecycle/Association.cpp b/dev/AppLifecycle/Association.cpp index f08a7e5ed4..9cbb6d443c 100644 --- a/dev/AppLifecycle/Association.cpp +++ b/dev/AppLifecycle/Association.cpp @@ -26,6 +26,17 @@ namespace winrt::Microsoft::Windows::AppLifecycle::implementation seed = wil::GetModuleFileNameW(nullptr); } + // Convert to lowercase if it appears to be a file path to ensure case insensitivity + if (!seed.empty() && + (seed.find(L'\\') != std::wstring::npos || + (seed.size() > 1 && seed[1] == L':'))) + { + // Make a mutable copy of the string + std::wstring lowercaseSeed = seed; + CharLowerW(&lowercaseSeed[0]); + seed = lowercaseSeed; + } + std::hash hasher; auto hash = hasher(seed); uint64_t hash64 = static_cast(hash); diff --git a/test/AppLifecycle/FunctionalTests.cpp b/test/AppLifecycle/FunctionalTests.cpp index 3f969ee795..9159cfb398 100644 --- a/test/AppLifecycle/FunctionalTests.cpp +++ b/test/AppLifecycle/FunctionalTests.cpp @@ -406,5 +406,25 @@ namespace Test::AppLifecycle Execute(L"AppLifecycleTestApp.exe", L"/UnregisterProtocol", g_deploymentDir); WaitForEvent(event, m_failed); } + + TEST_METHOD(FileTypeActivation_CaseInsensitivity) + { + // This test verifies that ComputeAppId is case-insensitive for file paths + // by checking that two paths that differ only by case produce the same AppId + + // Get implementation namespace to access ComputeAppId + using namespace winrt::Microsoft::Windows::AppLifecycle::implementation; + + // Test paths with different case + std::wstring path1 = L"C:\\Users\\user\\App\\app.exe"; + std::wstring path2 = L"C:\\Users\\user\\App\\App.exe"; + + // Verify that the AppIds calculated from the paths are the same + auto appId1 = ComputeAppId(path1); + auto appId2 = ComputeAppId(path2); + + // The AppIds should be identical regardless of the case + VERIFY_ARE_EQUAL(appId1, appId2); + } }; } diff --git a/test/AppLifecycle/pch.h b/test/AppLifecycle/pch.h index 26d190ff0c..fd553d7550 100644 --- a/test/AppLifecycle/pch.h +++ b/test/AppLifecycle/pch.h @@ -31,5 +31,8 @@ #include #include +// Include Association.h for implementation namespace access +#include "../../dev/AppLifecycle/Association.h" + #include namespace TP = ::Test::Packages;