Skip to content
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

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

Open
Bergam64 opened this issue Jul 21, 2022 · 1 comment

Comments

@Bergam64
Copy link

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.

@BarzenX
Copy link

BarzenX commented Feb 2, 2024

This would be awesome!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants