Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ internal static IReadOnlyList<Runspace> GetAllRunspaces()

internal static IReadOnlyList<Runspace> GetRunspacesByName(string[] names)
{
List<Runspace> rtnRunspaces = new List<Runspace>();
List<Runspace> rtnRunspaces = new();
IReadOnlyList<Runspace> runspaces = Runspace.RunspaceList;

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

internal static IReadOnlyList<Runspace> GetRunspacesById(int[] ids)
{
List<Runspace> rtnRunspaces = new List<Runspace>();
List<Runspace> rtnRunspaces = new();

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

internal static IReadOnlyList<Runspace> GetRunspacesByInstanceId(Guid[] instanceIds)
{
List<Runspace> rtnRunspaces = new List<Runspace>();
List<Runspace> rtnRunspaces = new();
IReadOnlyList<Runspace> runspaces = Runspace.RunspaceList;

foreach (Guid instanceId in instanceIds)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ protected override void ProcessRecord()
}
}

VerbInfo verb = new VerbInfo();
VerbInfo verb = new();
verb.Verb = field.Name;
verb.AliasPrefix = VerbAliasPrefixes.GetVerbAliasPrefix(field.Name);
verb.Group = groupName;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ internal virtual void Add(PSObject groupValue)

private static string BuildName(List<ObjectCommandPropertyValue> propValues)
{
StringBuilder sb = new StringBuilder();
StringBuilder sb = new();
foreach (ObjectCommandPropertyValue propValue in propValues)
{
var propValuePropertyValue = propValue?.PropertyValue;
Expand Down Expand Up @@ -176,7 +176,7 @@ public ArrayList Values
{
get
{
ArrayList values = new ArrayList();
ArrayList values = new();
foreach (ObjectCommandPropertyValue propValue in GroupValue.orderValues)
{
values.Add(propValue.PropertyValue);
Expand Down Expand Up @@ -248,10 +248,10 @@ public class GroupObjectCommand : ObjectBase
[Parameter(ParameterSetName = "HashTable")]
public SwitchParameter AsString { get; set; }

private readonly List<GroupInfo> _groups = new List<GroupInfo>();
private readonly OrderByProperty _orderByProperty = new OrderByProperty();
private readonly Dictionary<object, GroupInfo> _tupleToGroupInfoMappingDictionary = new Dictionary<object, GroupInfo>();
private readonly List<OrderByPropertyEntry> _entriesToOrder = new List<OrderByPropertyEntry>();
private readonly List<GroupInfo> _groups = new();
private readonly OrderByProperty _orderByProperty = new();
private readonly Dictionary<object, GroupInfo> _tupleToGroupInfoMappingDictionary = new();
private readonly List<OrderByPropertyEntry> _entriesToOrder = new();
private OrderByPropertyComparer _orderByPropertyComparer;
private bool _hasProcessedFirstInputObject;
private bool _hasDifferentValueTypes;
Expand Down Expand Up @@ -375,7 +375,7 @@ private static void DoOrderedGrouping(

private void WriteNonTerminatingError(Exception exception, string resourceIdAndErrorId, ErrorCategory category)
{
Exception ex = new Exception(StringUtil.Format(resourceIdAndErrorId), exception);
Exception ex = new(StringUtil.Format(resourceIdAndErrorId), exception);
WriteError(new ErrorRecord(ex, resourceIdAndErrorId, category, null));
}

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

if (AsString && !AsHashTable)
{
ArgumentException ex = new ArgumentException(UtilityCommonStrings.GroupObjectWithHashTable);
ErrorRecord er = new ErrorRecord(ex, "ArgumentException", ErrorCategory.InvalidArgument, AsString);
ArgumentException ex = new(UtilityCommonStrings.GroupObjectWithHashTable);
ErrorRecord er = new(ex, "ArgumentException", ErrorCategory.InvalidArgument, AsString);
ThrowTerminatingError(er);
}

if (AsHashTable && !AsString && (Property != null && (Property.Length > 1 || _orderByProperty.MshParameterList.Count > 1)))
{
ArgumentException ex = new ArgumentException(UtilityCommonStrings.GroupObjectSingleProperty);
ErrorRecord er = new ErrorRecord(ex, "ArgumentException", ErrorCategory.InvalidArgument, Property);
ArgumentException ex = new(UtilityCommonStrings.GroupObjectSingleProperty);
ErrorRecord er = new(ex, "ArgumentException", ErrorCategory.InvalidArgument, Property);
ThrowTerminatingError(er);
}

Expand Down
Loading