Skip to content

When CodeNav is set to Sort by Order, some methods that are not part of an interface may be displayed out-of-order #164

Description

@Bergam64

Hello Samir,

This is a follow-up issue for #140.

When CodeNav is set to Sort by Order, some methods that are not part of an interface may be displayed out-of-order.

Repro:

File IMyService.cs:

internalinterfaceIMyService{voidPublicMethod1();voidPublicMethod2();voidPublicMethod3();}

File MyService.cs:

namespaceSomeNamespace;internalsealedclassMyService:IMyService{privatestaticvoidPrivateMethod0()// <-- Not part of an interface.{}publicvoidPublicMethod1(){}privatestaticvoidPrivateMethod1()// <-- Not part of an interface.{}publicvoidPublicMethod2(){}publicvoidPublicMethod3(){}internalvoidPrivateMethod3()// <-- Not part of an interface.{}}

CodeNav displays this:

+---------------------------------+
| SomeNamespace |
+---------------------------------+
| +-----------------------------+ |
| | MyService : IMyService | |
| +-----------------------------+ |
| | PrivateMethod0 () | |
| | +-------------------------+ | |
| | | IMyService | | |
| | +-------------------------+ | |
| | | PublicMethod1 () | | |
| | | PublicMethod2 () | | |
| | | PublicMethod3 () | | |
| | +-------------------------+ | |
| | PrivateMethod1 () | | // <-- Wrong position (must be between 'PublicMethod1' and 'PublicMethod2').
| | PrivateMethod3 () | |
| +-----------------------------+ |
+---------------------------------+

But it should instead display this:

+---------------------------------+
| SomeNamespace |
+---------------------------------+
| +-----------------------------+ |
| | MyService : IMyService | |
| +-----------------------------+ |
| | PrivateMethod0 () | |
| | +-------------------------+ | |
| | | IMyService | | |
| | +-------------------------+ | |
| | | PublicMethod1 () | | |
| | +-------------------------+ | |
| | PrivateMethod1 () | |
| | +-------------------------+ | | // <-- Open interface block each time next method is part of an interface but previous method wasn't.
| | | IMyService | | |
| | +-------------------------+ | |
| | | PublicMethod2 () | | |
| | | PublicMethod3 () | | | // <-- While current method is part of same interface as previous method, stay in same interface block.
| | +-------------------------+ | | // <-- Close interface block if next method is not part of same interface (or it's last method).
| | PrivateMethod3 () | |
| +-----------------------------+ |
+---------------------------------+

Note that if regions are involved, CodeNav display is correct.

Try with this file:

File MyService2.cs:

namespaceSomeNamespace;internalsealedclassMyService2:IMyService{privatestaticvoidPrivateMethod0()// <-- Not part of an interface.{}
#region PublicMethod1
publicvoidPublicMethod1(){}privatestaticvoidPrivateMethod1()// <-- Not part of an interface.{}
#endregion
publicvoidPublicMethod2(){}
#region PublicMethod3
publicvoidPublicMethod3(){}internalvoidPrivateMethod3()// <-- Not part of an interface.{
#endregion
}}

CodeNav displays this:

+---------------------------------+
| SomeNamespace |
+---------------------------------+
| +-----------------------------+ |
| | MyService2 : IMyService | |
| +-----------------------------+ |
| | PrivateMethod0 () | |
| | +-------------------------+ | |
| | | #PublicMethod1 | | |
| | +-------------------------+ | |
| | | +---------------------+ | | |
| | | | IMyService | | | |
| | | +---------------------+ | | |
| | | | PublicMethod1 () | | | |
| | | +---------------------+ | | |
| | | PrivateMethod1 () | | |
| | +-------------------------+ | |
| | +-------------------------+ | |
| | | IMyService | | |
| | +-------------------------+ | |
| | | PublicMethod2 () | | |
| | +-------------------------+ | |
| | +-------------------------+ | |
| | | #PublicMethod3 | | |
| | +-------------------------+ | |
| | | +---------------------+ | | |
| | | | IMyService | | | |
| | | +---------------------+ | | |
| | | | PublicMethod3 () | | | |
| | | +---------------------+ | | |
| | | PrivateMethod3 () | | |
| | +-------------------------+ | |
| +-----------------------------+ |
+---------------------------------+

which is correct.

Context:

  • CodeNav 10.5.129.
  • VS 2026 Insiders [11619.145].

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions