Skip to content

Commit 5374caa

Browse files
authoredJan 18, 2025
SWEEP: PrintStackTrace cleanup, #932 (#1101)
* SWEEP: Exception.StackTrace cleanup, #932 * Add unit tests for StackTraceHelper, #932 * Better assert for PrintCurrentStackTrace that caller is the top line * PR feedback * Add string.Contains extension method for .NET Framework and Standard 2.0 * Use MemoryExtensions.Contains * Revert test code to use extension method * Use is null
1 parent dcfa0e2 commit 5374caa

File tree

70 files changed

+645
-352
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

70 files changed

+645
-352
lines changed
 

‎Directory.Build.targets

+8-1
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@
8080
<DebugType>portable</DebugType>
8181
</PropertyGroup>
8282

83-
<!-- Features in .NET Standard 2.1, .NET 5.x, .NET 6.x, .NET 7.x, .NET 8.x, and .NET 9.x only -->
83+
<!-- Features in .NET Standard 2.1, .NET Core 3.x, .NET 5.x, .NET 6.x, .NET 7.x, .NET 8.x, and .NET 9.x only -->
8484
<PropertyGroup Condition=" '$(TargetFramework)' == 'netstandard2.1' Or $(TargetFramework.StartsWith('netcoreapp3.')) Or $(TargetFramework.StartsWith('net5.')) Or $(TargetFramework.StartsWith('net6.')) Or $(TargetFramework.StartsWith('net7.')) Or $(TargetFramework.StartsWith('net8.')) Or $(TargetFramework.StartsWith('net9.')) ">
8585

8686
<DefineConstants>$(DefineConstants);FEATURE_ARRAY_FILL</DefineConstants>
@@ -93,6 +93,13 @@
9393

9494
</PropertyGroup>
9595

96+
<!-- Features in .NET Standard 2.1, .NET Core 2.1-2.2, .NET Core 3.x, .NET 5.x, .NET 6.x, .NET 7.x, .NET 8.x, and .NET 9.x only -->
97+
<PropertyGroup Condition=" '$(TargetFramework)' == 'netstandard2.1' Or '$(TargetFramework)' == 'netcoreapp2.1' Or '$(TargetFramework)' == 'netcoreapp2.2' Or $(TargetFramework.StartsWith('netcoreapp3.')) Or $(TargetFramework.StartsWith('net5.')) Or $(TargetFramework.StartsWith('net6.')) Or $(TargetFramework.StartsWith('net7.')) Or $(TargetFramework.StartsWith('net8.')) Or $(TargetFramework.StartsWith('net9.')) ">
98+
99+
<DefineConstants>$(DefineConstants);FEATURE_STRING_CONTAINS_STRINGCOMPARISON</DefineConstants>
100+
101+
</PropertyGroup>
102+
96103
<!-- Features in .NET Standard 2.x, .NET Core 2.x, .NET Core 3.x, .NET 5.x, .NET 6.x, .NET 7.x, .NET 8.x, and .NET 9.x -->
97104
<PropertyGroup Condition=" $(TargetFramework.StartsWith('netstandard2.')) Or $(TargetFramework.StartsWith('netcoreapp2.')) Or $(TargetFramework.StartsWith('netcoreapp3.')) Or $(TargetFramework.StartsWith('net5.')) Or $(TargetFramework.StartsWith('net6.')) Or $(TargetFramework.StartsWith('net7.')) Or $(TargetFramework.StartsWith('net8.')) Or $(TargetFramework.StartsWith('net9.')) ">
98105

‎src/Lucene.Net.Benchmark/ByTask/Benchmark.cs

+3-4
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,7 @@ public Benchmark(TextReader algReader)
5858
}
5959
catch (Exception e) when (e.IsException())
6060
{
61-
//e.printStackTrace();
62-
Console.Error.WriteLine(e.ToString());
61+
e.PrintStackTrace();
6362
throw new Exception("Error: cannot init PerfRunData!", e);
6463
}
6564

@@ -145,7 +144,7 @@ public static void Exec(string[] args)
145144
}
146145
catch (Exception e) when (e.IsException())
147146
{
148-
Console.Error.WriteLine(e.ToString());
147+
e.PrintStackTrace();
149148
Environment.Exit(1);
150149
}
151150

@@ -160,7 +159,7 @@ public static void Exec(string[] args)
160159
catch (Exception e) when (e.IsException())
161160
{
162161
Console.Error.WriteLine("Error: cannot execute the algorithm! " + e.Message);
163-
Console.Error.WriteLine(e.ToString());
162+
e.PrintStackTrace();
164163
}
165164

166165
Console.WriteLine("####################");

0 commit comments

Comments
 (0)