AsyncInvocationRegion: Check if Exception.InternalPreserveStackTrace really exists.

This commit is contained in:
Virgile Bello 2013-07-10 11:48:02 +09:00
Родитель ba255da522
Коммит 9be669e438
1 изменённых файлов: 5 добавлений и 3 удалений

Просмотреть файл

@ -14,7 +14,7 @@ namespace NUnit.Framework.Internal
static AsyncInvocationRegion()
{
PreserveStackTrace = (Action<Exception>)Delegate.CreateDelegate(typeof(Action<Exception>), PreserveStackTraceMethod);
PreserveStackTrace = PreserveStackTraceMethod != null ? (Action<Exception>)Delegate.CreateDelegate(typeof(Action<Exception>), PreserveStackTraceMethod) : null;
}
private AsyncInvocationRegion()
@ -85,6 +85,7 @@ at wrapping a non-async method invocation in an async region was done");
}
catch (Exception e)
{
if (PreserveStackTrace != null)
PreserveStackTrace(e);
throw;
}
@ -109,6 +110,7 @@ at wrapping a non-async method invocation in an async region was done");
{
IList<Exception> innerExceptions = GetAllExceptions(e.InnerException);
if (PreserveStackTrace != null)
PreserveStackTrace(innerExceptions[0]);
throw innerExceptions[0];
}