How to do code analysis on ASP.NET MVC 3 view files?
How to do code analysis on code written in ASPX / ASCX files in an ASP.NET MVC 3 application? Is it possible to create custom rules which can inspect code written in "<%= %>" or "<%: %>" or "<% %>" code blocks? The ASPX / ASCX files in this context a开发者_如何学编程re views or partial views in ASP.NET MVC 3 context.
Code analysis is usually performed on server side logic code. Such code should never be written in a view thus no need to perform code analysis there. For views spitting HTML the W3C validator is a good tool to analyze the code.
The <%:
and <%=
are just calls to helper methods whose logic is implemented on the server so they should be analyzed in the server code. As far as the <%
is concerned if I were to write a code analysis tool for views I would put as rule inside it that <%
is not present in a view because this assumes the developer wrote a server side code in a view which as I stated shouldn't be done.
精彩评论