8000 Add target framework net7.0 by plioi · Pull Request #294 · fixie/fixie · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Add target framework net7.0 #294

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Nov 16, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ jobs:
dotnet-version: |
3.1
6.0
7.0
- run: dotnet --info
- name: Build and Test
env:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ jobs:
dotnet-version: |
3.1
6.0
7.0
- run: dotnet --info
- name: Build and Test
env:
Expand Down
2 changes: 1 addition & 1 deletion src/Fixie.TestAdapter/Fixie.TestAdapter.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
</Target>

<PropertyGroup>
<TargetFrameworks>netcoreapp3.1;net6.0</TargetFrameworks>
<TargetFrameworks>netcoreapp3.1;net6.0;net7.0</TargetFrameworks>
<Description>Visual Studio integration for the Fixie test framework.</Description>
<NuspecFile>Fixie.TestAdapter.nuspec</NuspecFile>
<DebugType>embedded</DebugType>
Expand Down
6 changes: 6 additions & 0 deletions src/Fixie.TestAdapter/Fixie.TestAdapter.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@
<dependency id="Mono.Cecil" version="0.11.3" />
<dependency id="Microsoft.NET.Test.Sdk" version="16.10.0" />
</group>
<group targetFramework="net7.0">
<dependency id="Fixie" version="[$version$]" />
<dependency id="Mono.Cecil" version="0.11.3" />
<dependency id="Microsoft.NET.Test.Sdk" version="16.10.0" />
</group>
</dependencies>
</metadata>
<files>
Expand All @@ -32,5 +37,6 @@
<!-- Run-Time Assets -->
<file target="lib\netcoreapp3.1" src="..\Fixie.TestAdapter\bin\Release\netcoreapp3.1\Fixie.TestAdapter.dll" />
<file target="lib\net6.0" src="..\Fixie.TestAdapter\bin\Release\net6.0\Fixie.TestAdapter.dll" />
<file target="lib\net7.0" src="..\Fixie.TestAdapter\bin\Release\net7.0\Fixie.TestAdapter.dll" />
</files>
</package>
2 changes: 1 addition & 1 deletion src/Fixie.Tests/Fixie.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<Import Project="..\..\build\Fixie.props" />

<PropertyGroup>
<TargetFrameworks>netcoreapp3.1;net6.0</TargetFrameworks>
<TargetFrameworks>netcoreapp3.1;net6.0;net7.0</TargetFrameworks>
<DebugType>embedded</DebugType>
</PropertyGroup>

Expand Down
16 changes: 15 additions & 1 deletion src/Fixie.Tests/StackTracePresentationTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using Assertions;
using Fixie.Reports;
Expand Down Expand Up @@ -70,7 +71,14 @@ public async Task ShouldProvideCleanStackTraceTestMethodFailures()

public async Task ShouldNotAlterTheMeaningfulStackTraceOfExplicitTestMethodInvocationFailures()
{
(await Run<FailureTestClass, ExplicitExceptionHandling>())
var output = (await Run<FailureTestClass, ExplicitExceptionHandling>()).ToArray();

#if NET7_0_OR_GREATER
const string optimizedInvoker = " at InvokeStub_FailureTestClass.Synchronous(Object, Object, IntPtr*)";
const string initialInvoker = " at System.RuntimeMethodHandle.InvokeMethod(Object target, Void** arguments, Signature sig, Boolean isConstructor)";
#endif

output
.ShouldBe(
"Test '" + FullName<FailureTestClass>() + ".Asynchronous' failed:",
"",
Expand All @@ -88,6 +96,12 @@ public async Task ShouldNotAlterTheMeaningfulStackTraceOfExplicitTestMethodInvoc
"",
"Fixie.Tests.FailureException",
At<FailureTestClass>("Synchronous()"),
#if NET7_0_OR_GREATER
output.Contains(optimizedInvoker)
? optimizedInvoker
: initialInvoker,
" at System.Reflection.MethodInvoker.Invoke(Object obj, IntPtr* args, BindingFlags invokeAttr)",
#endif
"--- End of stack trace from previous location where exception was thrown ---",
At(typeof(MethodInfoExtensions), "CallResolvedMethod(MethodInfo resolvedMethod, Object instance, Object[] parameters)", Path.Join("...", "src", "Fixie", "MethodInfoExtensions.cs")),
At(typeof(MethodInfoExtensions), "Call(MethodInfo method, Object instance, Object[] parameters)", Path.Join("...", "src", "Fixie", "MethodInfoExtensions.cs")),
Expand Down
2 changes: 2 additions & 0 deletions src/Fixie.Tests/Utility.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ public static string TargetFrameworkVersion
return "3.1";
#elif NET6_0
return "6.0";
#elif NET7_0
return "7.0";
#endif
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/Fixie/Fixie.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>netcoreapp3.1;net6.0</TargetFrameworks>
<TargetFrameworks>netcoreapp3.1;net6.0;net7.0</TargetFrameworks>
<Description>Ergonomic Testing for .NET</Description>
<DebugType>embedded</DebugType>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
Expand Down
31 changes: 26 additions & 5 deletions src/Fixie/Reports/ExceptionExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,13 @@ public static string LiterateStackTrace(this Exception exception)

var lines = exception.StackTrace.Split(NewLine);

if (lines.Length >= 2)
var totalLines = lines.Length;

if (totalLines >= 2)
{
const string subsequentInvoke = " InvokeStub_";
const string firstInvoke = " System.RuntimeMethodHandle.InvokeMethod(Object target, Void** arguments, Signature sig, Boolean isConstructor)";
const string methodInvoker = " System.Reflection.MethodInvoker.Invoke(Object obj, IntPtr* args, BindingFlags invokeAttr)";
const string synchronousRethrowMarker = "--- End of stack trace from previous location";
const string callResolvedMethod = " Fixie.MethodInfoExtensions.CallResolvedMethod(MethodInfo resolvedMethod, Object instance, Object[] parameters)";
const string constructTestClass = " Fixie.Test.Construct(Type testClass)";
Expand All @@ -58,10 +63,26 @@ public static string LiterateStackTrace(this Exception exception)
if (lines[^2].Contains(callResolvedMethod) ||
lines[^2].Contains(constructTestClass))
{
var linesToRemove =
lines.Length >= 3 && lines[^3].Contains(synchronousRethrowMarker)
? 3
: 2;
int linesToRemove = 2;

if (totalLines >= 3 && lines[^3].Contains(synchronousRethrowMarker))
{
linesToRemove++;

if (totalLines >= 4 && lines[^4].Contains(methodInvoker))
{
linesToRemove++;

if (totalLines >= 5)
{
if (lines[^5].Contains(firstInvoke) ||
lines[^5].Contains(subsequentInvoke))
{
linesToRemove++;
}
}
}
}

return string.Join(NewLine, lines[..^linesToRemove]);
}
Expand Down
0