diff options
author | Sebastien Pouliot <sebastien@xamarin.com> | 2013-09-04 16:33:39 +0400 |
---|---|---|
committer | Sebastien Pouliot <sebastien@xamarin.com> | 2013-09-04 16:33:39 +0400 |
commit | 097a333cd590e9f45c9f40d53fbb72e94b0a3e61 (patch) | |
tree | bef6ef8b2edda0507761ba5b645d55566a904439 | |
parent | a4f678fc72876d03cd7054ec0bcf8485531b8053 (diff) |
Exception.InternalPreserveStackTrace is not something available in Monopre-1.0
-rwxr-xr-x | NUnitLite-0.9.0/src/framework/Internal/AsyncInvocationRegion.cs | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/NUnitLite-0.9.0/src/framework/Internal/AsyncInvocationRegion.cs b/NUnitLite-0.9.0/src/framework/Internal/AsyncInvocationRegion.cs index 345a808..c37a6d5 100755 --- a/NUnitLite-0.9.0/src/framework/Internal/AsyncInvocationRegion.cs +++ b/NUnitLite-0.9.0/src/framework/Internal/AsyncInvocationRegion.cs @@ -9,12 +9,16 @@ namespace NUnit.Framework.Internal internal abstract class AsyncInvocationRegion : IDisposable { private static readonly Type AsyncStateMachineAttribute = Type.GetType("System.Runtime.CompilerServices.AsyncStateMachineAttribute"); +#if !MONOTOUCH private static readonly MethodInfo PreserveStackTraceMethod = typeof(Exception).GetMethod("InternalPreserveStackTrace", BindingFlags.Instance | BindingFlags.NonPublic); +#endif private static readonly Action<Exception> PreserveStackTrace; static AsyncInvocationRegion() { +#if !MONOTOUCH PreserveStackTrace = (Action<Exception>)Delegate.CreateDelegate(typeof(Action<Exception>), PreserveStackTraceMethod); +#endif } private AsyncInvocationRegion() @@ -85,7 +89,8 @@ at wrapping a non-async method invocation in an async region was done"); } catch (Exception e) { - PreserveStackTrace(e); + if (PreserveStackTrace != null) + PreserveStackTrace(e); throw; } } @@ -109,7 +114,8 @@ at wrapping a non-async method invocation in an async region was done"); { IList<Exception> innerExceptions = GetAllExceptions(e.InnerException); - PreserveStackTrace(innerExceptions[0]); + if (PreserveStackTrace != null) + PreserveStackTrace(innerExceptions[0]); throw innerExceptions[0]; } |