自动查找 ASP.NET 页面中的编译错误

发布于 2024-10-13 01:19:16 字数 390 浏览 4 评论 0原文

我有一个 ASP.NET 网站,其中页面调用 DLL 中的一些组件。我需要更改组件中方法的签名,并且缺少进行文本搜索,不知道这是否会破坏任何页面。在我看来,这是网络编程的弱点——编译器无法告诉你语法错误。

但事实并非如此。有谁知道是否有一种方法可以在网站上运行蜘蛛来监视编译错误,或者也许有一些工具可以编译文件夹结构中的所有 .aspx 文件以查找编译错误?

这仅用于语法检查——而不是实际预编译网站。

编辑 看起来 aspnet_compiler 正在被推荐。我的网站没有使用 Visual Studio 项目——它是通过我自己的模板系统(在母版页可用之前)随着时间的推移而增长的。因此,可以对文件夹中的所有文件运行 aspnet_compiler 的东西可能会起作用......

I have an ASP.NET website where the pages call a few components in DLLs. I need to change the signature of a method in the component, and short of doing a text search, don't know if this will break any pages or not. IMO, this is the weakness of web programming -- you don't get the benefit of a compiler telling you about syntax errors.

But it doesn't need to be so. Does anyone know if there is a way to run a spider over a website watching for compile errors, or perhaps some tool that would compile all the .aspx files in a folder structure looking for compile errors?

This is merely for syntax checking -- not to actually pre-compile the website.

EDIT It looks like aspnet_compiler is being recommended. I don't use Visual Studio projects for the website -- it's grown over time with my own templating system (back before Master Pages were available). So something that would run aspnet_compiler over all the files in a folder might work...

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

我最亲爱的 2024-10-20 01:19:24

编译器将自动捕获并报告 .cs 源代码或代码隐藏页面中的任何错误。您认为编译器不会捕获语法错误(例如在调用方法时以错误的顺序获取参数等)的假设是不正确的 - 这是使用编译语言的主要好处之一。如果您遇到与此相矛盾的情况,请发布一些代码。

如果您担心 ASPX 文件或视图中的错误(如果使用 MVC),您也可以让 IDE 预编译 ASPX 文件

请参阅本文了解详细信息

我大部分时间都将其关闭,因为它会减慢编译速度,但我在部署站点之前使用它作为额外的验证步骤。

The compiler will automatically catch and any report any errors in your .cs source or code-behind pages. Your assumption that the compiler won't catch syntax errors (such as getting the arguments in the wrong order when calling a method, etc) is incorrect - that's one of the primary benefits of using a compiled language. If you're experiencing something that contradicts this, please post some code.

If you're concerned about errors in the ASPX files or in your views (if using MVC), you can have the IDE precompile ASPX files, as well.

See this article for more information.

I turn this off most of the time since it slows down compilation, but I use it before deploying a site as an extra verification step.

三五鸿雁 2024-10-20 01:19:22

这是我们首先使用 Visual Studio 等开发工具的众多原因之一。实现您所要求的最简单的方法是使用可以编译和检查错误的 IDE 进行开发,即使您选择发布未编译的代码也是如此。

由于 Microsoft 免费提供 Visual Web Developer,因此没有理由不使用它。

This is one of the many reasons we use development tools like Visual Studio in the first place. The single easiest way to do what you're asking is to develop with an IDE that DOES compile and check for errors, even ifyou choose to publish teh un-compiled code.

Since Microsoft offers Visual Web Developer for free, there's really no reason to NOT use it.

梦魇绽荼蘼 2024-10-20 01:19:21

您可以在项目上放置一个标志,告诉它在编译项目时编译所有 aspx 文件。它会增加您的构建时间,但有时是值得的。请参阅http://mikehadlow.blogspot.com/2008/05/ compiling-aspx-templates-using.html

此外,Resharper 非常擅长查找方法引用,即使在 aspx 文件中也是如此。因此,如果您使用 Resharper 重命名方法,只要您的解决方案包含 Web 项目,它也会在 aspx 文件中找到并重命名该方法。

There is a flag that you can put on your project that tells it to compile all the aspx files when the project is compiled. It adds time to your build, but it can sometimes be worthwhile. See http://mikehadlow.blogspot.com/2008/05/compiling-aspx-templates-using.html

Also, Resharper is really good at finding references to methods, even in aspx files. So if you use Resharper to rename a method, as long as your solution includes the web project, it'll find and rename that method in the aspx files, too.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文