Full framework

This commit is contained in:
Ben Adams
2017-11-13 12:14:24 +00:00
parent 5eb9c25574
commit f250bdef96
7 changed files with 84 additions and 35 deletions

View File

@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp2.0</TargetFramework>
<TargetFrameworks>netcoreapp2.0;net46</TargetFrameworks>
<IsPackable>false</IsPackable>
</PropertyGroup>

View File

@@ -38,7 +38,7 @@ namespace Demystify
// Assert
var stackTrace = demystifiedException.ToString();
stackTrace = ReplaceLineEndings.Replace(stackTrace, "");
var trace = stackTrace.Split(Environment.NewLine)
var trace = stackTrace.Split(new[] { Environment.NewLine }, StringSplitOptions.None)
// Remove items that vary between test runners
.Where(s =>
s != " at void System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, object state)" &&

View File

@@ -22,16 +22,21 @@ namespace Demystify
stackFrame => stackFrame.MethodInfo.ToString()
)
// Remove Framework method that can be optimized out (inlined)
.Where(methodName => methodName != "System.Collections.Generic.List<T>+Enumerator.MoveNext()")
// Don't include this method as call stack shared between multiple tests
.SkipLast(1);
.Where(methodName => !methodName.StartsWith("bool System.Collections.Generic.List<T>+"));
var count = methodNames.Count();
methodNames = methodNames.Take(count - 1);
foreach (var method in methodNames)
{
Console.WriteLine(method.ToString());
}
// Assert
Assert.Equal (ExpectedCallStack, methodNames.ToList());
var expected = ExpectedCallStack.ToArray();
var trace = methodNames.ToArray();
Assert.Equal(expected.Length, trace.Length);
for (var i = 0; i < expected.Length; i++)
{
Assert.Equal(expected[i], trace[i]);
}
}
@@ -52,7 +57,6 @@ namespace Demystify
static List<string> ExpectedCallStack = new List<string>()
{
"bool System.Collections.Generic.List<T>+Enumerator.MoveNextRare()",
"IEnumerable<string> Demystify.MixedStack.Iterator()+MoveNext()",
"string string.Join(string separator, IEnumerable<string> values)",
"string Demystify.MixedStack+GenericClass<T>.GenericMethod<V>(ref V value)",

View File

@@ -1,5 +1,6 @@
using System;
using System.Diagnostics;
using System.Linq;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using Xunit;
@@ -28,13 +29,12 @@ namespace Demystify
// Assert
var stackTrace = demystifiedException.ToString();
stackTrace = ReplaceLineEndings.Replace(stackTrace, "");
var trace = stackTrace.Split(Environment.NewLine);
var trace = stackTrace.Split(new[]{Environment.NewLine}, StringSplitOptions.None);
Assert.Equal(
new[] {
"System.Exception: Exception of type 'System.Exception' was thrown. ---> System.Exception: Exception of type 'System.Exception' was thrown.",
" at Task Demystify.NonThrownException.DoesNotPreventThrowStackTrace()+()=>{}",
" at void System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, object state)",
" at async Task Demystify.NonThrownException.DoesNotPreventThrowStackTrace()",
" --- End of inner exception stack trace ---"},
trace);
@@ -52,13 +52,12 @@ namespace Demystify
// Assert
stackTrace = demystifiedException.ToString();
stackTrace = ReplaceLineEndings.Replace(stackTrace, "");
trace = stackTrace.Split(Environment.NewLine);
trace = stackTrace.Split(new[] { Environment.NewLine }, StringSplitOptions.None);
Assert.Equal(
new[] {
"System.Exception: Exception of type 'System.Exception' was thrown. ---> System.Exception: Exception of type 'System.Exception' was thrown.",
" at Task Demystify.NonThrownException.DoesNotPreventThrowStackTrace()+()=>{}",
" at void System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, object state)",
" at async Task Demystify.NonThrownException.DoesNotPreventThrowStackTrace()",
" --- End of inner exception stack trace ---",
" at async Task Demystify.NonThrownException.DoesNotPreventThrowStackTrace()"
@@ -78,11 +77,14 @@ namespace Demystify
// Assert
var stackTrace = est.ToString();
stackTrace = ReplaceLineEndings.Replace(stackTrace, "");
var trace = stackTrace.Split(Environment.NewLine);
var trace = stackTrace.Split(new[] { Environment.NewLine }, StringSplitOptions.None)
// Remove Full framework entries
.Where(s => !s.StartsWith(" at bool System.Threading._ThreadPoolWaitCallbac") &&
!s.StartsWith(" at void System.Threading.Tasks.Task.System.Thre"));
Assert.Equal(
new[] {
" at void System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, object state)",
" at bool System.Threading.ThreadPoolWorkQueue.Dispatch()"},
trace);
}