From cda8e4e625ddb3b110bc472a1da558579092032c Mon Sep 17 00:00:00 2001 From: Ben Adams Date: Mon, 17 Feb 2020 03:21:56 +0000 Subject: [PATCH 01/18] Bump version + sourcelink --- src/Ben.Demystifier/Ben.Demystifier.csproj | 2 ++ version.json | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Ben.Demystifier/Ben.Demystifier.csproj b/src/Ben.Demystifier/Ben.Demystifier.csproj index de26b84..0550b7a 100644 --- a/src/Ben.Demystifier/Ben.Demystifier.csproj +++ b/src/Ben.Demystifier/Ben.Demystifier.csproj @@ -11,6 +11,7 @@ git true embedded + true @@ -27,6 +28,7 @@ 1.6.0 + diff --git a/version.json b/version.json index 19a4255..edef176 100644 --- a/version.json +++ b/version.json @@ -1,5 +1,5 @@ { - "version": "0.1.4", + "version": "0.1.6", "publicReleaseRefSpec": [ "^refs/heads/master$", // we release out of master "^refs/heads/dev$", // we release out of develop From 0f17b3029b842b0886ce49cafc3032184805873e Mon Sep 17 00:00:00 2001 From: "Mitch Capper (he, him)" Date: Sun, 16 Aug 2020 15:30:11 -0700 Subject: [PATCH 02/18] Prepare for GetMethod to return null and avoid crashing (#107) Closes #106 --- src/Ben.Demystifier/EnhancedStackTrace.Frames.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Ben.Demystifier/EnhancedStackTrace.Frames.cs b/src/Ben.Demystifier/EnhancedStackTrace.Frames.cs index 988f628..ecb646c 100644 --- a/src/Ben.Demystifier/EnhancedStackTrace.Frames.cs +++ b/src/Ben.Demystifier/EnhancedStackTrace.Frames.cs @@ -53,7 +53,7 @@ namespace System.Diagnostics var method = frame.GetMethod(); // Always show last stackFrame - if (!ShowInStackTrace(method) && i < stackFrames.Length - 1) + if (method != null && !ShowInStackTrace(method) && i < stackFrames.Length - 1) { continue; } @@ -62,7 +62,7 @@ namespace System.Diagnostics var row = frame.GetFileLineNumber(); var column = frame.GetFileColumnNumber(); var ilOffset = frame.GetILOffset(); - if (string.IsNullOrEmpty(fileName) && ilOffset >= 0) + if (method != null && string.IsNullOrEmpty(fileName) && ilOffset >= 0) { // .NET Framework and older versions of mono don't support portable PDBs // so we read it manually to get file name and line information From 06fd57f7972b57f382c37822d21577fddcb0f514 Mon Sep 17 00:00:00 2001 From: Ben Adams Date: Tue, 15 Dec 2020 02:16:16 +0000 Subject: [PATCH 03/18] Create dependabot.yml --- .github/dependabot.yml | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 .github/dependabot.yml diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..03ec545 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,11 @@ +# To get started with Dependabot version updates, you'll need to specify which +# package ecosystems to update and where the package manifests are located. +# Please see the documentation for all configuration options: +# https://help.github.com/github/administering-a-repository/configuration-options-for-dependency-updates + +version: 2 +updates: + - package-ecosystem: "nuget" # See documentation for possible values + directory: "/" # Location of package manifests + schedule: + interval: "daily" From 881fec24294ed942d05dc8352c91a255b0b9d1c5 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 15 Dec 2020 02:16:44 +0000 Subject: [PATCH 04/18] Bump System.ValueTuple from 4.4.0 to 4.5.0 Bumps [System.ValueTuple](https://github.com/dotnet/corefx) from 4.4.0 to 4.5.0. - [Release notes](https://github.com/dotnet/corefx/releases) - [Commits](https://github.com/dotnet/corefx/commits) Signed-off-by: dependabot[bot] --- test/Ben.Demystifier.Test/Ben.Demystifier.Test.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/Ben.Demystifier.Test/Ben.Demystifier.Test.csproj b/test/Ben.Demystifier.Test/Ben.Demystifier.Test.csproj index bf3aa90..32761dd 100644 --- a/test/Ben.Demystifier.Test/Ben.Demystifier.Test.csproj +++ b/test/Ben.Demystifier.Test/Ben.Demystifier.Test.csproj @@ -8,7 +8,7 @@ - + From fde9e8c4630b4a2bfeb165cd6a85683bdcb032bb Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 15 Dec 2020 02:16:45 +0000 Subject: [PATCH 05/18] Bump System.Threading.Tasks.Extensions from 4.5.3 to 4.5.4 Bumps [System.Threading.Tasks.Extensions](https://github.com/dotnet/corefx) from 4.5.3 to 4.5.4. - [Release notes](https://github.com/dotnet/corefx/releases) - [Commits](https://github.com/dotnet/corefx/commits) Signed-off-by: dependabot[bot] --- src/Ben.Demystifier/Ben.Demystifier.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Ben.Demystifier/Ben.Demystifier.csproj b/src/Ben.Demystifier/Ben.Demystifier.csproj index 0550b7a..383643b 100644 --- a/src/Ben.Demystifier/Ben.Demystifier.csproj +++ b/src/Ben.Demystifier/Ben.Demystifier.csproj @@ -27,7 +27,7 @@ 1.6.0 - + From 97312bb0f634f121a1979796b3a5d2f75d7869f8 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 15 Dec 2020 02:16:45 +0000 Subject: [PATCH 06/18] Bump System.Reflection.Metadata from 1.6.0 to 5.0.0 Bumps [System.Reflection.Metadata](https://github.com/dotnet/runtime) from 1.6.0 to 5.0.0. - [Release notes](https://github.com/dotnet/runtime/releases) - [Commits](https://github.com/dotnet/runtime/commits/v5.0.0) Signed-off-by: dependabot[bot] --- src/Ben.Demystifier/Ben.Demystifier.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Ben.Demystifier/Ben.Demystifier.csproj b/src/Ben.Demystifier/Ben.Demystifier.csproj index 383643b..01b5b77 100644 --- a/src/Ben.Demystifier/Ben.Demystifier.csproj +++ b/src/Ben.Demystifier/Ben.Demystifier.csproj @@ -25,7 +25,7 @@ - 1.6.0 + 5.0.0 From 66461b7ede3a211fc45970b5f16fb9c016c849ed Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 15 Dec 2020 02:16:46 +0000 Subject: [PATCH 07/18] Bump BenchmarkDotNet from 0.10.12 to 0.12.1 Bumps [BenchmarkDotNet](https://github.com/dotnet/BenchmarkDotNet) from 0.10.12 to 0.12.1. - [Release notes](https://github.com/dotnet/BenchmarkDotNet/releases) - [Commits](https://github.com/dotnet/BenchmarkDotNet/compare/v0.10.12...v0.12.1) Signed-off-by: dependabot[bot] --- .../Ben.Demystifier.Benchmarks.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/Ben.Demystifier.Benchmarks/Ben.Demystifier.Benchmarks.csproj b/test/Ben.Demystifier.Benchmarks/Ben.Demystifier.Benchmarks.csproj index b208351..84dc64e 100644 --- a/test/Ben.Demystifier.Benchmarks/Ben.Demystifier.Benchmarks.csproj +++ b/test/Ben.Demystifier.Benchmarks/Ben.Demystifier.Benchmarks.csproj @@ -6,6 +6,6 @@ - + \ No newline at end of file From e09b8c43181e6cadbe779e75efa58aec3a3e416d Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 15 Dec 2020 02:21:30 +0000 Subject: [PATCH 08/18] Bump Nerdbank.GitVersioning from 3.0.25 to 3.3.37 Bumps [Nerdbank.GitVersioning](https://github.com/dotnet/Nerdbank.GitVersioning) from 3.0.25 to 3.3.37. - [Release notes](https://github.com/dotnet/Nerdbank.GitVersioning/releases) - [Commits](https://github.com/dotnet/Nerdbank.GitVersioning/compare/v3.0.25...v3.3.37) Signed-off-by: dependabot[bot] --- src/Ben.Demystifier/Ben.Demystifier.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Ben.Demystifier/Ben.Demystifier.csproj b/src/Ben.Demystifier/Ben.Demystifier.csproj index 01b5b77..22997fd 100644 --- a/src/Ben.Demystifier/Ben.Demystifier.csproj +++ b/src/Ben.Demystifier/Ben.Demystifier.csproj @@ -22,7 +22,7 @@ - + 5.0.0 From 8bca4d975ece0bbf36c2f87de2a0716743fa3c2f Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 15 Dec 2020 07:10:53 +0000 Subject: [PATCH 09/18] Bump xunit.runner.visualstudio from 2.3.1 to 2.4.3 Bumps [xunit.runner.visualstudio](https://github.com/xunit/visualstudio.xunit) from 2.3.1 to 2.4.3. - [Release notes](https://github.com/xunit/visualstudio.xunit/releases) - [Commits](https://github.com/xunit/visualstudio.xunit/commits/v2.4.3) Signed-off-by: dependabot[bot] --- test/Ben.Demystifier.Test/Ben.Demystifier.Test.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/Ben.Demystifier.Test/Ben.Demystifier.Test.csproj b/test/Ben.Demystifier.Test/Ben.Demystifier.Test.csproj index 32761dd..fc6fd4f 100644 --- a/test/Ben.Demystifier.Test/Ben.Demystifier.Test.csproj +++ b/test/Ben.Demystifier.Test/Ben.Demystifier.Test.csproj @@ -10,7 +10,7 @@ - + From b7519638402f9a63db9d635eb601bd17cfa9d15e Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 15 Dec 2020 07:53:33 +0000 Subject: [PATCH 10/18] Bump xunit from 2.3.1 to 2.4.1 Bumps [xunit](https://github.com/xunit/xunit) from 2.3.1 to 2.4.1. - [Release notes](https://github.com/xunit/xunit/releases) - [Commits](https://github.com/xunit/xunit/compare/2.3.1...2.4.1) Signed-off-by: dependabot[bot] --- test/Ben.Demystifier.Test/Ben.Demystifier.Test.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/Ben.Demystifier.Test/Ben.Demystifier.Test.csproj b/test/Ben.Demystifier.Test/Ben.Demystifier.Test.csproj index fc6fd4f..e3c3689 100644 --- a/test/Ben.Demystifier.Test/Ben.Demystifier.Test.csproj +++ b/test/Ben.Demystifier.Test/Ben.Demystifier.Test.csproj @@ -9,7 +9,7 @@ - + From 87375e9013db462ad5af21bc308bc73c63cfe919 Mon Sep 17 00:00:00 2001 From: Ben Adams Date: Thu, 17 Dec 2020 14:30:54 +0000 Subject: [PATCH 11/18] Create FUNDING.yml --- .github/FUNDING.yml | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 .github/FUNDING.yml diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml new file mode 100644 index 0000000..5c919e1 --- /dev/null +++ b/.github/FUNDING.yml @@ -0,0 +1,2 @@ + +github: [benaadams] From d2e58a8b549409a1898cd35636871bd755ce07e9 Mon Sep 17 00:00:00 2001 From: Ben Adams Date: Sun, 3 Jan 2021 14:37:37 +0000 Subject: [PATCH 12/18] Update framework versions --- sample/StackTrace/StackTrace.csproj | 2 +- .../Ben.Demystifier.Benchmarks.csproj | 4 ++-- test/Ben.Demystifier.Benchmarks/Exceptions.cs | 7 +++++-- test/Ben.Demystifier.Benchmarks/Program.cs | 2 +- test/Ben.Demystifier.Test/Ben.Demystifier.Test.csproj | 3 ++- 5 files changed, 11 insertions(+), 7 deletions(-) diff --git a/sample/StackTrace/StackTrace.csproj b/sample/StackTrace/StackTrace.csproj index 3e72966..8699af6 100644 --- a/sample/StackTrace/StackTrace.csproj +++ b/sample/StackTrace/StackTrace.csproj @@ -2,7 +2,7 @@ Exe - netcoreapp2.0 + netcoreapp2.1 diff --git a/test/Ben.Demystifier.Benchmarks/Ben.Demystifier.Benchmarks.csproj b/test/Ben.Demystifier.Benchmarks/Ben.Demystifier.Benchmarks.csproj index 84dc64e..6c761d2 100644 --- a/test/Ben.Demystifier.Benchmarks/Ben.Demystifier.Benchmarks.csproj +++ b/test/Ben.Demystifier.Benchmarks/Ben.Demystifier.Benchmarks.csproj @@ -1,6 +1,6 @@ - + - netcoreapp2.1;netcoreapp2.0;net462 + netcoreapp2.1;netcoreapp3.1;net462;net5.0 Release Exe diff --git a/test/Ben.Demystifier.Benchmarks/Exceptions.cs b/test/Ben.Demystifier.Benchmarks/Exceptions.cs index 12417a9..c41396e 100644 --- a/test/Ben.Demystifier.Benchmarks/Exceptions.cs +++ b/test/Ben.Demystifier.Benchmarks/Exceptions.cs @@ -2,11 +2,14 @@ using System; using System.Collections.Generic; using System.Diagnostics; using BenchmarkDotNet.Attributes; -using BenchmarkDotNet.Attributes.Jobs; +using BenchmarkDotNet.Jobs; namespace Ben.Demystifier.Benchmarks { - [ClrJob, CoreJob] + [SimpleJob(RuntimeMoniker.Net48)] + [SimpleJob(RuntimeMoniker.NetCoreApp21)] + [SimpleJob(RuntimeMoniker.NetCoreApp31)] + [SimpleJob(RuntimeMoniker.NetCoreApp50)] [Config(typeof(Config))] public class ExceptionTests { diff --git a/test/Ben.Demystifier.Benchmarks/Program.cs b/test/Ben.Demystifier.Benchmarks/Program.cs index 4b8a7e4..ac893e7 100644 --- a/test/Ben.Demystifier.Benchmarks/Program.cs +++ b/test/Ben.Demystifier.Benchmarks/Program.cs @@ -43,6 +43,6 @@ namespace Ben.Demystifier.Benchmarks internal class Config : ManualConfig { - public Config() => Add(new MemoryDiagnoser()); + public Config() => AddDiagnoser(MemoryDiagnoser.Default); } } diff --git a/test/Ben.Demystifier.Test/Ben.Demystifier.Test.csproj b/test/Ben.Demystifier.Test/Ben.Demystifier.Test.csproj index e3c3689..4fb9218 100644 --- a/test/Ben.Demystifier.Test/Ben.Demystifier.Test.csproj +++ b/test/Ben.Demystifier.Test/Ben.Demystifier.Test.csproj @@ -1,13 +1,14 @@ - netcoreapp2.1;netcoreapp2.0;net46 + netcoreapp2.1;netcoreapp3.1;net46;net5.0 true ..\..\src\Ben.Demystifier\key.snk false + From 84d3257a8f1590c699fe7bbb47cbb6b0572ddf55 Mon Sep 17 00:00:00 2001 From: Bruno Garcia Date: Sat, 2 Jan 2021 17:31:54 -0500 Subject: [PATCH 13/18] hide inlined frames --- .../EnhancedStackTrace.Frames.cs | 78 +++++++++++-------- 1 file changed, 45 insertions(+), 33 deletions(-) diff --git a/src/Ben.Demystifier/EnhancedStackTrace.Frames.cs b/src/Ben.Demystifier/EnhancedStackTrace.Frames.cs index ecb646c..f0994f8 100644 --- a/src/Ben.Demystifier/EnhancedStackTrace.Frames.cs +++ b/src/Ben.Demystifier/EnhancedStackTrace.Frames.cs @@ -615,6 +615,18 @@ namespace System.Diagnostics { Debug.Assert(method != null); + // Since .NET 5: + // https://github.com/dotnet/runtime/blob/7c18d4d6488dab82124d475d1199def01d1d252c/src/libraries/System.Private.CoreLib/src/System/Diagnostics/StackTrace.cs#L348-L361 + if ((method.MethodImplementationFlags & MethodImplAttributes.AggressiveInlining) != 0) + { + // Aggressive Inlines won't normally show in the StackTrace; however for Tier0 Jit and + // cross-assembly AoT/R2R these inlines will be blocked until Tier1 Jit re-Jits + // them when they will inline. We don't show them in the StackTrace to bring consistency + // between this first-pass asm and fully optimized asm. + return false; + } + + // Since .NET Core 2: if (StackTraceHiddenAttributeType != null) { // Don't show any methods marked with the StackTraceHiddenAttribute @@ -632,6 +644,17 @@ namespace System.Diagnostics return true; } + // Since .NET Core 2: + if (StackTraceHiddenAttributeType != null) + { + // Don't show any methods marked with the StackTraceHiddenAttribute + // https://github.com/dotnet/coreclr/pull/14652 + if (IsStackTraceHidden(type)) + { + return false; + } + } + if (type == typeof(Task<>) && method.Name == "InnerInvoke") { return false; @@ -662,44 +685,33 @@ namespace System.Diagnostics } } - if (StackTraceHiddenAttributeType != null) + // Fallbacks for runtime pre-StackTraceHiddenAttribute + if (type == typeof(ExceptionDispatchInfo) && method.Name == "Throw") { - // Don't show any types marked with the StackTraceHiddenAttribute - // https://github.com/dotnet/coreclr/pull/14652 - if (IsStackTraceHidden(type)) + return false; + } + + if (type == typeof(TaskAwaiter) || + type == typeof(TaskAwaiter<>) || + type == typeof(ValueTaskAwaiter) || + type == typeof(ValueTaskAwaiter<>) || + type == typeof(ConfiguredValueTaskAwaitable.ConfiguredValueTaskAwaiter) || + type == typeof(ConfiguredValueTaskAwaitable<>.ConfiguredValueTaskAwaiter) || + type == typeof(ConfiguredTaskAwaitable.ConfiguredTaskAwaiter) || + type == typeof(ConfiguredTaskAwaitable<>.ConfiguredTaskAwaiter)) + { + switch (method.Name) { - return false; + case "HandleNonSuccessAndDebuggerNotification": + case "ThrowForNonSuccess": + case "ValidateEnd": + case "GetResult": + return false; } } - else + else if (type.FullName == "System.ThrowHelper") { - // Fallbacks for runtime pre-StackTraceHiddenAttribute - if (type == typeof(ExceptionDispatchInfo) && method.Name == "Throw") - { - return false; - } - else if (type == typeof(TaskAwaiter) || - type == typeof(TaskAwaiter<>) || - type == typeof(ValueTaskAwaiter) || - type == typeof(ValueTaskAwaiter<>) || - type == typeof(ConfiguredValueTaskAwaitable.ConfiguredValueTaskAwaiter) || - type == typeof(ConfiguredValueTaskAwaitable<>.ConfiguredValueTaskAwaiter) || - type == typeof(ConfiguredTaskAwaitable.ConfiguredTaskAwaiter) || - type == typeof(ConfiguredTaskAwaitable<>.ConfiguredTaskAwaiter)) - { - switch (method.Name) - { - case "HandleNonSuccessAndDebuggerNotification": - case "ThrowForNonSuccess": - case "ValidateEnd": - case "GetResult": - return false; - } - } - else if (type.FullName == "System.ThrowHelper") - { - return false; - } + return false; } return true; From a5ae4e6391e02c59c017f06bb265174841ef6750 Mon Sep 17 00:00:00 2001 From: Kirill Osenkov Date: Mon, 7 Dec 2020 14:47:38 -0800 Subject: [PATCH 14/18] Add a unit-test for https://github.com/benaadams/Ben.Demystifier/issues/109 --- test/Ben.Demystifier.Test/TypeNameTests.cs | 29 ++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 test/Ben.Demystifier.Test/TypeNameTests.cs diff --git a/test/Ben.Demystifier.Test/TypeNameTests.cs b/test/Ben.Demystifier.Test/TypeNameTests.cs new file mode 100644 index 0000000..837e8a1 --- /dev/null +++ b/test/Ben.Demystifier.Test/TypeNameTests.cs @@ -0,0 +1,29 @@ +using System; +using System.Diagnostics; +using Xunit; + +namespace Ben.Demystifier.Test +{ + public class TypeNameTests + { + [Fact] + public void NestedGenericTypes() + { + try + { + Throw(new Generic<(int, string)>.Nested()); + } + catch (Exception ex) + { + var text = ex.ToStringDemystified(); + } + } + + public void Throw(Generic<(int a, string b)>.Nested nested) + { + throw null; + } + } + + public class Generic { public struct Nested { } } +} \ No newline at end of file From 6d7a54cd84f6c1d3dc3ee040b08fb03d0f920a1a Mon Sep 17 00:00:00 2001 From: Ben Adams Date: Sun, 3 Jan 2021 15:51:28 +0000 Subject: [PATCH 15/18] Update for new frameworks --- .../EnhancedStackTrace.Frames.cs | 16 +++++++++++- src/Ben.Demystifier/TypeNameHelper.cs | 3 +-- .../AggregateException.cs | 22 +++++++++++++--- .../DynamicCompilation.cs | 1 + .../NonThrownException.cs | 26 ++++++++++++++++++- 5 files changed, 60 insertions(+), 8 deletions(-) diff --git a/src/Ben.Demystifier/EnhancedStackTrace.Frames.cs b/src/Ben.Demystifier/EnhancedStackTrace.Frames.cs index f0994f8..bee86ba 100644 --- a/src/Ben.Demystifier/EnhancedStackTrace.Frames.cs +++ b/src/Ben.Demystifier/EnhancedStackTrace.Frames.cs @@ -663,8 +663,13 @@ namespace System.Diagnostics { return false; } - if (type == typeof(Task)) + if (type == typeof(Task) || type.DeclaringType == typeof(Task)) { + if (method.Name.Contains(".cctor")) + { + return false; + } + switch (method.Name) { case "ExecuteWithThreadLocal": @@ -672,15 +677,24 @@ namespace System.Diagnostics case "ExecutionContextCallback": case "ExecuteEntry": case "InnerInvoke": + case "ExecuteEntryUnsafe": + case "ExecuteFromThreadPool": + case "s_ecCallback": return false; } } if (type == typeof(ExecutionContext)) { + if (method.Name.Contains(".cctor")) + { + return false; + } + switch (method.Name) { case "RunInternal": case "Run": + case "RunFromThreadPoolDispatchLoop": return false; } } diff --git a/src/Ben.Demystifier/TypeNameHelper.cs b/src/Ben.Demystifier/TypeNameHelper.cs index bfa1559..070276f 100644 --- a/src/Ben.Demystifier/TypeNameHelper.cs +++ b/src/Ben.Demystifier/TypeNameHelper.cs @@ -60,9 +60,8 @@ namespace System.Diagnostics } var genericPartIndex = type.Name.IndexOf('`'); - Debug.Assert(genericPartIndex >= 0); - return type.Name.Substring(0, genericPartIndex); + return (genericPartIndex >= 0) ? type.Name.Substring(0, genericPartIndex) : type.Name; } private static void ProcessType(StringBuilder builder, Type type, DisplayNameOptions options) diff --git a/test/Ben.Demystifier.Test/AggregateException.cs b/test/Ben.Demystifier.Test/AggregateException.cs index 3c0034a..59fe292 100644 --- a/test/Ben.Demystifier.Test/AggregateException.cs +++ b/test/Ben.Demystifier.Test/AggregateException.cs @@ -37,14 +37,28 @@ namespace Ben.Demystifier.Test var trace = string.Join("", stackTrace.Split(new[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries) // Remove items that vary between test runners .Where(s => - s != " at Task Ben.Demystifier.Test.DynamicCompilation.DoesNotPreventStackTrace()+() => { }" && - !s.Contains("System.Threading.Tasks.Task.WaitAll") + (s != " at Task Ben.Demystifier.Test.DynamicCompilation.DoesNotPreventStackTrace()+() => { }" && + !s.Contains("System.Threading.Tasks.Task.WaitAll")) ) .Skip(1) .ToArray()) // Remove Full framework back arrow .Replace("<---", ""); - +#if NET5_0 || NETCOREAPP3_1 + var expected = string.Join("", new[] { + " ---> System.ArgumentException: Value does not fall within the expected range.", + " at async Task Ben.Demystifier.Test.AggregateException.Throw1()", + " at async void Ben.Demystifier.Test.AggregateException.DemystifiesAggregateExceptions()+(?) => { }", + " --- End of inner exception stack trace ---", + " at void Ben.Demystifier.Test.AggregateException.DemystifiesAggregateExceptions()", + " ---> (Inner Exception #1) System.NullReferenceException: Object reference not set to an instance of an object.", + " at async Task Ben.Demystifier.Test.AggregateException.Throw2()", + " at async void Ben.Demystifier.Test.AggregateException.DemystifiesAggregateExceptions()+(?) => { }", + " ---> (Inner Exception #2) System.InvalidOperationException: Operation is not valid due to the current state of the object.", + " at async Task Ben.Demystifier.Test.AggregateException.Throw3()", + " at async void Ben.Demystifier.Test.AggregateException.DemystifiesAggregateExceptions()+(?) => { }" + }); +#else var expected = string.Join("", new[] { " at async Task Ben.Demystifier.Test.AggregateException.Throw1()", " at async void Ben.Demystifier.Test.AggregateException.DemystifiesAggregateExceptions()+(?) => { }", @@ -59,7 +73,7 @@ namespace Ben.Demystifier.Test "---> (Inner Exception #2) System.InvalidOperationException: Operation is not valid due to the current state of the object.", " at async Task Ben.Demystifier.Test.AggregateException.Throw3()", " at async void Ben.Demystifier.Test.AggregateException.DemystifiesAggregateExceptions()+(?) => { }"}); - +#endif Assert.Equal(expected, trace); } diff --git a/test/Ben.Demystifier.Test/DynamicCompilation.cs b/test/Ben.Demystifier.Test/DynamicCompilation.cs index 3731011..e9a7364 100644 --- a/test/Ben.Demystifier.Test/DynamicCompilation.cs +++ b/test/Ben.Demystifier.Test/DynamicCompilation.cs @@ -44,6 +44,7 @@ namespace Ben.Demystifier.Test s != " at void System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, object state)" && s != " at Task Ben.Demystifier.Test.DynamicCompilation.DoesNotPreventStackTrace()+() => { }" ) + .Select(s => Regex.Replace(s, "lambda_method[0-9]+\\(", "lambda_method(")) .ToArray(); Assert.Equal( diff --git a/test/Ben.Demystifier.Test/NonThrownException.cs b/test/Ben.Demystifier.Test/NonThrownException.cs index ef5abf2..ef99cf2 100644 --- a/test/Ben.Demystifier.Test/NonThrownException.cs +++ b/test/Ben.Demystifier.Test/NonThrownException.cs @@ -31,13 +31,24 @@ namespace Ben.Demystifier.Test stackTrace = LineEndingsHelper.RemoveLineEndings(stackTrace); var trace = stackTrace.Split(new[]{Environment.NewLine}, StringSplitOptions.None); +#if NETCOREAPP3_1 || NET5_0 Assert.Equal( new[] { - "System.Exception: Exception of type 'System.Exception' was thrown. ---> System.Exception: Exception of type 'System.Exception' was thrown.", + "System.Exception: Exception of type 'System.Exception' was thrown.", + " ---> System.Exception: Exception of type 'System.Exception' was thrown.", " at Task Ben.Demystifier.Test.NonThrownException.DoesNotPreventThrowStackTrace()+() => { }", " at async Task Ben.Demystifier.Test.NonThrownException.DoesNotPreventThrowStackTrace()", " --- End of inner exception stack trace ---"}, trace); +#else + Assert.Equal( + new[] { + "System.Exception: Exception of type 'System.Exception' was thrown. ---> System.Exception: Exception of type 'System.Exception' was thrown.", + " at Task Ben.Demystifier.Test.NonThrownException.DoesNotPreventThrowStackTrace()+() => { }", + " at async Task Ben.Demystifier.Test.NonThrownException.DoesNotPreventThrowStackTrace()", + " --- End of inner exception stack trace ---"}, + trace); +#endif // Act try @@ -54,6 +65,18 @@ namespace Ben.Demystifier.Test stackTrace = LineEndingsHelper.RemoveLineEndings(stackTrace); trace = stackTrace.Split(new[] { Environment.NewLine }, StringSplitOptions.None); +#if NETCOREAPP3_1 || NET5_0 + Assert.Equal( + new[] { + "System.Exception: Exception of type 'System.Exception' was thrown.", + " ---> System.Exception: Exception of type 'System.Exception' was thrown.", + " at Task Ben.Demystifier.Test.NonThrownException.DoesNotPreventThrowStackTrace()+() => { }", + " at async Task Ben.Demystifier.Test.NonThrownException.DoesNotPreventThrowStackTrace()", + " --- End of inner exception stack trace ---", + " at async Task Ben.Demystifier.Test.NonThrownException.DoesNotPreventThrowStackTrace()" + }, + trace); +#else Assert.Equal( new[] { "System.Exception: Exception of type 'System.Exception' was thrown. ---> System.Exception: Exception of type 'System.Exception' was thrown.", @@ -63,6 +86,7 @@ namespace Ben.Demystifier.Test " at async Task Ben.Demystifier.Test.NonThrownException.DoesNotPreventThrowStackTrace()" }, trace); +#endif } [Fact] From 45df64a115887221bc14dd0e1d7418ee8d28b4c7 Mon Sep 17 00:00:00 2001 From: Ben Adams Date: Sun, 3 Jan 2021 16:01:46 +0000 Subject: [PATCH 16/18] Update version --- version.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version.json b/version.json index edef176..a50dbf4 100644 --- a/version.json +++ b/version.json @@ -1,5 +1,5 @@ { - "version": "0.1.6", + "version": "0.2.0", "publicReleaseRefSpec": [ "^refs/heads/master$", // we release out of master "^refs/heads/dev$", // we release out of develop From 786ab1828a6eee2461e370430335612ee8cc2758 Mon Sep 17 00:00:00 2001 From: Ben Adams Date: Sun, 3 Jan 2021 16:09:10 +0000 Subject: [PATCH 17/18] Add GitHub action testing --- .github/workflows/pull-request.yaml | 41 +++++++++++++++++++++++++++++ appveyor.yml | 32 ---------------------- 2 files changed, 41 insertions(+), 32 deletions(-) create mode 100644 .github/workflows/pull-request.yaml delete mode 100644 appveyor.yml diff --git a/.github/workflows/pull-request.yaml b/.github/workflows/pull-request.yaml new file mode 100644 index 0000000..0d5b3ea --- /dev/null +++ b/.github/workflows/pull-request.yaml @@ -0,0 +1,41 @@ +name: Demystifier PR Build +on: pull_request + +jobs: + build: + name: "Build for PR" + runs-on: ${{ matrix.os }} + env: + DOTNET_NOLOGO: true + strategy: + fail-fast: false + matrix: + os: [windows-latest, ubuntu-18.04, macOS-latest] + config: [Debug, Release] + steps: + - name: Clone source + uses: actions/checkout@v2 + with: + fetch-depth: 0 + + - name: Install .NET Core SDK 2.1 + uses: actions/setup-dotnet@v1 + with: + dotnet-version: '2.1.x' + + - name: Install .NET Core SDK 3.1 + uses: actions/setup-dotnet@v1 + with: + dotnet-version: '3.1.x' + + - name: Install .NET SDK 5.0 + uses: actions/setup-dotnet@v1 + with: + dotnet-version: '5.0.x' + + - name: Get .NET information + run: dotnet --info + + - name: "Test" + run: dotnet test -c ${{ matrix.config }} + diff --git a/appveyor.yml b/appveyor.yml deleted file mode 100644 index 9f08f22..0000000 --- a/appveyor.yml +++ /dev/null @@ -1,32 +0,0 @@ -image: Visual Studio 2017 - -branches: - only: - - master - -skip_branch_with_pr: true - -skip_tags: true - -skip_commits: - files: - - BUILDING.md - - CONTRIBUTING.md - - ISSUE_TEMPLATE.md - - LICENCE - - README.md - -nuget: - disable_publish_on_pr: true - -build_script: -- ps: .\build.ps1 -target appveyor - -test: off - -deploy: off - -artifacts: -- path: artifacts/build -- path: artifacts/packages -- path: artifacts/test From 59fa63f20b1fe84791f43e54b111a06b477bc739 Mon Sep 17 00:00:00 2001 From: Ben Adams Date: Sun, 3 Jan 2021 16:33:53 +0000 Subject: [PATCH 18/18] OS test --- test/Ben.Demystifier.Test/Ben.Demystifier.Test.csproj | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/Ben.Demystifier.Test/Ben.Demystifier.Test.csproj b/test/Ben.Demystifier.Test/Ben.Demystifier.Test.csproj index 4fb9218..66837aa 100644 --- a/test/Ben.Demystifier.Test/Ben.Demystifier.Test.csproj +++ b/test/Ben.Demystifier.Test/Ben.Demystifier.Test.csproj @@ -1,7 +1,8 @@ - netcoreapp2.1;netcoreapp3.1;net46;net5.0 + netcoreapp2.1;netcoreapp3.1;net46;net5.0 + netcoreapp2.1;netcoreapp3.1;net5.0 true ..\..\src\Ben.Demystifier\key.snk false