我有一个会抛出异常的方法:
public void MyMethod()
{
// do some logging
throw new Exception("My Text");
}
我在我的代码中使用这个方法超过100次,问题是当我把这个方法用在另外一个必须返回值的方法中时,Resharper并不理解这里并不需要返回值,例如:
public int AnotherMethod()
{
// some stuff
MyMethod(); // <= it always throws exception
return 0; // i have to put this code, while it never executes
}
有没有办法告诉Re-sharper,像这样把MyMethod标记为异常呢?
public int AnotherMethod()
{
// some stuff
throw new Exception(); // <= it always throws exception
//return 0; <= this line is no more needed
}
[ContractAnnotation("=> halt")] public void TerminationMethod()
。 - ta.speot.is