[PT Run] Fix Program Plugin launching issue in Turkish locale (#10981)

* [Launcher] Fix Program Plugin launching issue in Turkish locale

* [Launcher] Add test for Turkish localized path

* Update expect.txt

* Update .github/actions/spell-check/expect.txt

Co-authored-by: Clint Rutkas <clint@rutkas.com>
Co-authored-by: Enrico Giordani <enricogior@users.noreply.github.com>
This commit is contained in:
Doğan Çelik 2021-05-21 17:51:53 +03:00 committed by GitHub
parent 50c6a1de8a
commit 17fbe40b40
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 24 additions and 6 deletions

View file

@ -18,6 +18,15 @@ namespace Microsoft.Plugin.Program.UnitTests.Programs
[TestFixture]
public class Win32Tests
{
private static readonly Win32Program _imagingDevices = new Win32Program
{
Name = "Imaging Devices",
ExecutableName = "imagingdevices.exe",
FullPath = "c:\\program files\\windows photo viewer\\imagingdevices.exe",
LnkResolvedPath = null,
AppType = Win32Program.ApplicationType.Win32Application,
};
private static readonly Win32Program _notepadAppdata = new Win32Program
{
Name = "Notepad",
@ -432,6 +441,12 @@ namespace Microsoft.Plugin.Program.UnitTests.Programs
Assert.IsTrue(_cmdRunCommand.QueryEqualsNameForRunCommands(query));
}
[TestCase("ımaging")]
public void Win32ApplicationsShouldNotHaveIncorrectPathWhenExecuting(string query)
{
Assert.IsFalse(_imagingDevices.FullPath.Contains(query, StringComparison.Ordinal));
}
[Test]
public void WebApplicationShouldReturnContextMenuWithOpenInConsoleWhenContextMenusIsCalled()
{

View file

@ -344,6 +344,7 @@ namespace Microsoft.Plugin.Program.Programs
}
[System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1031:Do not catch general exception types", Justification = "Any error in CreateWin32Program should not prevent other programs from loading.")]
[System.Diagnostics.CodeAnalysis.SuppressMessage("Globalization", "CA1308:Normalize strings to uppercase", Justification = "User facing path needs to be shown in lowercase.")]
private static Win32Program CreateWin32Program(string path)
{
try
@ -354,8 +355,8 @@ namespace Microsoft.Plugin.Program.Programs
ExecutableName = Path.GetFileName(path),
IcoPath = path,
// Using CurrentCulture since this is user facing
FullPath = path.ToLower(CultureInfo.CurrentCulture),
// Using InvariantCulture since this is user facing
FullPath = path.ToLowerInvariant(),
UniqueIdentifier = path,
ParentDirectory = Directory.GetParent(path).FullName,
Description = string.Empty,
@ -465,6 +466,7 @@ namespace Microsoft.Plugin.Program.Programs
}
[System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1031:Do not catch general exception types", Justification = "Unsure of what exceptions are caught here while enabling static analysis")]
[System.Diagnostics.CodeAnalysis.SuppressMessage("Globalization", "CA1308:Normalize strings to uppercase", Justification = "User facing path needs to be shown in lowercase.")]
private static Win32Program LnkProgram(string path)
{
try
@ -481,8 +483,8 @@ namespace Microsoft.Plugin.Program.Programs
{
program.LnkResolvedPath = program.FullPath;
// Using CurrentCulture since this is user facing
program.FullPath = Path.GetFullPath(target).ToLower(CultureInfo.CurrentCulture);
// Using InvariantCulture since this is user facing
program.FullPath = Path.GetFullPath(target).ToLowerInvariant();
program.AppType = GetAppTypeFromPath(target);
var description = ShellLinkHelper.Description;
@ -693,10 +695,11 @@ namespace Microsoft.Plugin.Program.Programs
return files;
}
[System.Diagnostics.CodeAnalysis.SuppressMessage("Globalization", "CA1308:Normalize strings to uppercase", Justification = "User facing path needs to be shown in lowercase.")]
private static string Extension(string path)
{
// Using CurrentCulture since this is user facing
var extension = Path.GetExtension(path)?.ToLower(CultureInfo.CurrentCulture);
// Using InvariantCulture since this is user facing
var extension = Path.GetExtension(path)?.ToLowerInvariant();
if (!string.IsNullOrEmpty(extension))
{