Closed
Description
When using NUnit in C++/CLI and the state is somehow corrupted (unrecoverable errors), the nunit thread that runs the test crashes. The nunit-console thread that is waiting on the operation to complete, never exits the wait and therefore hangs the whole process.
Maybe using NUnit for C++/CLI is not supported, but we have a lot of them.
I have made a quick fix like this in NUnit.Framework.Internal.Reflect in Reflect.cs:
[HandleProcessCorruptedStateExceptions] //put here to handle native corrupt state exceptions.
public static object InvokeMethod( MethodInfo method, object fixture, params object[] args )
{
if(method != null)
{
try
{
return method.Invoke(fixture, args);
}
#if !PORTABLE && !NETSTANDARD1_6
catch (System.Threading.ThreadAbortException)
{
// No need to wrap or rethrow ThreadAbortException
return null;
}
#endif
catch (TargetInvocationException e)
{
throw new NUnitException("Rethrown", e.InnerException);
}
catch (Exception e)
{
throw new NUnitException("Rethrown", e);
}
#pragma warning disable 1058
catch
#pragma warning restore 1058
{
throw new NUnitException("Rethrown", new Exception("Unknown Native exception thrown."));
}
}
return null;
}