c# 问题 - 是否有一个工具可以确定我应该/可以在哪里使用“使用”确保资源关闭的声明?

发布于 2024-08-19 05:13:10 字数 163 浏览 2 评论 0原文

c# 问题 - 有没有一种工具可以确定我应该/可以在哪里使用“using”语句来确保资源关闭? (以避免内存泄漏等)

包括以下两种情况:

a)有资源未关闭,

b)语法使用 try-catch-finally 并确定这可以更改为 using

谢谢

c# question - is there a tool to identify where I should/can use a "using" statement to ensure resources are closed? (to avoid memory leaks etc)

Including both the cases that:

a) there are resources not been closed and

b) syntax is using a try-catch-finally and identies this could be changed to a using

Thanks

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

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

发布评论

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

评论(4

玩套路吗 2024-08-26 05:13:10

我不确定它是否明确涵盖了情况 b,但是 Gendarme 是一个很好的工具,可以告诉您当您没有using语句时 围绕一次性物品。

I'm not sure if it covers case b explicitly, but Gendarme is a fine tool that will tell you when you don't have a using statement around disposable objects.

奢欲 2024-08-26 05:13:10

不知道这是否是您正在寻找的工具,但是 当您拥有实现 IDisposable 的类中的对象并且您没有处置它时,Code Rush 将突出显示您的代码。

Don't know if this is the kind of tool that you're looking for, but Code Rush will highlight your code when you have an object from a class that implements IDisposable and you're not diposing it.

梦醒时光 2024-08-26 05:13:10

查看是否可以在项目中启用代码分析并打开 Microsoft.Reliability:在失去范围之前释放对象规则

Take a look if you can to enable code analysis in your project and turn on Microsoft.Reliability: Dispose objects before losing scope rule

流云如水 2024-08-26 05:13:10

FxCop 是 Microsoft 提供的一款免费工具,可以执行此操作。它还包含在 Visual Studio 2005+ 的“团队系统”变体中

FxCop is a free tool from Microsoft that can do this. It's also included in the "Team System" variants of Visual Studio 2005+

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