Skip to content
Merged
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
18 changes: 6 additions & 12 deletions Remora.Commands/Trees/CommandTreeBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -286,8 +286,8 @@ private IEnumerable<IChildNode> ToChildNodes(IEnumerable<Type> moduleTypes, IPar
// If the group is being hoisted, take the attributes of the parent type(s).
ExtractExtraAttributes(parentType, out var extraAttributes, out var extraConditions);

attributes = extraAttributes.Concat(attributes).ToArray();
conditions = extraConditions.Concat(conditions).ToArray();
attributes = [..attributes, ..extraAttributes];
conditions = [..conditions, ..extraConditions];
}

var groupNode = new GroupNode(group.ToArray(), groupChildren, parent, group.Key, groupAliases, attributes, conditions, description);
Expand Down Expand Up @@ -348,16 +348,10 @@ private static void ExtractExtraAttributes(Type parentType, out IEnumerable<Attr

parentGroupType.GetAttributesAndConditions(out var parentAttributes, out var parentConditions);

extraAttributes.AddRange(parentAttributes.Reverse());
extraConditions.AddRange(parentConditions.Reverse());
extraAttributes.AddRange(parentAttributes);
extraConditions.AddRange(parentConditions);
}
while ((parentGroupType = parentGroupType!.DeclaringType) is not null);

// These are inserted in reverse order as we traverse up the
// inheritance tree, so re-reversing the list gives us all attributes
// in the correct order, *decescending* down the tree, effectively.
extraAttributes.Reverse();
extraConditions.Reverse();
}

/// <summary>
Expand Down Expand Up @@ -395,8 +389,8 @@ private IEnumerable<CommandNode> GetModuleCommands(Type moduleType, IParentNode
// If the group is being hoisted, take the attributes of the parent type(s).
ExtractExtraAttributes(moduleType, out var extraAttributes, out var extraConditions);

attributes = extraAttributes.Concat(attributes).ToArray();
conditions = extraConditions.Concat(conditions).ToArray();
attributes = [..attributes, ..extraAttributes];
conditions = [..conditions, ..extraConditions];
}

yield return new CommandNode
Expand Down
Loading