|
Project
|
ReSharper
|
|
Priority
|
Normal |
|
Type
|
Feature |
|
Fix versions
|
Mirabile Futurum |
|
State
|
Open |
|
Assignee
|
Evgeny Pasynkov |
|
Subsystem
|
Code Analysis |
|
Affected versions
|
No Affected versions |
|
Fixed in build
|
No Fixed in build |
Module module = ...;
if (module == null)
{
Response.Redirect("~/IncorrectRequestString.aspx");
}
Contract contract = module.Contract;
Response.Redirect("~/IncorrectRequestString.aspx", true);
On the other hand, if it throws exception one could catch it and use module once again, so we may need a flag on terminating methods, saying if method just never returns or throws unconditionally.
However, a ThreadAbortException is a special exception as it can NOT be caught. So the last line in this example will NEVER be executed! In that sense, this method is a special case which could be handled by your analysis tool as a throw statement, without any user configuration necessary.
try { Response.Redirect("~/IncorrectRequestString.aspx"); } catch (ThreadAbortException) { // statements here will execute, but exception will ALWAYS be rethrown } // execution will NEVER reach this point!This logic is too specific and too complex to implement it in 3.0
It is not quite correct. It is rethrown only if it is caused by Thread.Abort method, but not if it is "manually" thrown.
using System; using System.Threading; class Program { static void Main() { ThreadAbortException e1 = null; try { Thread.CurrentThread.Abort(); } catch(ThreadAbortException e2) { e1 = e2; // This is just to obtain an instance of ThreadAbortException, it has not public ctors Thread.ResetAbort(); } try { throw e1; // Throw instance of ThreadAbortException "manually" } catch(ThreadAbortException) {} Console.WriteLine("It is not re-thrown!"); } }