如何使用 C# 调试器(或其他任何东西)来检查开源应用程序中 GUI 事件期间发生的情况?

发布于 2024-08-12 23:06:51 字数 209 浏览 4 评论 0原文

想象一下,您获得了一个用 C# 编写的又大又漂亮的应用程序,并且具有完整的源代码。因此,您想弄清楚当您执行用户事件时会执行哪些方法,例如按下按钮或按下热键或其他什么。代码库太大了,您不想手动查找代码的相关部分,例如跟踪该按钮的事件处理程序。

那么,有没有一种简单的自动化方法来获取从时间 T(即我按下按钮的时间)开始执行的某种方法的日志?您能否解释和/或提供专门处理这种情况的文章的链接?

imagine that you are given a big nice app in C#, with full source code. So you want to figure out what methods are executed when you do a user event, e.g. press a button or press a hotkey or whatever. The codebase is so big that you don't feel like looking for the relevant part of the code manually, e.g. tracking down the event handler for that button.

Well, is there a straightforward automated way to obtain some sort of a log of methods being executed beginning with time T (which is when I press the button)? Could you explain and/or provide links to articles dealing specifically with this situation?

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

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

发布评论

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

评论(4

↘紸啶 2024-08-19 23:06:51

其他人描述的代码覆盖工具利用了分析代码的能力。代码覆盖率工具的基础是它使用应用程序分析器,并被编程为执行源代码匹配和行命中计数作为其分析的一部分。对于 .NET,代码覆盖率和其他分析工具将利用 。 NET 分析 API。甚至NCover。

存在其他工具可以为您提供更多您正在寻找的日志活动,而不是行命中计数。您甚至可以编写自己的分析应用程序,该应用程序可能会记录到特殊的 XML 文件,然后对其进行数字签名、时间戳,并将其上传到服务器进程。

  • AQtime 似乎具有您可能正在寻找的控制流和日志记录功能为了。
  • Sparx Systems 的 Enterprise Architect 包含一个名为 SSProfiler75.exe 的分析应用程序,它是它能够将源代码“逆向工程”成序列图。

考虑寻找代码分析工具,而不仅仅是代码覆盖工具,这是分析器的一种用例。

A code coverage tool, which others describe, leverages the ability to profile code. The underpinnings of a code coverage tool are that it uses an application profiler, and is programmed to perform source code matching and line hit counts as part of its profiling. In the case of .NET, code coverage and other profiling tools will be leveraging the .NET Profiling API. Even NCover.

Other tools exist which may provide you more of a log-activity that you are looking for, rather than line-hit-counts. You can even work on programming your own profiling application which might log to a special XML file, and then digitally sign it, timestamp it, and upload it to a server process.

  • AQtime seems to have the flow-of-control and logging capabilities you might be looking for.
  • Enterprise Architect from Sparx Systems includes a profiling application called SSProfiler75.exe, which is behind its ability to "reverse engineer" source code into sequence diagrams.

Consider looking for code profiling tools, not simply code coverage tools, which are one use case for a profiler.

南城旧梦 2024-08-19 23:06:51

执行的方法列表称为“代码覆盖率”。

有一种称为“代码覆盖率分析器”的工具可以记录所调用的方法:当您有一个或多个测试用例并且想要知道测试“覆盖”哪些方法时,这在测试代码时非常有用。

此类 C# 工具的一个示例称为 NCover:有关此工具和其他工具的链接,请参阅 C#/.net 的代码覆盖率

The list of methods executed is called "code coverage".

There are tools called "code coverage analyzers" which log the methods called: this is useful when testing code, when you have one or more test cases and want to know what methods the tests are 'covering'.

One example of such a tool for C# is called NCover: for links to this and other tools, see Code Coverage for C#/.net.

彼岸花似海 2024-08-19 23:06:51

您可以使用 C# Visual Studio Express 并在代码中设置断点,然后从 IDE 使用单步调试。您还可以通过在设计器模式下双击按钮来了解按下按钮时执行的代码。它会直接带您到相关代码,您只需在那里放置一个断点,然后运行应用程序即可。

没有规定说你不能使用 VS 来调试开源应用程序,即使 VS 是闭源的。而且它是免费的,为什么不呢?

You can use C# Visual Studio Express and set a breakpoint in the code, then use step debugging from the IDE. You can also find out what code is executed when a button is pressed by double-clicking the button in designer mode. It takes you straight to the relevant code, and you can just put a break point there and then run the application.

There's no rule that says you can't use VS to debug an open source app, even though VS is closed source. And it's free, so why not?

天荒地未老 2024-08-19 23:06:51

我确信有人可以编写一个宏,以编程方式向所有事件处理程序添加断点!

Visual Studio 2010 有方法层次结构视图,非常好,但 2008 年不可用

I'm sure somebody could write a macro that will programatically add break points to all event handlers!!

visual studio 2010 has the method hierarchy view which is reallly nice, but it's not available in 2008

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