Skip to content

Regions should take precedence over Interfaces, not the other way around.Β #140

@Bergam64

Description

@Bergam64

Hello Samir,

I'd like to report a problem that has been there for ages: CodeNav always displays code structure with interfaces taking precedence over #regions. In order to correctly display the class structure, this should be the opposite.

Context:

  • CodeNav 2022 v8.9.40.
  • VS 2022 v17.2.6.
  • Sorting members by file order.

Repro with the following 2 files:

  • File "IMyService.cs":
namespace CodeNavInterfacesVsRegions
{
    public interface IMyService
    {
        void PublicMethod1();

        void PublicMethod2();
    }
}
  • File "MyService.cs":
namespace CodeNavInterfacesVsRegions
{
    public class MyService : IMyService
    {
        #region PublicMethod1

        public void PublicMethod1()
        {
            PrivateMethod11();
            PrivateMethod12();
        }

        private void PrivateMethod11()
        {
        }

        private void PrivateMethod12()
        {
        }

        #endregion

        #region PublicMethod2

        public void PublicMethod2()
        {
            PrivateMethod21();
            PrivateMethod22();
        }

        private void PrivateMethod21()
        {
        }

        private void PrivateMethod22()
        {
        }

        #endregion
    }
}

For class MyService, CodeNav displays this:

{} CodeNavInterfacesVsRegions
-------------------------------
 MyService : IMyService
 ------------------------------
 +----------------------------+
 | #PublicMethod1             |
 +----------------------------+
 | +-------------------------+|
 | | IMyService              ||
 | +-------------------------||
 | | PublicMethod1 ()        ||
 | | PublicMethod2 ()        ||  <-- This method (implementing interface) is not part of #region #PublicMethod1!
 | +-------------------------+|
 | PrivateMethod11 ()         |
 | PrivateMethod12 ()         |
 +----------------------------+

 +----------------------------+
 | #PublicMethod2 ()          |
 +----------------------------+
 | PrivateMethod21 ()         |
 | PrivateMethod22 ()         |
 +----------------------------+

But it should instead display this:

{} CodeNavInterfacesVsRegions
-------------------------------
 MyService : IMyService
 ------------------------------
 +----------------------------+
 | #PublicMethod1             |
 +----------------------------+
 | +-------------------------+|
 | | IMyService              ||
 | +-------------------------||
 | | PublicMethod1 ()        ||
 | +-------------------------+|
 | PrivateMethod11 ()         |
 | PrivateMethod12 ()         |
 +----------------------------+

 +----------------------------+
 | #PublicMethod2 ()          |
 +----------------------------+
 | +-------------------------+|  <-- Repeat block for interface implementation.
 | | IMyService              ||
 | +-------------------------||
 | | PublicMethod2 ()        ||  <-- This method (implementing interface) appears in the correct #region.
 | +-------------------------+|
 | PrivateMethod21 ()         |
 | PrivateMethod22 ()         |
 +----------------------------+

If you agree this is a bug, then please fix it, else add an option to control this precedence.

Thanks in advance.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions