0

Why is resharper suggesting "implicitly captured closure"



        [Test]
        public void TestPositions()
        {
            // setup
            var credentials = new byte[] {1, 2, 3};
            var positions = new List<Position>
                                {
                                    new Position {PositionNumber = 21},
                                    new Position {PositionNumber = 22}
                                };

            m_container.MockTerminalInfo.Setup(te => te.GetStuff(positions)).Returns(new IPSubnet("254.254.99.0/24"));
            m_container.MockTerminalInfo.Setup(te => te.GetDifferentStuff(positions, credentials, someLogicalField)).Returns(new IPSubnet("254.254.99.0/24"));


       }



       Bool someLogicalField = true;


Resharper gives the warning:
"Implicitly captured closure: credentials and this"

Can someone please explain this?
Also why is it a warning intead of maybe suggestion/hint?

Cheers,
Calin

8 comments

Please sign in to leave a comment.