views:

41

answers:

1

Suppose I have a model and a view that display this model properties.

public class UserModel
{
    public string UserName { get; set; }
    .................
}

somewhere in a view...

<%= Model.UserName %>

Now I rename one of the properties (say, UserName => FullUserName), VS will suggest to perform refactoring meaning project-wide renaming of references to this property. It will really work everywhere in code except in the views.

Why? There is a setting to have the views compiled at the project build. Why won't it perform simple little refactoring there as well?

Is there any way to persuade it to?

+2  A: 

ReSharper supports renaming like this and also provides support for optionally renaming string literals. This is useful if you have code like this:

<asp:Label id="label1" runat="server"
     Text='<%# Container.DataItem("CustomerName") %>

If you rename the CustomerName property then ReSharper will prompt to see if you would like to change the "CustomerName" string too.

ReSharper isn't free but it is a very powerful tool and it can do a lot more than refactoring.

MikeD