Skip to content

Commit e7f90f0

Browse files
authored
Fix other path constructions using Path.Join (PowerShell#17825)
1 parent b66a93f commit e7f90f0

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

src/System.Management.Automation/CoreCLR/CorePsAssemblyLoadContext.cs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -346,9 +346,6 @@ private bool TryFindInGAC(AssemblyName assemblyName, out string assemblyFilePath
346346
return false;
347347
}
348348

349-
bool assemblyFound = false;
350-
char dirSeparator = IO.Path.DirectorySeparatorChar;
351-
352349
if (string.IsNullOrEmpty(_winDir))
353350
{
354351
// cache value of '_winDir' folder in member variable.
@@ -358,10 +355,10 @@ private bool TryFindInGAC(AssemblyName assemblyName, out string assemblyFilePath
358355
if (string.IsNullOrEmpty(_gacPathMSIL))
359356
{
360357
// cache value of '_gacPathMSIL' folder in member variable.
361-
_gacPathMSIL = $"{_winDir}{dirSeparator}Microsoft.NET{dirSeparator}assembly{dirSeparator}GAC_MSIL";
358+
_gacPathMSIL = Path.Join(_winDir, "Microsoft.NET", "assembly", "GAC_MSIL");
362359
}
363360

364-
assemblyFound = FindInGac(_gacPathMSIL, assemblyName, out assemblyFilePath);
361+
bool assemblyFound = FindInGac(_gacPathMSIL, assemblyName, out assemblyFilePath);
365362

366363
if (!assemblyFound)
367364
{
@@ -399,8 +396,7 @@ private static bool FindInGac(string gacRoot, AssemblyName assemblyName, out str
399396
bool assemblyFound = false;
400397
assemblyPath = null;
401398

402-
char dirSeparator = IO.Path.DirectorySeparatorChar;
403-
string tempAssemblyDirPath = $"{gacRoot}{dirSeparator}{assemblyName.Name}";
399+
string tempAssemblyDirPath = Path.Join(gacRoot, assemblyName.Name);
404400

405401
if (Directory.Exists(tempAssemblyDirPath))
406402
{

0 commit comments

Comments
 (0)