Search code examples
visual-studionavigationresharperkeyboard-shortcutsspring.net

How do I quickly navigate through xml (DI) configuration files?


I'm working on a .net project that uses the Spring.NET framework for dependency injection (DI). A typical solution contains several dozens of (small) xml DI configuration files. Navigating through these files isn't as frictionless as it could be.

I would like to know more tricks to be able to quickly navigate through the xml object definitions and the corresponding code. Got some you care to share?

Example scenarios

For instance, a solution contains the following files:

<!-- file1.xml -->
<object id="exampleObject" 
        type="Examples.ExampleObject, ExamplesLibrary">
  <property name="objectOne" ref="anotherExampleObject"/>    
</object>

<!-- file2.xml, somewhere in the same solution -->
<object id="anotherExampleObject" 
        type="Examples.AnotherExampleObject, ExamplesLibrary">
  <property name="Name" value="anotherExampleObject"/>    
</object>

Assuming you are working in file1.xml, how would you quickly navigate from ...

  • ref="anotherExampleObject" to the object definition in file2.xml?
  • type="Examples.ExampleObject, ExamplesLibrary" to the ExampleObject class in Examples.ExampleObject.cs

Notes

I'm fully aware of the advantages and disadvantages of using XML for configuring a DI container. Let's just accept the fact that I'm required to use xml and that I would like the process to be as friction-less as possible.

Answers do not have to be specific to Spring.NET, navigation tricks used for xml configuration in other .NET DI frameworks are appreciated too.

Currently I work mostly with VS 2010 with ReSharper 6; feel free to recommend any tool compatible with VS 2008 or 2010.


Solution

  • In a DI configuration file, ReSharper allows me to control-click in the value type attribute to immediately jump to the corresponding class:

    ctrl-click to cs file

    Furthermore, with the cursor at I I can hit "alt-`" to show the navigation menu:

    alt-backtick to show navigation menu