Skip to content

Commit 1e1e44a

Browse files
committed
comments
1 parent e2c934e commit 1e1e44a

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/Microsoft.Management.Configuration.Processor/Public/PathEnvironmentVariableHandler.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public static object Lock
3232
/// </summary>
3333
public static void UpdatePath()
3434
{
35-
List<string> paths = new List<string>(Environment.GetEnvironmentVariable(PathEnvironmentVariable)?.Split(';') ?? Array.Empty<string>());
35+
HashSet<string> paths = new HashSet<string>(Environment.GetEnvironmentVariable(PathEnvironmentVariable)?.Split(';') ?? Array.Empty<string>());
3636
var originalPathsSize = paths.Count;
3737

3838
AddPathsIfNotExist(paths, Environment.GetEnvironmentVariable(PathEnvironmentVariable, EnvironmentVariableTarget.Machine)?.Split(';'));
@@ -47,8 +47,11 @@ public static void UpdatePath()
4747
}
4848
}
4949

50+
// TODO: Currently it always adds new paths to the end. The "proper" thing to do would probably be to calculate
51+
// the full new list of paths (what one would expect to get from a new process launch) and use a line merge algorithm
52+
// with a strategy that puts the ephemeral entries before the new permanent ones.
5053
#pragma warning disable SA1011 // Closing square brackets should be spaced correctly
51-
private static void AddPathsIfNotExist(List<string> currentPaths, string[]? paths)
54+
private static void AddPathsIfNotExist(HashSet<string> currentPaths, string[]? paths)
5255
#pragma warning restore SA1011 // Closing square brackets should be spaced correctly
5356
{
5457
if (paths is not null)

0 commit comments

Comments
 (0)