-
Notifications
You must be signed in to change notification settings - Fork 868
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: TOC items order issue #10585
base: main
Are you sure you want to change the base?
fix: TOC items order issue #10585
Conversation
48923d1
to
e4e8b92
Compare
/// (e.g. StringComparer.InvariantCulture.Compare("\x0000 ZZZ \x0000"," ZZZ ")) returns 0). | ||
/// This feature is not implement by this comparer. | ||
/// </remarks> | ||
internal sealed class SymbolStringComparer : IComparer<string> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems to be occurred when using "outputFormat": "mref" options.
When using apiPage or markdown options. It works as expected.
The apiPage output does not use a custom string comparer and seems to sort by name
directly, does it work to sort by name also for mref
output?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ApiPage resolve names with SymbolFormatter.GetName(symbol, SyntaxLanguage.CSharp)
So name is represented as followings.
Class1
Class1.IRoutedView
Class1.IRoutedView<T>
Class1.IRoutedViewModel
Class1.IRoutedViewModelBase
So generics are sorted as expected when it's sorted by ordinal .
Because <
char code is smaller than alphabet char.
On the other hand, when using Mref
output format.
name is represented as followings.
BuildFromProject.Class1
BuildFromProject.Class1.IRoutedView
BuildFromProject.Class1.IRoutedViewModel
BuildFromProject.Class1.IRoutedViewModelBase
BuildFromProject.Class1.IRoutedView`1
So it requires SymbolStringComparer to get expected results.
I thought SymbolStringComparer should be also applied to ApiPage/Markdown output format.
eb07ed7
to
42e8d00
Compare
This PR intended to fix issue #10332
Background
When using
Globalization Invariant Mode
. string is sorted withordinal
orders.And it will cause some order problems, which seems not to be natural orders.
What's changed in this PR
1. Add
SymbolStringComparer.cs
Add custom StringComparer that sort ASCII chars.
It's similar to
StringComparer.InvariantCulture
's order but have following differences.2. Modify
YamlViewModelExtensions.cs
Modify toc /enum items sort logics to use custom
SymbolStringComparer
.3. Add test class to that contains test for Issue10332
Confirmed generated web site symbols are ordered as expected.
And
enumSortOrder:alphabetic
behavior is confirmed by modifyingseed/docfx.json
manually.Additional apply formatter to
Class1.cs
file content.4. Update snapshot files with
snapshot.yml