Skip to content

Commit

Permalink
fix: docfx metadata command throw ArgumentException when referenc…
Browse files Browse the repository at this point in the history
…ing empty namespace by doc comment (dotnet#10023)

fix: exception occurred when doc comment referencing empty namespace
  • Loading branch information
filzrev authored and p-kostov committed Jun 28, 2024
1 parent c1ca218 commit 93a5a58
Showing 1 changed file with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ private static MetadataItem GenerateNestedTocStructure(IEnumerable<KeyValuePair<
};
missingNamespace.DisplayNames.Add(SyntaxLanguage.Default, partialParentNamespace);
namespacedItems[partialParentNamespace] = missingNamespace;
allReferences.Add(partialParentNamespace, new());
allReferences.TryAdd(partialParentNamespace, new());

if (!partialParentNamespace.Contains('.'))
{
Expand Down Expand Up @@ -137,11 +137,19 @@ private static MetadataItem GenerateNestedTocStructure(IEnumerable<KeyValuePair<
}

foreach (var member in namespacedItems.Values)
{
member.Items = member.Items
.OrderBy(x => x.Type == MemberType.Namespace ? 0 : 1)
.ThenBy(x => x.Name)
.ToList();

if (member.Type == MemberType.Namespace
&& member.Items.All(x => x.Type == MemberType.Namespace))
{
allReferences[member.Name] = new();
}
}

return root;
}

Expand Down

0 comments on commit 93a5a58

Please sign in to comment.