Skip to content
This repository was archived by the owner on Jan 14, 2021. It is now read-only.

Commit ab5cc9c

Browse files
authored
[FinallyDelegate] Make this work with platforms without remoting. (#8)
1 parent b777682 commit ab5cc9c

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

NUnitLite-1.0.0/src/framework/FinallyDelegate.cs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@
2424
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
2525
// ***********************************************************************
2626

27+
#if __IOS__ || __WATCHOS__ || __TVOS__
28+
#define NO_REMOTING
29+
#endif
30+
2731
using System;
2832
using System.Diagnostics;
2933
using System.Threading;
@@ -60,7 +64,11 @@ public class FinallyDelegate
6064

6165
Dictionary<Guid, TestResult> lookupTable;
6266

67+
#if NO_REMOTING
68+
static Container container;
69+
#else
6370
private static readonly string CONTEXT_KEY = "TestResultName";
71+
#endif
6472

6573
public FinallyDelegate () {
6674
this.testStack = new Stack<Tuple<TestExecutionContext, long, TestResult>>();
@@ -73,14 +81,22 @@ public void Set (TestExecutionContext context, long startTicks, TestResult resul
7381
/* keep name in LogicalCallContext, because this will be inherited by
7482
* Threads spawned by the test case */
7583
var guid = Guid.NewGuid();
84+
#if NO_REMOTING
85+
container = new Container (guid);
86+
#else
7687
CallContext.SetData(CONTEXT_KEY, new Container(guid));
88+
#endif
7789

7890
this.lookupTable.Add(guid, result);
7991
this.testStack.Push(frame);
8092
}
8193

8294
public void HandleUnhandledExc (Exception ex) {
95+
#if NO_REMOTING
96+
Container c = container;
97+
#else
8398
Container c = (Container) CallContext.GetData(CONTEXT_KEY);
99+
#endif
84100
TestResult result = this.lookupTable [c.guid];
85101
result.RecordException(ex);
86102
result.ThreadCrashFail = true;

0 commit comments

Comments
 (0)