This is an automated email from the ASF dual-hosted git repository.

nightowl888 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/lucenenet.git

commit bf7a1c5cef07a2f8d768d2ab407d24ec4aa45323
Author: Shad Storhaug <[email protected]>
AuthorDate: Fri Sep 11 12:06:47 2020 +0700

    Directory.Build.targets: Inverted FEATURE_STACKTRACE so it is on when 
System.Diagnostics.StackTrace is available
---
 Directory.Build.targets                            |  2 +-
 .../Support/StackTraceHelper.cs                    | 23 +++++++++++-----------
 2 files changed, 12 insertions(+), 13 deletions(-)

diff --git a/Directory.Build.targets b/Directory.Build.targets
index 480032b..54188ef 100644
--- a/Directory.Build.targets
+++ b/Directory.Build.targets
@@ -68,6 +68,7 @@
     
<DefineConstants>$(DefineConstants);FEATURE_FILESTREAM_LOCK</DefineConstants>
     
<DefineConstants>$(DefineConstants);FEATURE_METHODBASE_GETMETHODBODY</DefineConstants>
     <DefineConstants>$(DefineConstants);FEATURE_SERIALIZABLE</DefineConstants>
+    <DefineConstants>$(DefineConstants);FEATURE_STACKTRACE</DefineConstants>
     
<DefineConstants>$(DefineConstants);FEATURE_TEXTWRITER_CLOSE</DefineConstants>
     
<DefineConstants>$(DefineConstants);FEATURE_TEXTWRITER_INITIALIZELIFETIMESERVICE</DefineConstants>
     
<DefineConstants>$(DefineConstants);FEATURE_THREAD_INTERRUPT</DefineConstants>
@@ -86,7 +87,6 @@
   <PropertyGroup Condition=" $(TargetFramework.StartsWith('netstandard1.')) Or 
$(TargetFramework.StartsWith('netcoreapp1.')) ">
     
     <DefineConstants>$(DefineConstants);NETSTANDARD1_X</DefineConstants>
-    <DefineConstants>$(DefineConstants);FEATURE_STACKTRACE</DefineConstants>
     
   </PropertyGroup>
 
diff --git a/src/Lucene.Net.TestFramework/Support/StackTraceHelper.cs 
b/src/Lucene.Net.TestFramework/Support/StackTraceHelper.cs
index b781ae5..294c8fd 100644
--- a/src/Lucene.Net.TestFramework/Support/StackTraceHelper.cs
+++ b/src/Lucene.Net.TestFramework/Support/StackTraceHelper.cs
@@ -1,11 +1,11 @@
 using System;
-using System.Text.RegularExpressions;
 
-#if !FEATURE_STACKTRACE
+#if FEATURE_STACKTRACE
 using System.Diagnostics;
 #else
 using System.Collections.Generic;
 using System.Linq;
+using System.Text.RegularExpressions;
 #endif
 
 namespace Lucene.Net.Util
@@ -33,8 +33,6 @@ namespace Lucene.Net.Util
     /// </summary>
     public static class StackTraceHelper
     {
-        private static readonly Regex METHOD_NAME_REGEX = new 
Regex(@"at\s+(?<fullyQualifiedMethod>.*\.(?<method>[\w`]+))\(");
-
         /// <summary>
         /// Matches the StackTrace for a method name.
         /// <para/>
@@ -44,9 +42,6 @@ namespace Lucene.Net.Util
         public static bool DoesStackTraceContainMethod(string methodName)
         {
 #if FEATURE_STACKTRACE
-            IEnumerable<string> allMethods = GetStackTrace(false);
-            return allMethods.Contains(methodName);
-#else
             StackTrace trace = new StackTrace();
             foreach (var frame in trace.GetFrames())
             {
@@ -56,8 +51,10 @@ namespace Lucene.Net.Util
                 }
             }
             return false;
+#else
+            IEnumerable<string> allMethods = GetStackTrace(false);
+            return allMethods.Contains(methodName);
 #endif
-
         }
 
         /// <summary>
@@ -69,9 +66,6 @@ namespace Lucene.Net.Util
         public static bool DoesStackTraceContainMethod(string className, 
string methodName) 
         {
 #if FEATURE_STACKTRACE
-            IEnumerable<string> allMethods = GetStackTrace(true);
-            return allMethods.Any(x => x.Contains(className + '.' + 
methodName));
-#else
             StackTrace trace = new StackTrace();
             foreach (var frame in trace.GetFrames())
             {
@@ -82,10 +76,15 @@ namespace Lucene.Net.Util
                 }
             }
             return false;
+#else
+            IEnumerable<string> allMethods = GetStackTrace(true);
+            return allMethods.Any(x => x.Contains(className + '.' + 
methodName));
 #endif
         }
 
-#if FEATURE_STACKTRACE
+#if !FEATURE_STACKTRACE
+        private static readonly Regex METHOD_NAME_REGEX = new 
Regex(@"at\s+(?<fullyQualifiedMethod>.*\.(?<method>[\w`]+))\(");
+
         private static IEnumerable<string> GetStackTrace(bool 
includeFullyQualifiedName)
         {
             var matches =

Reply via email to