Lint for ASP.NET MVC?

我是研究僧i 提交于 2020-01-05 08:11:32

问题


Is there a lint utility for ASP.NET MVC? Given that I frequently specify views and links via strings, when I move things around or change entity names I often break things, which I then only find out about when something fails at runtime.


回答1:


ReSharper's v6 (whose nightlies are now available, if you don't mind living on the edge) will catch this kind of error for you.




回答2:


You can use Refactor -> Rename and enable Search in Strings to replace every string in the solution




回答3:


Other option -- use the strongly typed helpers (which might still be in the futures assemblies). EG, Html.Action<ProductsController>(x => x.ShowProduct(id)) ; really the only way to fly.




回答4:


I don't know that there's something like that, but I'll tell you what I do: All my view names are in a struct that contains string constants. It's a pain to keep it sync'ed as the project changes, but it's worth it because you're far more likely to catch errors if you're using

ViewNames.Customer

rather than

"customer"


来源:https://stackoverflow.com/questions/5394907/lint-for-asp-net-mvc

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!