Skip to content

Commit 8fc0b81

Browse files
committed
Removed other use of stacktrace in netcore
1 parent 25adbff commit 8fc0b81

File tree

1 file changed

+5
-15
lines changed

1 file changed

+5
-15
lines changed

src/TestStack.BDDfy/Scanners/ScenarioScanners/FluentScenarioScanner.cs

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
using System;
2-
using System.Collections.Generic;
3-
using System.Diagnostics;
1+
using System.Collections.Generic;
42
using System.Linq;
53
using TestStack.BDDfy.Configuration;
64

@@ -38,26 +36,18 @@ private List<Step> CloneSteps(IEnumerable<Step> steps)
3836
private static string GetTitleFromMethodNameInStackTrace(object testObject)
3937
{
4038
// ReSharper disable once JoinDeclarationAndInitializer
41-
StackTrace trace;
4239
#if STACKTRACE
43-
trace = new StackTrace();
44-
#else
45-
try
46-
{
47-
throw new Exception();
48-
}
49-
catch (Exception e)
50-
{
51-
trace = new StackTrace(e, false);
52-
}
53-
#endif
40+
var trace = new System.Diagnostics.StackTrace();
5441
var frames = trace.GetFrames();
5542

5643
var initiatingFrame = frames?.LastOrDefault(s => s.GetMethod().DeclaringType == testObject.GetType());
5744
if (initiatingFrame == null)
5845
return null;
5946

6047
return Configurator.Scanners.Humanize(initiatingFrame.GetMethod().Name);
48+
#else
49+
return null;
50+
#endif
6151
}
6252
}
6353
}

0 commit comments

Comments
 (0)