+3
Under review

Feature to show code navigation paths to an object

Omid K. Rad 5 years ago updated by Lior Kerner 5 years ago 1
I had originally submitted this to Visual Studio UserVoice: https://goo.gl/RFypH1

Description: Show possible code paths to a specific class member or class members of specific type from current location in code. It always happens that you are coding inside a method and you wonder how you can access object X of type Z from where you are. Is it available through `this.A.K.D.X` or through `this.G().N.T.C.X` or through `SomeStaticClass.I[0].M.R.E().F`?

Of course you can find usages/references of class Z and for each of the references look up references again until you find a path to your current location in code (i.e. this), but it will be much more helpful if we had tooling that showed us possible navigation paths in the code to the target object X, or any members with type of target class Z.

The concept is something similar to friend connections graph that shows if you are directly connected to a person, or connected through your friends, or friends of friends, etc... or if there is no path between you and the other person at all. see http://inmaps.linkedinlabs.com/ for an example of it.

A code connection graph similarly shows you all possible paths that you can use (using dot notations) to access one object from another object. This can become really handy for discovering code specially in large code bases. It could be used for example to find properties that have unnecessary exposures or find code that repeating itself.

For example a developer uses the following code to find a distribution object:

this.ViewModel.TransactionGridRows.First().Account.GetTransactions().Where(t => t.Distributions.Count() == 1).ToList()

What they don't know is that the object they're looking for is already cached in:

this.Buffer.SingleDistributions

This feature will help find it easily when it shows all the paths in code that you can access properties of type Distribution, like:

this -> Buffer (TransactionBuffer class) -> Distributions (List<Distribution> type)

this -> ViewModel -> TransactionGridRows[Index] -> Account -> GetTransactions()[Index] -> Distributions[Index]

This is also possible with find references feature in Visual Studio. But what "Find References" lacks is that it won't tell you other possible indirect paths. You have to inspect all references for yourself.

Under review
Hi Omid!

That's a really cool idea and very interesting, it actually sparked off a discussion within the OzCode team about possible future features.

If you’d like to find the quickest path to get at a certain object you can use OzCode’s Search feature. You can even search by the type name.
By the way, in case you haven’t seen it , the Show All Instances feature will allow you to see an object even if you don’t have any way of getting at it in your current context.
Thanks again for your input!

Lior Kerner, Support Engineer
The OzCode Support Team