查找在C#code未捕获的异常 [英] Find uncaught exceptions in C# code
问题描述
我不知道是否有工具来查找在C#中捕获的异常使用静态code分析?基本上,我想选择的methodA(),并希望抛出的methodA所有异常(),并调用了methodA所有方法()的列表。我想 ReSharper的 +的代理约翰逊和 AtomineerUtils ,均不能这种简单的任务。
下面是我的例子code:
公共类矩形
{
公众诠释宽度{获得;组; }
公众诠释高度{获得;组; }
公众诠释面积()
{
CheckProperties();
长×=宽*高;
如果(X→10)
抛出新ArgumentOutOfRangeException();
返程(INT)×;
}
私人无效CheckProperties()
{
如果(宽℃,||高度℃下)
抛出新的InvalidOperationException异常();
}
}
该工具应能告诉我(任何形式),该方法面积()会抛出 ArgumentOutOfRangeException
或 InvalidOperationException异常。
我使用的R#插件一旦这样做,
自己决定,如果它是值得的: HTTP://exceptionalplugin.$c$cplex.com
I'm wondering if there is a tool to find uncaught exceptions in C# using static code analysis? Basically I want to select a methodA() and want a list of all exceptions thrown by methodA() and all methods called by methodA(). I tried ReSharper + Agent Johnson and AtomineerUtils, both fail this simple task.
Here's my example code:
public class Rectangle
{
public int Width { get; set; }
public int Height { get; set; }
public int Area()
{
CheckProperties();
long x = Width * Height;
if (x > 10)
throw new ArgumentOutOfRangeException();
return (int) x;
}
private void CheckProperties()
{
if (Width < 0 || Height < 0)
throw new InvalidOperationException();
}
}
The tool should be able to tell me (in any form) that method Area() will throw ArgumentOutOfRangeException
or InvalidOperationException.
I used an R# addin once that did that in the IDE - Exceptional. Bad idea, turns out that it complains about every single string.Format call and similar common cases that may indeed throw, but that won't cause issues.
Decide for yourself if it's worth it: http://exceptionalplugin.codeplex.com
这篇关于查找在C#code未捕获的异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!