ReSharper’s Web Path Mapping Explained

One of the many scenarios that ReSharper seeks to address in web projects is a situation where the locations of files during the design of the app are different from the locations where the app gets deployed. This makes life difficult for ReSharper, since it doesn’t know where to go looking for the relevant files. Luckily, the Path Mapping feature lets you configure the locations of those paths.

There are two mechanisms that can both be used to configure path mappings – context actions and explicitly opening the Path Mapping dialog.

When ReSharper sees a path that it doesn’t recognize, it will underline the path with a wavy line, complaining that it doesn’t know where the path is. At this point, pressing Alt+Enter will show you several options for how the situation can be handled:

The first option, Ignore path, simply tells ReSharper to not bother inspecting this particular path wherever it may appear. This is useful in situations where, for example, you are referencing a file that doesn’t yet exist, and might be created later.

The second option is to Set path mapping, i.e. define explicitly how the path is handled.

Once again, there are two options: Substitute replaces a path with a different path, whereas Ignore chooses to ignore the path and is functionally equivalent to the Ignore path context action.

The Path mapping dialog box doesn’t only show up when you use a context action: you can also open it up by selecting the Path mapping element of the properties of the web project you’re working with. Note that we’re talking about the property grid (F4) rather than the tabbed property pages. To bring up the dialog, just press the button next to Path mapping.

Incidentally, the text value next to the button can be one of two possible options – either Custom indicating that some mappings have already been created, or Not set when none have yet been defined. At any rate, just as with the context action, pressing the button brings up the Path mapping window where you can create, delete and change mappings:

We hope you find this feature of ReSharper useful and your experience of developing web applications becomes a little more enjoyable. Develop with pleasure!

image description