[PT Run] Localized file paths (Part 1): Update helper class and Program plugin (#20024)

* make helper non-static and add cache

* uwp app: add localized path

* Win32Program: Rename variable

* spell fix

* Win32Program: Localized paths

* fix invalid var name

* spell fix

* fix build

* test new shell localization helper

* fixes

* fix crash

* replace old helper class

* replace old helper class 2

* Helper improvements

* last changes

* add docs info

* remove left-over

* remove second left-over
This commit is contained in:
Heiko
2023-02-13 17:30:18 +01:00
committed by GitHub
parent 4c3b470ec0
commit 6e4a2898ab
11 changed files with 178 additions and 95 deletions

View File

@@ -22,7 +22,7 @@ namespace Microsoft.Plugin.Program.UnitTests.Programs
Name = "Imaging Devices",
ExecutableName = "imagingdevices.exe",
FullPath = "c:\\program files\\windows photo viewer\\imagingdevices.exe",
LnkResolvedPath = null,
LnkFilePath = null,
AppType = Win32Program.ApplicationType.Win32Application,
};
@@ -31,7 +31,7 @@ namespace Microsoft.Plugin.Program.UnitTests.Programs
Name = "Notepad",
ExecutableName = "notepad.exe",
FullPath = "c:\\windows\\system32\\notepad.exe",
LnkResolvedPath = "c:\\users\\powertoys\\appdata\\roaming\\microsoft\\windows\\start menu\\programs\\accessories\\notepad.lnk",
LnkFilePath = "c:\\users\\powertoys\\appdata\\roaming\\microsoft\\windows\\start menu\\programs\\accessories\\notepad.lnk",
AppType = Win32Program.ApplicationType.Win32Application,
};
@@ -40,7 +40,7 @@ namespace Microsoft.Plugin.Program.UnitTests.Programs
Name = "Notepad",
ExecutableName = "notepad.exe",
FullPath = "c:\\windows\\system32\\notepad.exe",
LnkResolvedPath = "c:\\programdata\\microsoft\\windows\\start menu\\programs\\accessories\\notepad.lnk",
LnkFilePath = "c:\\programdata\\microsoft\\windows\\start menu\\programs\\accessories\\notepad.lnk",
AppType = Win32Program.ApplicationType.Win32Application,
};
@@ -50,7 +50,7 @@ namespace Microsoft.Plugin.Program.UnitTests.Programs
ExecutableName = "cmd.exe",
FullPath = "c:\\windows\\system32\\cmd.exe",
Arguments = @"/E:ON /V:ON /K ""C:\Program Files\Microsoft SDKs\Azure\.NET SDK\v2.9\\bin\setenv.cmd""",
LnkResolvedPath = "c:\\programdata\\microsoft\\windows\\start menu\\programs\\microsoft azure\\microsoft azure sdk for .net\\v2.9\\microsoft azure command prompt - v2.9.lnk",
LnkFilePath = "c:\\programdata\\microsoft\\windows\\start menu\\programs\\microsoft azure\\microsoft azure sdk for .net\\v2.9\\microsoft azure command prompt - v2.9.lnk",
AppType = Win32Program.ApplicationType.Win32Application,
};
@@ -60,7 +60,7 @@ namespace Microsoft.Plugin.Program.UnitTests.Programs
ExecutableName = "cmd.exe",
FullPath = "c:\\windows\\system32\\cmd.exe",
Arguments = @"/k ""C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvars64.bat""",
LnkResolvedPath = "c:\\programdata\\microsoft\\windows\\start menu\\programs\\visual studio 2019\\visual studio tools\\vc\\x64 native tools command prompt for vs 2019.lnk",
LnkFilePath = "c:\\programdata\\microsoft\\windows\\start menu\\programs\\visual studio 2019\\visual studio tools\\vc\\x64 native tools command prompt for vs 2019.lnk",
AppType = Win32Program.ApplicationType.Win32Application,
};
@@ -69,7 +69,7 @@ namespace Microsoft.Plugin.Program.UnitTests.Programs
Name = "Command Prompt",
ExecutableName = "cmd.exe",
FullPath = "c:\\windows\\system32\\cmd.exe",
LnkResolvedPath = "c:\\users\\powertoys\\appdata\\roaming\\microsoft\\windows\\start menu\\programs\\system tools\\command prompt.lnk",
LnkFilePath = "c:\\users\\powertoys\\appdata\\roaming\\microsoft\\windows\\start menu\\programs\\system tools\\command prompt.lnk",
AppType = Win32Program.ApplicationType.Win32Application,
};
@@ -78,7 +78,7 @@ namespace Microsoft.Plugin.Program.UnitTests.Programs
Name = "File Explorer",
ExecutableName = "File Explorer.lnk",
FullPath = "c:\\users\\powertoys\\appdata\\roaming\\microsoft\\windows\\start menu\\programs\\system tools\\file explorer.lnk",
LnkResolvedPath = null,
LnkFilePath = null,
AppType = Win32Program.ApplicationType.Win32Application,
};
@@ -87,7 +87,7 @@ namespace Microsoft.Plugin.Program.UnitTests.Programs
Name = "File Explorer",
ExecutableName = "explorer.exe",
FullPath = "c:\\windows\\explorer.exe",
LnkResolvedPath = null,
LnkFilePath = null,
AppType = Win32Program.ApplicationType.Win32Application,
};
@@ -96,7 +96,7 @@ namespace Microsoft.Plugin.Program.UnitTests.Programs
Name = "Wordpad",
ExecutableName = "wordpad.exe",
FullPath = "c:\\program files\\windows nt\\accessories\\wordpad.exe",
LnkResolvedPath = "c:\\programdata\\microsoft\\windows\\start menu\\programs\\accessories\\wordpad.lnk",
LnkFilePath = "c:\\programdata\\microsoft\\windows\\start menu\\programs\\accessories\\wordpad.lnk",
AppType = Win32Program.ApplicationType.Win32Application,
};
@@ -105,7 +105,7 @@ namespace Microsoft.Plugin.Program.UnitTests.Programs
Name = "WORDPAD",
ExecutableName = "WORDPAD.EXE",
FullPath = "c:\\program files\\windows nt\\accessories\\wordpad.exe",
LnkResolvedPath = null,
LnkFilePath = null,
AppType = Win32Program.ApplicationType.Win32Application,
};
@@ -113,7 +113,7 @@ namespace Microsoft.Plugin.Program.UnitTests.Programs
{
Name = "Twitter",
FullPath = "c:\\program files (x86)\\google\\chrome\\application\\chrome_proxy.exe",
LnkResolvedPath = "c:\\users\\powertoys\\appdata\\roaming\\microsoft\\windows\\start menu\\programs\\chrome apps\\twitter.lnk",
LnkFilePath = "c:\\users\\powertoys\\appdata\\roaming\\microsoft\\windows\\start menu\\programs\\chrome apps\\twitter.lnk",
Arguments = " --profile-directory=Default --app-id=jgeosdfsdsgmkedfgdfgdfgbkmhcgcflmi",
AppType = 0,
};
@@ -122,7 +122,7 @@ namespace Microsoft.Plugin.Program.UnitTests.Programs
{
Name = "Web page",
FullPath = "c:\\program files (x86)\\microsoft\\edge\\application\\msedge_proxy.exe",
LnkResolvedPath = "c:\\users\\powertoys\\appdata\\roaming\\microsoft\\windows\\start menu\\programs\\web page.lnk",
LnkFilePath = "c:\\users\\powertoys\\appdata\\roaming\\microsoft\\windows\\start menu\\programs\\web page.lnk",
Arguments = "--profile-directory=Default --app-id=homljgmgpmcbpjbnjpfijnhipfkiclkd",
AppType = 0,
};
@@ -131,7 +131,7 @@ namespace Microsoft.Plugin.Program.UnitTests.Programs
{
Name = "edge - Bing",
FullPath = "c:\\program files (x86)\\microsoft\\edge\\application\\msedge_proxy.exe",
LnkResolvedPath = "c:\\users\\powertoys\\appdata\\roaming\\microsoft\\windows\\start menu\\programs\\edge - bing.lnk",
LnkFilePath = "c:\\users\\powertoys\\appdata\\roaming\\microsoft\\windows\\start menu\\programs\\edge - bing.lnk",
Arguments = " --profile-directory=Default --app-id=aocfnapldcnfbofgmbbllojgocaelgdd",
AppType = 0,
};
@@ -141,7 +141,7 @@ namespace Microsoft.Plugin.Program.UnitTests.Programs
Name = "Microsoft Edge",
ExecutableName = "msedge.exe",
FullPath = "c:\\program files (x86)\\microsoft\\edge\\application\\msedge.exe",
LnkResolvedPath = "c:\\programdata\\microsoft\\windows\\start menu\\programs\\microsoft edge.lnk",
LnkFilePath = "c:\\programdata\\microsoft\\windows\\start menu\\programs\\microsoft edge.lnk",
AppType = Win32Program.ApplicationType.Win32Application,
};
@@ -150,7 +150,7 @@ namespace Microsoft.Plugin.Program.UnitTests.Programs
Name = "Google Chrome",
ExecutableName = "chrome.exe",
FullPath = "c:\\program files (x86)\\google\\chrome\\application\\chrome.exe",
LnkResolvedPath = "c:\\programdata\\microsoft\\windows\\start menu\\programs\\google chrome.lnk",
LnkFilePath = "c:\\programdata\\microsoft\\windows\\start menu\\programs\\google chrome.lnk",
AppType = Win32Program.ApplicationType.Win32Application,
};
@@ -159,7 +159,7 @@ namespace Microsoft.Plugin.Program.UnitTests.Programs
Name = "Proxy App",
ExecutableName = "test_proxy.exe",
FullPath = "c:\\program files (x86)\\microsoft\\edge\\application\\test_proxy.exe",
LnkResolvedPath = "c:\\programdata\\microsoft\\windows\\start menu\\programs\\test proxy.lnk",
LnkFilePath = "c:\\programdata\\microsoft\\windows\\start menu\\programs\\test proxy.lnk",
AppType = Win32Program.ApplicationType.Win32Application,
};
@@ -168,7 +168,7 @@ namespace Microsoft.Plugin.Program.UnitTests.Programs
Name = "cmd",
ExecutableName = "cmd.exe",
FullPath = "c:\\windows\\system32\\cmd.exe",
LnkResolvedPath = null,
LnkFilePath = null,
AppType = Win32Program.ApplicationType.RunCommand, // Run command
};
@@ -178,7 +178,7 @@ namespace Microsoft.Plugin.Program.UnitTests.Programs
Description = "Cmder: Lovely Console Emulator",
ExecutableName = "Cmder.exe",
FullPath = "c:\\tools\\cmder\\cmder.exe",
LnkResolvedPath = null,
LnkFilePath = null,
AppType = Win32Program.ApplicationType.RunCommand, // Run command
};
@@ -188,7 +188,7 @@ namespace Microsoft.Plugin.Program.UnitTests.Programs
ExecutableName = "Shop Titans.url",
FullPath = "steam://rungameid/1258080",
ParentDirectory = "C:\\Users\\temp\\AppData\\Roaming\\Microsoft\\Windows\\Start Menu\\Programs\\Steam",
LnkResolvedPath = null,
LnkFilePath = null,
AppType = Win32Program.ApplicationType.InternetShortcutApplication,
};
@@ -198,7 +198,7 @@ namespace Microsoft.Plugin.Program.UnitTests.Programs
ExecutableName = "Shop Titans.url",
FullPath = "steam://rungameid/1258080",
ParentDirectory = "C:\\Users\\temp\\Desktop",
LnkResolvedPath = null,
LnkFilePath = null,
AppType = Win32Program.ApplicationType.InternetShortcutApplication,
};
@@ -208,7 +208,7 @@ namespace Microsoft.Plugin.Program.UnitTests.Programs
ExecutableName = "dummy.appref-ms",
FullPath = "C:\\dummy.appref-ms",
ParentDirectory = "C:\\",
LnkResolvedPath = null,
LnkFilePath = null,
AppType = Win32Program.ApplicationType.ApprefApplication,
};
@@ -218,7 +218,7 @@ namespace Microsoft.Plugin.Program.UnitTests.Programs
ExecutableName = "application.lnk",
FullPath = "C:\\application.lnk",
ParentDirectory = "C:\\",
LnkResolvedPath = "C:\\application.lnk",
LnkFilePath = "C:\\application.lnk",
AppType = Win32Program.ApplicationType.ShortcutApplication,
};
@@ -228,7 +228,7 @@ namespace Microsoft.Plugin.Program.UnitTests.Programs
ExecutableName = "application.lnk",
FullPath = "C:\\dummy\\folder",
ParentDirectory = "C:\\dummy\\",
LnkResolvedPath = "C:\\tools\\application.lnk",
LnkFilePath = "C:\\tools\\application.lnk",
AppType = Win32Program.ApplicationType.Folder,
};
@@ -238,7 +238,7 @@ namespace Microsoft.Plugin.Program.UnitTests.Programs
ExecutableName = "application.lnk",
FullPath = "C:\\dummy\\file.pdf",
ParentDirectory = "C:\\dummy\\",
LnkResolvedPath = "C:\\tools\\application.lnk",
LnkFilePath = "C:\\tools\\application.lnk",
AppType = Win32Program.ApplicationType.GenericFile,
};
@@ -303,7 +303,7 @@ namespace Microsoft.Plugin.Program.UnitTests.Programs
}
[TestMethod]
public void DedupFunctionMustRemoveDuplicatesForExeExtensionsWithoutLnkResolvedPath()
public void DedupFunctionMustRemoveDuplicatesForExeExtensionsWithoutLnkFilePath()
{
// Arrange
List<Win32Program> prgms = new List<Win32Program>
@@ -317,7 +317,7 @@ namespace Microsoft.Plugin.Program.UnitTests.Programs
// Assert
Assert.AreEqual(1, apps.Count);
Assert.IsTrue(!string.IsNullOrEmpty(apps[0].LnkResolvedPath));
Assert.IsTrue(!string.IsNullOrEmpty(apps[0].LnkFilePath));
}
[TestMethod]

View File

@@ -331,7 +331,7 @@ namespace Microsoft.Plugin.Program.UnitTests.Storage
ExecutableName = "path.exe",
ParentDirectory = "directory",
FullPath = "directory\\path.exe",
LnkResolvedPath = "directory\\path.lnk", // This must be equal for lnk applications
LnkFilePath = "directory\\path.lnk", // This must be equal for lnk applications
};
win32ProgramRepository.Add(item);