Skip to content

Commit 3bf1949

Browse files
committed
Use a SortedSet to sort the results of Get-SecretInfo
Instead of a `SortedDictionary` so that keys don't have to be unique. Fixes #95.
1 parent 47bc3b7 commit 3bf1949

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

src/code/SecretManagement.cs

+14-6
Original file line numberDiff line numberDiff line change
@@ -1056,22 +1056,30 @@ private void WriteExtensionResults(ExtensionVaultModule extensionModule)
10561056
}
10571057
}
10581058

1059+
private class SecretInformationComparer :
1060+
IComparer<KeyValuePair<string, SecretInformation>>
1061+
{
1062+
public int Compare(KeyValuePair<string, SecretInformation> x, KeyValuePair<string, SecretInformation> y)
1063+
{
1064+
return string.Compare(x.Key, y.Key, StringComparison.Ordinal);
1065+
}
1066+
}
1067+
10591068
private void WriteResults(SecretInformation[] results)
10601069
{
10611070
if (results == null) { return; }
10621071

10631072
// Ensure each vaults results are sorted by secret name.
1064-
var sortedList = new SortedDictionary<string, SecretInformation>(StringComparer.OrdinalIgnoreCase);
1073+
var sortedSet = new SortedSet<KeyValuePair<string, SecretInformation>>(new SecretInformationComparer ());
1074+
10651075
foreach (var item in results)
10661076
{
1067-
sortedList.Add(
1068-
key: item.Name,
1069-
value: item);
1077+
sortedSet.Add(new KeyValuePair<string, SecretInformation>(item.Name, item));
10701078
}
10711079

1072-
foreach (var item in sortedList.Values)
1080+
foreach (var pair in sortedSet)
10731081
{
1074-
WriteObject(item);
1082+
WriteObject(pair.Value);
10751083
}
10761084
}
10771085

0 commit comments

Comments
 (0)