Skip to content

Commit edb70b1

Browse files
authored
1 parent 9b36841 commit edb70b1

20 files changed

+117
-117
lines changed

src/Microsoft.PowerShell.Commands.Utility/commands/utility/GetRunspaceCommand.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ internal static IReadOnlyList<Runspace> GetAllRunspaces()
126126

127127
internal static IReadOnlyList<Runspace> GetRunspacesByName(string[] names)
128128
{
129-
List<Runspace> rtnRunspaces = new List<Runspace>();
129+
List<Runspace> rtnRunspaces = new();
130130
IReadOnlyList<Runspace> runspaces = Runspace.RunspaceList;
131131

132132
foreach (string name in names)
@@ -146,7 +146,7 @@ internal static IReadOnlyList<Runspace> GetRunspacesByName(string[] names)
146146

147147
internal static IReadOnlyList<Runspace> GetRunspacesById(int[] ids)
148148
{
149-
List<Runspace> rtnRunspaces = new List<Runspace>();
149+
List<Runspace> rtnRunspaces = new();
150150

151151
foreach (int id in ids)
152152
{
@@ -167,7 +167,7 @@ internal static IReadOnlyList<Runspace> GetRunspacesById(int[] ids)
167167

168168
internal static IReadOnlyList<Runspace> GetRunspacesByInstanceId(Guid[] instanceIds)
169169
{
170-
List<Runspace> rtnRunspaces = new List<Runspace>();
170+
List<Runspace> rtnRunspaces = new();
171171
IReadOnlyList<Runspace> runspaces = Runspace.RunspaceList;
172172

173173
foreach (Guid instanceId in instanceIds)

src/Microsoft.PowerShell.Commands.Utility/commands/utility/GetVerbCommand.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ protected override void ProcessRecord()
7070
}
7171
}
7272

73-
VerbInfo verb = new VerbInfo();
73+
VerbInfo verb = new();
7474
verb.Verb = field.Name;
7575
verb.AliasPrefix = VerbAliasPrefixes.GetVerbAliasPrefix(field.Name);
7676
verb.Group = groupName;

src/Microsoft.PowerShell.Commands.Utility/commands/utility/Group-Object.cs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ internal virtual void Add(PSObject groupValue)
140140

141141
private static string BuildName(List<ObjectCommandPropertyValue> propValues)
142142
{
143-
StringBuilder sb = new StringBuilder();
143+
StringBuilder sb = new();
144144
foreach (ObjectCommandPropertyValue propValue in propValues)
145145
{
146146
var propValuePropertyValue = propValue?.PropertyValue;
@@ -176,7 +176,7 @@ public ArrayList Values
176176
{
177177
get
178178
{
179-
ArrayList values = new ArrayList();
179+
ArrayList values = new();
180180
foreach (ObjectCommandPropertyValue propValue in GroupValue.orderValues)
181181
{
182182
values.Add(propValue.PropertyValue);
@@ -248,10 +248,10 @@ public class GroupObjectCommand : ObjectBase
248248
[Parameter(ParameterSetName = "HashTable")]
249249
public SwitchParameter AsString { get; set; }
250250

251-
private readonly List<GroupInfo> _groups = new List<GroupInfo>();
252-
private readonly OrderByProperty _orderByProperty = new OrderByProperty();
253-
private readonly Dictionary<object, GroupInfo> _tupleToGroupInfoMappingDictionary = new Dictionary<object, GroupInfo>();
254-
private readonly List<OrderByPropertyEntry> _entriesToOrder = new List<OrderByPropertyEntry>();
251+
private readonly List<GroupInfo> _groups = new();
252+
private readonly OrderByProperty _orderByProperty = new();
253+
private readonly Dictionary<object, GroupInfo> _tupleToGroupInfoMappingDictionary = new();
254+
private readonly List<OrderByPropertyEntry> _entriesToOrder = new();
255255
private OrderByPropertyComparer _orderByPropertyComparer;
256256
private bool _hasProcessedFirstInputObject;
257257
private bool _hasDifferentValueTypes;
@@ -375,7 +375,7 @@ private static void DoOrderedGrouping(
375375

376376
private void WriteNonTerminatingError(Exception exception, string resourceIdAndErrorId, ErrorCategory category)
377377
{
378-
Exception ex = new Exception(StringUtil.Format(resourceIdAndErrorId), exception);
378+
Exception ex = new(StringUtil.Format(resourceIdAndErrorId), exception);
379379
WriteError(new ErrorRecord(ex, resourceIdAndErrorId, category, null));
380380
}
381381

@@ -401,15 +401,15 @@ protected override void ProcessRecord()
401401

402402
if (AsString && !AsHashTable)
403403
{
404-
ArgumentException ex = new ArgumentException(UtilityCommonStrings.GroupObjectWithHashTable);
405-
ErrorRecord er = new ErrorRecord(ex, "ArgumentException", ErrorCategory.InvalidArgument, AsString);
404+
ArgumentException ex = new(UtilityCommonStrings.GroupObjectWithHashTable);
405+
ErrorRecord er = new(ex, "ArgumentException", ErrorCategory.InvalidArgument, AsString);
406406
ThrowTerminatingError(er);
407407
}
408408

409409
if (AsHashTable && !AsString && (Property != null && (Property.Length > 1 || _orderByProperty.MshParameterList.Count > 1)))
410410
{
411-
ArgumentException ex = new ArgumentException(UtilityCommonStrings.GroupObjectSingleProperty);
412-
ErrorRecord er = new ErrorRecord(ex, "ArgumentException", ErrorCategory.InvalidArgument, Property);
411+
ArgumentException ex = new(UtilityCommonStrings.GroupObjectSingleProperty);
412+
ErrorRecord er = new(ex, "ArgumentException", ErrorCategory.InvalidArgument, Property);
413413
ThrowTerminatingError(er);
414414
}
415415

0 commit comments

Comments
 (0)