Skip to content

Commit

Permalink
Sort NameSpaces and Types
Browse files Browse the repository at this point in the history
  • Loading branch information
chidozieononiwu committed May 14, 2024
1 parent a229c82 commit c663a95
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
12 changes: 12 additions & 0 deletions src/dotnet/APIView/APIView/Model/TokenTreeModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -165,5 +165,17 @@ public override bool Equals(object obj)
var other = (APITreeNode)obj;
return Name == other.Name && Id == other.Id && Kind == other.Kind;
}

public void SortChildren()
{
if (Kind.Equals("Namespace") || Kind.Equals("Type") || Kind.Equals("Member"))
{
Children.Sort((x, y) => x.Name.CompareTo(y.Name));
}
foreach (var child in Children)
{
child.SortChildren();
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,9 @@ public TreeTokenCodeFile Build(IAssemblySymbol assemblySymbol, bool runAnalysis,
diagnostics.TargetId = ConvertToValidCssId(diagnostics.TargetId);
}

// Sort API Tree by name
apiTreeNode.SortChildren();

var treeTokenCodeFile = new TreeTokenCodeFile()
{
Name = $"{assemblySymbol.Name} ({assemblySymbol.Identity.Version})",
Expand Down Expand Up @@ -409,7 +412,7 @@ private void BuildMember(List<APITreeNode> apiTree, ISymbol member, bool inHidde
apiTreeNode.Kind = "Member";
apiTreeNode.Properties.Add("SubKind", member.Kind.ToString());
apiTreeNode.Id = ConvertToValidCssId(member.GetId());
apiTreeNode.Name = member.ToDisplayString(SymbolDisplayFormat.MinimallyQualifiedFormat);
apiTreeNode.Name = member.ToDisplayString();
apiTreeNode.Tags.Add("HideFromNavigation");

if (isHidden && !inHiddenScope)
Expand Down

0 comments on commit c663a95

Please sign in to comment.