0

I have this code that has a circular reference between Service1 and Service 2 and I am using VS2015 Code Map to find circular references but they do not seem to be showing up

I have selected Layout > Analyzers > Circular References Analyzer and according to the legend on the right it should be highlighted in red square boxes...

    public interface IService1
        {
            void Dosometing1();
            void Donothing();
        }

        public class Service1 : IService1
        {
            private readonly IService2 _service2;

            public Service1(IService2 service2)
            {
                _service2 = service2;
            }

            public void Dosometing1(){}
            public void Donothing()
            {
             _service2.Dosometing2();   
            }
        }

        public interface IService2
        {
            void Dosometing2();
        }

        public class Service2 : IService2
        {
            readonly IService1 _service1;

            public Service2(IService1 service1)
            {
                _service1 = service1;
            }

            public void Dosometing2()
            {
                _service1.Donothing();

            }
        }

circ ref from code map

kurasa
  • 5,205
  • 9
  • 38
  • 53

1 Answers1

1

There are also no circular references in that graph anywhere. All the links flow from left to right and none from right to left. The circular references analyzer highlights cycles in the visible graph.

Here's an example of a simple circular reference at method level:

    class TestMe
    {
        public void A()
        {
            B();
        }

        public void B()
        {
            A();
        }
    }

And the code map:

enter image description here

Please let me know if you were expecting something else. It would also help if you could describe what sort of architectural violation you are trying to catch :)

Bogdan Gavril MSFT
  • 20,615
  • 10
  • 53
  • 74