Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions dev/AppLifecycle/Association.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,17 @@ namespace winrt::Microsoft::Windows::AppLifecycle::implementation
seed = wil::GetModuleFileNameW<std::wstring>(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<std::wstring> hasher;
auto hash = hasher(seed);
uint64_t hash64 = static_cast<uint64_t>(hash);
Expand Down
20 changes: 20 additions & 0 deletions test/AppLifecycle/FunctionalTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
};
}
3 changes: 3 additions & 0 deletions test/AppLifecycle/pch.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,8 @@
#include <winrt/Windows.System.h>
#include <winrt/Microsoft.Windows.AppLifecycle.h>

// Include Association.h for implementation namespace access
#include "../../dev/AppLifecycle/Association.h"

#include <WindowsAppRuntime.Test.Bootstrap.h>
namespace TP = ::Test::Packages;