重命名重构是否为强类型剃刀视图中的某个人工作?

Ole*_* D. 23 asp.net-mvc refactoring visual-studio-2010 strongly-typed-view razor

我有一个看起来像这样的模型:

public class Person
{
     public string PostalCode {get;set;}
}
Run Code Online (Sandbox Code Playgroud)

然后我有一个剃刀的观点

@model MvcApp1.Person

Your location is: @Model.PostalCode
Run Code Online (Sandbox Code Playgroud)

当我使用Visual Studio的2010重命名重构(Ctrl + R,R)时,属性在模型类上重命名,但在视图中保持不变.

我的理解是,由于视图是强类型的,因此视图中也应该重命名.

我究竟做错了什么?

SLa*_*aks 20

VS的重构引擎不支持Razor.

  • @Oleg在您的项目文件中是,将<MvcBuildViews> false </ MvcBuildViews>更改为<MvcBuildViews> true </ MvcBuildViews> (15认同)
  • 编译时检查视图怎么样?因为在重构之后没有PostalCode属性,有没有办法得到编译器错误? (4认同)
  • 在 Visual Studio 2015 中仍然不支持,但 resharper 支持它 (2认同)