dotnet / docfx

Static site generator for .NET API documentation.
https://dotnet.github.io/docfx/
MIT License
4.09k stars 867 forks source link

[Bug] Generic methods / types are not ordered correctly together with their non-generic versions #10332

Open mikernet opened 3 weeks ago

mikernet commented 3 weeks ago

Describe the bug Title says it all. Examples:

Image

Image

Expected behavior Generic types/methods should follow immediately after non-generic ones with the same name.

Context (please complete the following information):

filzrev commented 3 weeks ago

It seems to be occurred when using "outputFormat": "mref" options. When using apiPage or markdown options. It works as expected.

I though it's introduced by enabling InvariantGlobalization mode. (#8893) I'll try to create PR to fix reported issue later.

Background Currently toc items are sorted by uid. And when item contains generic type parameter it's represented as "`1".

But when toc items are sorted with Ordinal order. The order of results is changed from what is expected.

Sample TOC file

  - uid: BuildFromProject.IRoutedView
    name: IRoutedView
  - uid: BuildFromProject.IRoutedViewModel
    name: IRoutedViewModel
  - uid: BuildFromProject.IRoutedView`1
    name: IRoutedView<T>
mikernet commented 3 weeks ago

So based on your comment, does that mean that there is a workaround that I can use for now (something that won't radically change how I need to generate the docs)?

filzrev commented 3 weeks ago

A temporary workaround is to disable globalization nvariant mode.

1. Steps to disableInvariantModesettings

  1. Open following file. (On Windows environment)

    %UserProfile%\.dotnet\tools\.store\docfx\2.77.0\docfx\2.77.0\tools\net8.0\any\docfx.runtimeconfig.json

  2. Modify System.Globalization.Invariant setting to false.

2. Steps to confirm behavior changes

  1. Run docfx metadata command.
  2. Run docfx build --serve command
  3. Confirm TOC displayed orders.

To fix the root cause problems. It need to create Custom IComparer<string> that compatible with InvariantCulture(with System.Globalization.Invariant: false)