From 14af18c43e1d1b8a80674be6afdfaa7604ab5a19 Mon Sep 17 00:00:00 2001 From: Dennis Doomen Date: Thu, 16 Jan 2025 11:31:29 +0100 Subject: [PATCH 1/3] Bump all dependencies --- .github/workflows/build.yml | 4 +- Build/Build.cs | 4 +- Build/_build.csproj | 6 +- Directory.Build.props | 4 +- Src/FluentAssertions/FluentAssertions.csproj | 4 +- Tests/Approval.Tests/Approval.Tests.csproj | 4 +- .../FluentAssertions/net47.verified.txt | 68 ++++++++--------- .../FluentAssertions/net6.0.verified.txt | 76 +++++++++---------- .../netstandard2.0.verified.txt | 68 ++++++++--------- .../netstandard2.1.verified.txt | 68 ++++++++--------- Tests/FSharp.Specs/FSharp.Specs.fsproj | 3 +- .../FluentAssertions.Equivalency.Specs.csproj | 2 +- .../FluentAssertions.Specs.csproj | 2 +- .../MSTestV2.Specs/MSTestV2.Specs.csproj | 4 +- .../XUnit2.Specs/XUnit2.Specs.csproj | 2 +- Tests/UWP.Specs/UWP.Specs.csproj | 2 +- Tests/VB.Specs/VB.Specs.vbproj | 4 +- global.json | 2 +- 18 files changed, 163 insertions(+), 164 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 08caf2633d..2e842f562e 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -50,7 +50,7 @@ jobs: strategy: matrix: - os: [ubuntu-22.04, macos-12] + os: [ubuntu-24.04, macos-15] runs-on: ${{ matrix.os }} @@ -66,7 +66,7 @@ jobs: 2.1.x 3.1.x 6.0.x - 7.0.x + 8.0.x - name: Run NUKE run: ./build.sh UnitTests diff --git a/Build/Build.cs b/Build/Build.cs index 3b206c57ee..6f9881e68c 100644 --- a/Build/Build.cs +++ b/Build/Build.cs @@ -13,10 +13,8 @@ using Nuke.Common.Tools.GitVersion; using Nuke.Common.Tools.ReportGenerator; using Nuke.Common.Tools.Xunit; +using Nuke.Common.Utilities; using Nuke.Common.Utilities.Collections; -using Nuke.Components; -using static Nuke.Common.IO.FileSystemTasks; -using static Nuke.Common.IO.PathConstruction; using static Nuke.Common.Tools.DotNet.DotNetTasks; using static Nuke.Common.Tools.ReportGenerator.ReportGeneratorTasks; using static Nuke.Common.Tools.Xunit.XunitTasks; diff --git a/Build/_build.csproj b/Build/_build.csproj index 6ecfc4325b..6058846cca 100644 --- a/Build/_build.csproj +++ b/Build/_build.csproj @@ -21,9 +21,9 @@ - - - + + + diff --git a/Directory.Build.props b/Directory.Build.props index ec349586de..fa3f9de386 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -31,11 +31,11 @@ all runtime; build; native; contentfiles; analyzers; buildtransitive - + all runtime; build; native; contentfiles; analyzers; buildtransitive - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/Src/FluentAssertions/FluentAssertions.csproj b/Src/FluentAssertions/FluentAssertions.csproj index 963db04116..030f9996cb 100644 --- a/Src/FluentAssertions/FluentAssertions.csproj +++ b/Src/FluentAssertions/FluentAssertions.csproj @@ -50,7 +50,7 @@ - + runtime; build; native; contentfiles; analyzers; buildtransitive all @@ -59,7 +59,7 @@ - + diff --git a/Tests/Approval.Tests/Approval.Tests.csproj b/Tests/Approval.Tests/Approval.Tests.csproj index 5ec29e2d20..3c3d74211e 100644 --- a/Tests/Approval.Tests/Approval.Tests.csproj +++ b/Tests/Approval.Tests/Approval.Tests.csproj @@ -6,14 +6,14 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive - + diff --git a/Tests/Approval.Tests/ApprovedApi/FluentAssertions/net47.verified.txt b/Tests/Approval.Tests/ApprovedApi/FluentAssertions/net47.verified.txt index bc72e1fbec..51370f44e4 100644 --- a/Tests/Approval.Tests/ApprovedApi/FluentAssertions/net47.verified.txt +++ b/Tests/Approval.Tests/ApprovedApi/FluentAssertions/net47.verified.txt @@ -39,23 +39,23 @@ namespace FluentAssertions public static System.Func Invoking(this T subject, System.Func action) { } public static FluentAssertions.Events.IMonitor Monitor(this T eventSource, System.Func utcNow = null) { } public static FluentAssertions.Specialized.ExecutionTimeAssertions Should(this FluentAssertions.Specialized.ExecutionTime executionTime) { } - [System.Obsolete("You are asserting the \'AndConstraint\' itself. Remove the \'Should()\' method direct" + - "ly following \'And\'", true)] + [System.Obsolete(("You are asserting the \'AndConstraint\' itself. Remove the \'Should()\' method direct" + + "ly following \'And\'"), true)] public static void Should(this FluentAssertions.Specialized.ExecutionTimeAssertions _) { } - [System.Obsolete("You are asserting the \'AndConstraint\' itself. Remove the \'Should()\' method direct" + - "ly following \'And\'", true)] + [System.Obsolete(("You are asserting the \'AndConstraint\' itself. Remove the \'Should()\' method direct" + + "ly following \'And\'"), true)] public static void Should(this FluentAssertions.Specialized.TaskCompletionSourceAssertionsBase _) { } public static FluentAssertions.Types.MethodInfoSelectorAssertions Should(this FluentAssertions.Types.MethodInfoSelector methodSelector) { } - [System.Obsolete("You are asserting the \'AndConstraint\' itself. Remove the \'Should()\' method direct" + - "ly following \'And\'", true)] + [System.Obsolete(("You are asserting the \'AndConstraint\' itself. Remove the \'Should()\' method direct" + + "ly following \'And\'"), true)] public static void Should(this FluentAssertions.Types.MethodInfoSelectorAssertions _) { } public static FluentAssertions.Types.PropertyInfoSelectorAssertions Should(this FluentAssertions.Types.PropertyInfoSelector propertyInfoSelector) { } - [System.Obsolete("You are asserting the \'AndConstraint\' itself. Remove the \'Should()\' method direct" + - "ly following \'And\'", true)] + [System.Obsolete(("You are asserting the \'AndConstraint\' itself. Remove the \'Should()\' method direct" + + "ly following \'And\'"), true)] public static void Should(this FluentAssertions.Types.PropertyInfoSelectorAssertions _) { } public static FluentAssertions.Types.TypeSelectorAssertions Should(this FluentAssertions.Types.TypeSelector typeSelector) { } - [System.Obsolete("You are asserting the \'AndConstraint\' itself. Remove the \'Should()\' method direct" + - "ly following \'And\'", true)] + [System.Obsolete(("You are asserting the \'AndConstraint\' itself. Remove the \'Should()\' method direct" + + "ly following \'And\'"), true)] public static void Should(this FluentAssertions.Types.TypeSelectorAssertions _) { } public static FluentAssertions.Specialized.ActionAssertions Should(this System.Action action) { } public static FluentAssertions.Collections.StringCollectionAssertions Should(this System.Collections.Generic.IEnumerable @this) { } @@ -109,32 +109,32 @@ namespace FluentAssertions public static FluentAssertions.Numeric.NullableNumericAssertions Should(this ulong? actualValue) { } public static FluentAssertions.Numeric.NumericAssertions Should(this ushort actualValue) { } public static FluentAssertions.Numeric.NullableNumericAssertions Should(this ushort? actualValue) { } - [System.Obsolete("You are asserting the \'AndConstraint\' itself. Remove the \'Should()\' method direct" + - "ly following \'And\'", true)] + [System.Obsolete(("You are asserting the \'AndConstraint\' itself. Remove the \'Should()\' method direct" + + "ly following \'And\'"), true)] public static void Should(this FluentAssertions.Primitives.BooleanAssertions _) where TAssertions : FluentAssertions.Primitives.BooleanAssertions { } - [System.Obsolete("You are asserting the \'AndConstraint\' itself. Remove the \'Should()\' method direct" + - "ly following \'And\'", true)] + [System.Obsolete(("You are asserting the \'AndConstraint\' itself. Remove the \'Should()\' method direct" + + "ly following \'And\'"), true)] public static void Should(this FluentAssertions.Primitives.DateTimeAssertions _) where TAssertions : FluentAssertions.Primitives.DateTimeAssertions { } - [System.Obsolete("You are asserting the \'AndConstraint\' itself. Remove the \'Should()\' method direct" + - "ly following \'And\'", true)] + [System.Obsolete(("You are asserting the \'AndConstraint\' itself. Remove the \'Should()\' method direct" + + "ly following \'And\'"), true)] public static void Should(this FluentAssertions.Primitives.DateTimeOffsetAssertions _) where TAssertions : FluentAssertions.Primitives.DateTimeOffsetAssertions { } - [System.Obsolete("You are asserting the \'AndConstraint\' itself. Remove the \'Should()\' method direct" + - "ly following \'And\'", true)] + [System.Obsolete(("You are asserting the \'AndConstraint\' itself. Remove the \'Should()\' method direct" + + "ly following \'And\'"), true)] public static void Should(this FluentAssertions.Primitives.DateTimeOffsetRangeAssertions _) where TAssertions : FluentAssertions.Primitives.DateTimeOffsetAssertions { } - [System.Obsolete("You are asserting the \'AndConstraint\' itself. Remove the \'Should()\' method direct" + - "ly following \'And\'", true)] + [System.Obsolete(("You are asserting the \'AndConstraint\' itself. Remove the \'Should()\' method direct" + + "ly following \'And\'"), true)] public static void Should(this FluentAssertions.Primitives.DateTimeRangeAssertions _) where TAssertions : FluentAssertions.Primitives.DateTimeAssertions { } - [System.Obsolete("You are asserting the \'AndConstraint\' itself. Remove the \'Should()\' method direct" + - "ly following \'And\'", true)] + [System.Obsolete(("You are asserting the \'AndConstraint\' itself. Remove the \'Should()\' method direct" + + "ly following \'And\'"), true)] public static void Should(this FluentAssertions.Primitives.GuidAssertions _) where TAssertions : FluentAssertions.Primitives.GuidAssertions { } - [System.Obsolete("You are asserting the \'AndConstraint\' itself. Remove the \'Should()\' method direct" + - "ly following \'And\'", true)] + [System.Obsolete(("You are asserting the \'AndConstraint\' itself. Remove the \'Should()\' method direct" + + "ly following \'And\'"), true)] public static void Should(this FluentAssertions.Primitives.SimpleTimeSpanAssertions _) where TAssertions : FluentAssertions.Primitives.SimpleTimeSpanAssertions { } public static FluentAssertions.Collections.GenericCollectionAssertions Should(this System.Collections.Generic.IEnumerable actualValue) { } @@ -142,18 +142,18 @@ namespace FluentAssertions public static FluentAssertions.Specialized.FunctionAssertions Should(this System.Func func) { } public static FluentAssertions.Numeric.ComparableTypeAssertions Should(this System.IComparable comparableValue) { } public static FluentAssertions.Specialized.TaskCompletionSourceAssertions Should(this System.Threading.Tasks.TaskCompletionSource tcs) { } - [System.Obsolete("You are asserting the \'AndConstraint\' itself. Remove the \'Should()\' method direct" + - "ly following \'And\'", true)] + [System.Obsolete(("You are asserting the \'AndConstraint\' itself. Remove the \'Should()\' method direct" + + "ly following \'And\'"), true)] public static void Should(this FluentAssertions.Numeric.NumericAssertions _) where TSubject : struct, System.IComparable where TAssertions : FluentAssertions.Numeric.NumericAssertions { } - [System.Obsolete("You are asserting the \'AndConstraint\' itself. Remove the \'Should()\' method direct" + - "ly following \'And\'", true)] + [System.Obsolete(("You are asserting the \'AndConstraint\' itself. Remove the \'Should()\' method direct" + + "ly following \'And\'"), true)] public static void Should(this FluentAssertions.Primitives.EnumAssertions _) where TEnum : struct, System.Enum where TAssertions : FluentAssertions.Primitives.EnumAssertions { } - [System.Obsolete("You are asserting the \'AndConstraint\' itself. Remove the \'Should()\' method direct" + - "ly following \'And\'", true)] + [System.Obsolete(("You are asserting the \'AndConstraint\' itself. Remove the \'Should()\' method direct" + + "ly following \'And\'"), true)] public static void Should(this FluentAssertions.Primitives.ReferenceTypeAssertions _) where TAssertions : FluentAssertions.Primitives.ReferenceTypeAssertions { } public static FluentAssertions.Collections.GenericDictionaryAssertions, TKey, TValue> Should(this System.Collections.Generic.IDictionary actualValue) { } @@ -2268,11 +2268,11 @@ namespace FluentAssertions.Specialized where TTask : System.Threading.Tasks.Task where TAssertions : FluentAssertions.Specialized.AsyncFunctionAssertions { - [System.Obsolete("This class is intended as base class. This ctor is accidentally public and will b" + - "e removed in Version 7.")] + [System.Obsolete(("This class is intended as base class. This ctor is accidentally public and will b" + + "e removed in Version 7."))] public AsyncFunctionAssertions(System.Func subject, FluentAssertions.Specialized.IExtractExceptions extractor) { } - [System.Obsolete("This class is intended as base class. This ctor is accidentally public and will b" + - "e made protected in Version 7.")] + [System.Obsolete(("This class is intended as base class. This ctor is accidentally public and will b" + + "e made protected in Version 7."))] public AsyncFunctionAssertions(System.Func subject, FluentAssertions.Specialized.IExtractExceptions extractor, FluentAssertions.Common.IClock clock) { } protected override string Identifier { get; } public System.Threading.Tasks.Task> CompleteWithinAsync(System.TimeSpan timeSpan, string because = "", params object[] becauseArgs) { } diff --git a/Tests/Approval.Tests/ApprovedApi/FluentAssertions/net6.0.verified.txt b/Tests/Approval.Tests/ApprovedApi/FluentAssertions/net6.0.verified.txt index 5adccdf720..374a48da02 100644 --- a/Tests/Approval.Tests/ApprovedApi/FluentAssertions/net6.0.verified.txt +++ b/Tests/Approval.Tests/ApprovedApi/FluentAssertions/net6.0.verified.txt @@ -39,23 +39,23 @@ namespace FluentAssertions public static System.Func Invoking(this T subject, System.Func action) { } public static FluentAssertions.Events.IMonitor Monitor(this T eventSource, System.Func utcNow = null) { } public static FluentAssertions.Specialized.ExecutionTimeAssertions Should(this FluentAssertions.Specialized.ExecutionTime executionTime) { } - [System.Obsolete("You are asserting the \'AndConstraint\' itself. Remove the \'Should()\' method direct" + - "ly following \'And\'", true)] + [System.Obsolete(("You are asserting the \'AndConstraint\' itself. Remove the \'Should()\' method direct" + + "ly following \'And\'"), true)] public static void Should(this FluentAssertions.Specialized.ExecutionTimeAssertions _) { } - [System.Obsolete("You are asserting the \'AndConstraint\' itself. Remove the \'Should()\' method direct" + - "ly following \'And\'", true)] + [System.Obsolete(("You are asserting the \'AndConstraint\' itself. Remove the \'Should()\' method direct" + + "ly following \'And\'"), true)] public static void Should(this FluentAssertions.Specialized.TaskCompletionSourceAssertionsBase _) { } public static FluentAssertions.Types.MethodInfoSelectorAssertions Should(this FluentAssertions.Types.MethodInfoSelector methodSelector) { } - [System.Obsolete("You are asserting the \'AndConstraint\' itself. Remove the \'Should()\' method direct" + - "ly following \'And\'", true)] + [System.Obsolete(("You are asserting the \'AndConstraint\' itself. Remove the \'Should()\' method direct" + + "ly following \'And\'"), true)] public static void Should(this FluentAssertions.Types.MethodInfoSelectorAssertions _) { } public static FluentAssertions.Types.PropertyInfoSelectorAssertions Should(this FluentAssertions.Types.PropertyInfoSelector propertyInfoSelector) { } - [System.Obsolete("You are asserting the \'AndConstraint\' itself. Remove the \'Should()\' method direct" + - "ly following \'And\'", true)] + [System.Obsolete(("You are asserting the \'AndConstraint\' itself. Remove the \'Should()\' method direct" + + "ly following \'And\'"), true)] public static void Should(this FluentAssertions.Types.PropertyInfoSelectorAssertions _) { } public static FluentAssertions.Types.TypeSelectorAssertions Should(this FluentAssertions.Types.TypeSelector typeSelector) { } - [System.Obsolete("You are asserting the \'AndConstraint\' itself. Remove the \'Should()\' method direct" + - "ly following \'And\'", true)] + [System.Obsolete(("You are asserting the \'AndConstraint\' itself. Remove the \'Should()\' method direct" + + "ly following \'And\'"), true)] public static void Should(this FluentAssertions.Types.TypeSelectorAssertions _) { } public static FluentAssertions.Specialized.ActionAssertions Should(this System.Action action) { } public static FluentAssertions.Collections.StringCollectionAssertions Should(this System.Collections.Generic.IEnumerable @this) { } @@ -114,40 +114,40 @@ namespace FluentAssertions public static FluentAssertions.Numeric.NullableNumericAssertions Should(this ulong? actualValue) { } public static FluentAssertions.Numeric.NumericAssertions Should(this ushort actualValue) { } public static FluentAssertions.Numeric.NullableNumericAssertions Should(this ushort? actualValue) { } - [System.Obsolete("You are asserting the \'AndConstraint\' itself. Remove the \'Should()\' method direct" + - "ly following \'And\'", true)] + [System.Obsolete(("You are asserting the \'AndConstraint\' itself. Remove the \'Should()\' method direct" + + "ly following \'And\'"), true)] public static void Should(this FluentAssertions.Primitives.BooleanAssertions _) where TAssertions : FluentAssertions.Primitives.BooleanAssertions { } - [System.Obsolete("You are asserting the \'AndConstraint\' itself. Remove the \'Should()\' method direct" + - "ly following \'And\'", true)] + [System.Obsolete(("You are asserting the \'AndConstraint\' itself. Remove the \'Should()\' method direct" + + "ly following \'And\'"), true)] public static void Should(this FluentAssertions.Primitives.DateOnlyAssertions _) where TAssertions : FluentAssertions.Primitives.DateOnlyAssertions { } - [System.Obsolete("You are asserting the \'AndConstraint\' itself. Remove the \'Should()\' method direct" + - "ly following \'And\'", true)] + [System.Obsolete(("You are asserting the \'AndConstraint\' itself. Remove the \'Should()\' method direct" + + "ly following \'And\'"), true)] public static void Should(this FluentAssertions.Primitives.DateTimeAssertions _) where TAssertions : FluentAssertions.Primitives.DateTimeAssertions { } - [System.Obsolete("You are asserting the \'AndConstraint\' itself. Remove the \'Should()\' method direct" + - "ly following \'And\'", true)] + [System.Obsolete(("You are asserting the \'AndConstraint\' itself. Remove the \'Should()\' method direct" + + "ly following \'And\'"), true)] public static void Should(this FluentAssertions.Primitives.DateTimeOffsetAssertions _) where TAssertions : FluentAssertions.Primitives.DateTimeOffsetAssertions { } - [System.Obsolete("You are asserting the \'AndConstraint\' itself. Remove the \'Should()\' method direct" + - "ly following \'And\'", true)] + [System.Obsolete(("You are asserting the \'AndConstraint\' itself. Remove the \'Should()\' method direct" + + "ly following \'And\'"), true)] public static void Should(this FluentAssertions.Primitives.DateTimeOffsetRangeAssertions _) where TAssertions : FluentAssertions.Primitives.DateTimeOffsetAssertions { } - [System.Obsolete("You are asserting the \'AndConstraint\' itself. Remove the \'Should()\' method direct" + - "ly following \'And\'", true)] + [System.Obsolete(("You are asserting the \'AndConstraint\' itself. Remove the \'Should()\' method direct" + + "ly following \'And\'"), true)] public static void Should(this FluentAssertions.Primitives.DateTimeRangeAssertions _) where TAssertions : FluentAssertions.Primitives.DateTimeAssertions { } - [System.Obsolete("You are asserting the \'AndConstraint\' itself. Remove the \'Should()\' method direct" + - "ly following \'And\'", true)] + [System.Obsolete(("You are asserting the \'AndConstraint\' itself. Remove the \'Should()\' method direct" + + "ly following \'And\'"), true)] public static void Should(this FluentAssertions.Primitives.GuidAssertions _) where TAssertions : FluentAssertions.Primitives.GuidAssertions { } - [System.Obsolete("You are asserting the \'AndConstraint\' itself. Remove the \'Should()\' method direct" + - "ly following \'And\'", true)] + [System.Obsolete(("You are asserting the \'AndConstraint\' itself. Remove the \'Should()\' method direct" + + "ly following \'And\'"), true)] public static void Should(this FluentAssertions.Primitives.SimpleTimeSpanAssertions _) where TAssertions : FluentAssertions.Primitives.SimpleTimeSpanAssertions { } - [System.Obsolete("You are asserting the \'AndConstraint\' itself. Remove the \'Should()\' method direct" + - "ly following \'And\'", true)] + [System.Obsolete(("You are asserting the \'AndConstraint\' itself. Remove the \'Should()\' method direct" + + "ly following \'And\'"), true)] public static void Should(this FluentAssertions.Primitives.TimeOnlyAssertions _) where TAssertions : FluentAssertions.Primitives.TimeOnlyAssertions { } public static FluentAssertions.Collections.GenericCollectionAssertions Should(this System.Collections.Generic.IEnumerable actualValue) { } @@ -155,18 +155,18 @@ namespace FluentAssertions public static FluentAssertions.Specialized.FunctionAssertions Should(this System.Func func) { } public static FluentAssertions.Numeric.ComparableTypeAssertions Should(this System.IComparable comparableValue) { } public static FluentAssertions.Specialized.TaskCompletionSourceAssertions Should(this System.Threading.Tasks.TaskCompletionSource tcs) { } - [System.Obsolete("You are asserting the \'AndConstraint\' itself. Remove the \'Should()\' method direct" + - "ly following \'And\'", true)] + [System.Obsolete(("You are asserting the \'AndConstraint\' itself. Remove the \'Should()\' method direct" + + "ly following \'And\'"), true)] public static void Should(this FluentAssertions.Numeric.NumericAssertions _) where TSubject : struct, System.IComparable where TAssertions : FluentAssertions.Numeric.NumericAssertions { } - [System.Obsolete("You are asserting the \'AndConstraint\' itself. Remove the \'Should()\' method direct" + - "ly following \'And\'", true)] + [System.Obsolete(("You are asserting the \'AndConstraint\' itself. Remove the \'Should()\' method direct" + + "ly following \'And\'"), true)] public static void Should(this FluentAssertions.Primitives.EnumAssertions _) where TEnum : struct, System.Enum where TAssertions : FluentAssertions.Primitives.EnumAssertions { } - [System.Obsolete("You are asserting the \'AndConstraint\' itself. Remove the \'Should()\' method direct" + - "ly following \'And\'", true)] + [System.Obsolete(("You are asserting the \'AndConstraint\' itself. Remove the \'Should()\' method direct" + + "ly following \'And\'"), true)] public static void Should(this FluentAssertions.Primitives.ReferenceTypeAssertions _) where TAssertions : FluentAssertions.Primitives.ReferenceTypeAssertions { } public static FluentAssertions.Collections.GenericDictionaryAssertions, TKey, TValue> Should(this System.Collections.Generic.IDictionary actualValue) { } @@ -2389,11 +2389,11 @@ namespace FluentAssertions.Specialized where TTask : System.Threading.Tasks.Task where TAssertions : FluentAssertions.Specialized.AsyncFunctionAssertions { - [System.Obsolete("This class is intended as base class. This ctor is accidentally public and will b" + - "e removed in Version 7.")] + [System.Obsolete(("This class is intended as base class. This ctor is accidentally public and will b" + + "e removed in Version 7."))] public AsyncFunctionAssertions(System.Func subject, FluentAssertions.Specialized.IExtractExceptions extractor) { } - [System.Obsolete("This class is intended as base class. This ctor is accidentally public and will b" + - "e made protected in Version 7.")] + [System.Obsolete(("This class is intended as base class. This ctor is accidentally public and will b" + + "e made protected in Version 7."))] public AsyncFunctionAssertions(System.Func subject, FluentAssertions.Specialized.IExtractExceptions extractor, FluentAssertions.Common.IClock clock) { } protected override string Identifier { get; } public System.Threading.Tasks.Task> CompleteWithinAsync(System.TimeSpan timeSpan, string because = "", params object[] becauseArgs) { } diff --git a/Tests/Approval.Tests/ApprovedApi/FluentAssertions/netstandard2.0.verified.txt b/Tests/Approval.Tests/ApprovedApi/FluentAssertions/netstandard2.0.verified.txt index 7995d53641..b0bf642d36 100644 --- a/Tests/Approval.Tests/ApprovedApi/FluentAssertions/netstandard2.0.verified.txt +++ b/Tests/Approval.Tests/ApprovedApi/FluentAssertions/netstandard2.0.verified.txt @@ -38,23 +38,23 @@ namespace FluentAssertions public static System.Action Invoking(this T subject, System.Action action) { } public static System.Func Invoking(this T subject, System.Func action) { } public static FluentAssertions.Specialized.ExecutionTimeAssertions Should(this FluentAssertions.Specialized.ExecutionTime executionTime) { } - [System.Obsolete("You are asserting the \'AndConstraint\' itself. Remove the \'Should()\' method direct" + - "ly following \'And\'", true)] + [System.Obsolete(("You are asserting the \'AndConstraint\' itself. Remove the \'Should()\' method direct" + + "ly following \'And\'"), true)] public static void Should(this FluentAssertions.Specialized.ExecutionTimeAssertions _) { } - [System.Obsolete("You are asserting the \'AndConstraint\' itself. Remove the \'Should()\' method direct" + - "ly following \'And\'", true)] + [System.Obsolete(("You are asserting the \'AndConstraint\' itself. Remove the \'Should()\' method direct" + + "ly following \'And\'"), true)] public static void Should(this FluentAssertions.Specialized.TaskCompletionSourceAssertionsBase _) { } public static FluentAssertions.Types.MethodInfoSelectorAssertions Should(this FluentAssertions.Types.MethodInfoSelector methodSelector) { } - [System.Obsolete("You are asserting the \'AndConstraint\' itself. Remove the \'Should()\' method direct" + - "ly following \'And\'", true)] + [System.Obsolete(("You are asserting the \'AndConstraint\' itself. Remove the \'Should()\' method direct" + + "ly following \'And\'"), true)] public static void Should(this FluentAssertions.Types.MethodInfoSelectorAssertions _) { } public static FluentAssertions.Types.PropertyInfoSelectorAssertions Should(this FluentAssertions.Types.PropertyInfoSelector propertyInfoSelector) { } - [System.Obsolete("You are asserting the \'AndConstraint\' itself. Remove the \'Should()\' method direct" + - "ly following \'And\'", true)] + [System.Obsolete(("You are asserting the \'AndConstraint\' itself. Remove the \'Should()\' method direct" + + "ly following \'And\'"), true)] public static void Should(this FluentAssertions.Types.PropertyInfoSelectorAssertions _) { } public static FluentAssertions.Types.TypeSelectorAssertions Should(this FluentAssertions.Types.TypeSelector typeSelector) { } - [System.Obsolete("You are asserting the \'AndConstraint\' itself. Remove the \'Should()\' method direct" + - "ly following \'And\'", true)] + [System.Obsolete(("You are asserting the \'AndConstraint\' itself. Remove the \'Should()\' method direct" + + "ly following \'And\'"), true)] public static void Should(this FluentAssertions.Types.TypeSelectorAssertions _) { } public static FluentAssertions.Specialized.ActionAssertions Should(this System.Action action) { } public static FluentAssertions.Collections.StringCollectionAssertions Should(this System.Collections.Generic.IEnumerable @this) { } @@ -108,32 +108,32 @@ namespace FluentAssertions public static FluentAssertions.Numeric.NullableNumericAssertions Should(this ulong? actualValue) { } public static FluentAssertions.Numeric.NumericAssertions Should(this ushort actualValue) { } public static FluentAssertions.Numeric.NullableNumericAssertions Should(this ushort? actualValue) { } - [System.Obsolete("You are asserting the \'AndConstraint\' itself. Remove the \'Should()\' method direct" + - "ly following \'And\'", true)] + [System.Obsolete(("You are asserting the \'AndConstraint\' itself. Remove the \'Should()\' method direct" + + "ly following \'And\'"), true)] public static void Should(this FluentAssertions.Primitives.BooleanAssertions _) where TAssertions : FluentAssertions.Primitives.BooleanAssertions { } - [System.Obsolete("You are asserting the \'AndConstraint\' itself. Remove the \'Should()\' method direct" + - "ly following \'And\'", true)] + [System.Obsolete(("You are asserting the \'AndConstraint\' itself. Remove the \'Should()\' method direct" + + "ly following \'And\'"), true)] public static void Should(this FluentAssertions.Primitives.DateTimeAssertions _) where TAssertions : FluentAssertions.Primitives.DateTimeAssertions { } - [System.Obsolete("You are asserting the \'AndConstraint\' itself. Remove the \'Should()\' method direct" + - "ly following \'And\'", true)] + [System.Obsolete(("You are asserting the \'AndConstraint\' itself. Remove the \'Should()\' method direct" + + "ly following \'And\'"), true)] public static void Should(this FluentAssertions.Primitives.DateTimeOffsetAssertions _) where TAssertions : FluentAssertions.Primitives.DateTimeOffsetAssertions { } - [System.Obsolete("You are asserting the \'AndConstraint\' itself. Remove the \'Should()\' method direct" + - "ly following \'And\'", true)] + [System.Obsolete(("You are asserting the \'AndConstraint\' itself. Remove the \'Should()\' method direct" + + "ly following \'And\'"), true)] public static void Should(this FluentAssertions.Primitives.DateTimeOffsetRangeAssertions _) where TAssertions : FluentAssertions.Primitives.DateTimeOffsetAssertions { } - [System.Obsolete("You are asserting the \'AndConstraint\' itself. Remove the \'Should()\' method direct" + - "ly following \'And\'", true)] + [System.Obsolete(("You are asserting the \'AndConstraint\' itself. Remove the \'Should()\' method direct" + + "ly following \'And\'"), true)] public static void Should(this FluentAssertions.Primitives.DateTimeRangeAssertions _) where TAssertions : FluentAssertions.Primitives.DateTimeAssertions { } - [System.Obsolete("You are asserting the \'AndConstraint\' itself. Remove the \'Should()\' method direct" + - "ly following \'And\'", true)] + [System.Obsolete(("You are asserting the \'AndConstraint\' itself. Remove the \'Should()\' method direct" + + "ly following \'And\'"), true)] public static void Should(this FluentAssertions.Primitives.GuidAssertions _) where TAssertions : FluentAssertions.Primitives.GuidAssertions { } - [System.Obsolete("You are asserting the \'AndConstraint\' itself. Remove the \'Should()\' method direct" + - "ly following \'And\'", true)] + [System.Obsolete(("You are asserting the \'AndConstraint\' itself. Remove the \'Should()\' method direct" + + "ly following \'And\'"), true)] public static void Should(this FluentAssertions.Primitives.SimpleTimeSpanAssertions _) where TAssertions : FluentAssertions.Primitives.SimpleTimeSpanAssertions { } public static FluentAssertions.Collections.GenericCollectionAssertions Should(this System.Collections.Generic.IEnumerable actualValue) { } @@ -141,18 +141,18 @@ namespace FluentAssertions public static FluentAssertions.Specialized.FunctionAssertions Should(this System.Func func) { } public static FluentAssertions.Numeric.ComparableTypeAssertions Should(this System.IComparable comparableValue) { } public static FluentAssertions.Specialized.TaskCompletionSourceAssertions Should(this System.Threading.Tasks.TaskCompletionSource tcs) { } - [System.Obsolete("You are asserting the \'AndConstraint\' itself. Remove the \'Should()\' method direct" + - "ly following \'And\'", true)] + [System.Obsolete(("You are asserting the \'AndConstraint\' itself. Remove the \'Should()\' method direct" + + "ly following \'And\'"), true)] public static void Should(this FluentAssertions.Numeric.NumericAssertions _) where TSubject : struct, System.IComparable where TAssertions : FluentAssertions.Numeric.NumericAssertions { } - [System.Obsolete("You are asserting the \'AndConstraint\' itself. Remove the \'Should()\' method direct" + - "ly following \'And\'", true)] + [System.Obsolete(("You are asserting the \'AndConstraint\' itself. Remove the \'Should()\' method direct" + + "ly following \'And\'"), true)] public static void Should(this FluentAssertions.Primitives.EnumAssertions _) where TEnum : struct, System.Enum where TAssertions : FluentAssertions.Primitives.EnumAssertions { } - [System.Obsolete("You are asserting the \'AndConstraint\' itself. Remove the \'Should()\' method direct" + - "ly following \'And\'", true)] + [System.Obsolete(("You are asserting the \'AndConstraint\' itself. Remove the \'Should()\' method direct" + + "ly following \'And\'"), true)] public static void Should(this FluentAssertions.Primitives.ReferenceTypeAssertions _) where TAssertions : FluentAssertions.Primitives.ReferenceTypeAssertions { } public static FluentAssertions.Collections.GenericDictionaryAssertions, TKey, TValue> Should(this System.Collections.Generic.IDictionary actualValue) { } @@ -2219,11 +2219,11 @@ namespace FluentAssertions.Specialized where TTask : System.Threading.Tasks.Task where TAssertions : FluentAssertions.Specialized.AsyncFunctionAssertions { - [System.Obsolete("This class is intended as base class. This ctor is accidentally public and will b" + - "e removed in Version 7.")] + [System.Obsolete(("This class is intended as base class. This ctor is accidentally public and will b" + + "e removed in Version 7."))] public AsyncFunctionAssertions(System.Func subject, FluentAssertions.Specialized.IExtractExceptions extractor) { } - [System.Obsolete("This class is intended as base class. This ctor is accidentally public and will b" + - "e made protected in Version 7.")] + [System.Obsolete(("This class is intended as base class. This ctor is accidentally public and will b" + + "e made protected in Version 7."))] public AsyncFunctionAssertions(System.Func subject, FluentAssertions.Specialized.IExtractExceptions extractor, FluentAssertions.Common.IClock clock) { } protected override string Identifier { get; } public System.Threading.Tasks.Task> CompleteWithinAsync(System.TimeSpan timeSpan, string because = "", params object[] becauseArgs) { } diff --git a/Tests/Approval.Tests/ApprovedApi/FluentAssertions/netstandard2.1.verified.txt b/Tests/Approval.Tests/ApprovedApi/FluentAssertions/netstandard2.1.verified.txt index 3df6aee5fb..e79d8fcb72 100644 --- a/Tests/Approval.Tests/ApprovedApi/FluentAssertions/netstandard2.1.verified.txt +++ b/Tests/Approval.Tests/ApprovedApi/FluentAssertions/netstandard2.1.verified.txt @@ -39,23 +39,23 @@ namespace FluentAssertions public static System.Func Invoking(this T subject, System.Func action) { } public static FluentAssertions.Events.IMonitor Monitor(this T eventSource, System.Func utcNow = null) { } public static FluentAssertions.Specialized.ExecutionTimeAssertions Should(this FluentAssertions.Specialized.ExecutionTime executionTime) { } - [System.Obsolete("You are asserting the \'AndConstraint\' itself. Remove the \'Should()\' method direct" + - "ly following \'And\'", true)] + [System.Obsolete(("You are asserting the \'AndConstraint\' itself. Remove the \'Should()\' method direct" + + "ly following \'And\'"), true)] public static void Should(this FluentAssertions.Specialized.ExecutionTimeAssertions _) { } - [System.Obsolete("You are asserting the \'AndConstraint\' itself. Remove the \'Should()\' method direct" + - "ly following \'And\'", true)] + [System.Obsolete(("You are asserting the \'AndConstraint\' itself. Remove the \'Should()\' method direct" + + "ly following \'And\'"), true)] public static void Should(this FluentAssertions.Specialized.TaskCompletionSourceAssertionsBase _) { } public static FluentAssertions.Types.MethodInfoSelectorAssertions Should(this FluentAssertions.Types.MethodInfoSelector methodSelector) { } - [System.Obsolete("You are asserting the \'AndConstraint\' itself. Remove the \'Should()\' method direct" + - "ly following \'And\'", true)] + [System.Obsolete(("You are asserting the \'AndConstraint\' itself. Remove the \'Should()\' method direct" + + "ly following \'And\'"), true)] public static void Should(this FluentAssertions.Types.MethodInfoSelectorAssertions _) { } public static FluentAssertions.Types.PropertyInfoSelectorAssertions Should(this FluentAssertions.Types.PropertyInfoSelector propertyInfoSelector) { } - [System.Obsolete("You are asserting the \'AndConstraint\' itself. Remove the \'Should()\' method direct" + - "ly following \'And\'", true)] + [System.Obsolete(("You are asserting the \'AndConstraint\' itself. Remove the \'Should()\' method direct" + + "ly following \'And\'"), true)] public static void Should(this FluentAssertions.Types.PropertyInfoSelectorAssertions _) { } public static FluentAssertions.Types.TypeSelectorAssertions Should(this FluentAssertions.Types.TypeSelector typeSelector) { } - [System.Obsolete("You are asserting the \'AndConstraint\' itself. Remove the \'Should()\' method direct" + - "ly following \'And\'", true)] + [System.Obsolete(("You are asserting the \'AndConstraint\' itself. Remove the \'Should()\' method direct" + + "ly following \'And\'"), true)] public static void Should(this FluentAssertions.Types.TypeSelectorAssertions _) { } public static FluentAssertions.Specialized.ActionAssertions Should(this System.Action action) { } public static FluentAssertions.Collections.StringCollectionAssertions Should(this System.Collections.Generic.IEnumerable @this) { } @@ -109,32 +109,32 @@ namespace FluentAssertions public static FluentAssertions.Numeric.NullableNumericAssertions Should(this ulong? actualValue) { } public static FluentAssertions.Numeric.NumericAssertions Should(this ushort actualValue) { } public static FluentAssertions.Numeric.NullableNumericAssertions Should(this ushort? actualValue) { } - [System.Obsolete("You are asserting the \'AndConstraint\' itself. Remove the \'Should()\' method direct" + - "ly following \'And\'", true)] + [System.Obsolete(("You are asserting the \'AndConstraint\' itself. Remove the \'Should()\' method direct" + + "ly following \'And\'"), true)] public static void Should(this FluentAssertions.Primitives.BooleanAssertions _) where TAssertions : FluentAssertions.Primitives.BooleanAssertions { } - [System.Obsolete("You are asserting the \'AndConstraint\' itself. Remove the \'Should()\' method direct" + - "ly following \'And\'", true)] + [System.Obsolete(("You are asserting the \'AndConstraint\' itself. Remove the \'Should()\' method direct" + + "ly following \'And\'"), true)] public static void Should(this FluentAssertions.Primitives.DateTimeAssertions _) where TAssertions : FluentAssertions.Primitives.DateTimeAssertions { } - [System.Obsolete("You are asserting the \'AndConstraint\' itself. Remove the \'Should()\' method direct" + - "ly following \'And\'", true)] + [System.Obsolete(("You are asserting the \'AndConstraint\' itself. Remove the \'Should()\' method direct" + + "ly following \'And\'"), true)] public static void Should(this FluentAssertions.Primitives.DateTimeOffsetAssertions _) where TAssertions : FluentAssertions.Primitives.DateTimeOffsetAssertions { } - [System.Obsolete("You are asserting the \'AndConstraint\' itself. Remove the \'Should()\' method direct" + - "ly following \'And\'", true)] + [System.Obsolete(("You are asserting the \'AndConstraint\' itself. Remove the \'Should()\' method direct" + + "ly following \'And\'"), true)] public static void Should(this FluentAssertions.Primitives.DateTimeOffsetRangeAssertions _) where TAssertions : FluentAssertions.Primitives.DateTimeOffsetAssertions { } - [System.Obsolete("You are asserting the \'AndConstraint\' itself. Remove the \'Should()\' method direct" + - "ly following \'And\'", true)] + [System.Obsolete(("You are asserting the \'AndConstraint\' itself. Remove the \'Should()\' method direct" + + "ly following \'And\'"), true)] public static void Should(this FluentAssertions.Primitives.DateTimeRangeAssertions _) where TAssertions : FluentAssertions.Primitives.DateTimeAssertions { } - [System.Obsolete("You are asserting the \'AndConstraint\' itself. Remove the \'Should()\' method direct" + - "ly following \'And\'", true)] + [System.Obsolete(("You are asserting the \'AndConstraint\' itself. Remove the \'Should()\' method direct" + + "ly following \'And\'"), true)] public static void Should(this FluentAssertions.Primitives.GuidAssertions _) where TAssertions : FluentAssertions.Primitives.GuidAssertions { } - [System.Obsolete("You are asserting the \'AndConstraint\' itself. Remove the \'Should()\' method direct" + - "ly following \'And\'", true)] + [System.Obsolete(("You are asserting the \'AndConstraint\' itself. Remove the \'Should()\' method direct" + + "ly following \'And\'"), true)] public static void Should(this FluentAssertions.Primitives.SimpleTimeSpanAssertions _) where TAssertions : FluentAssertions.Primitives.SimpleTimeSpanAssertions { } public static FluentAssertions.Collections.GenericCollectionAssertions Should(this System.Collections.Generic.IEnumerable actualValue) { } @@ -142,18 +142,18 @@ namespace FluentAssertions public static FluentAssertions.Specialized.FunctionAssertions Should(this System.Func func) { } public static FluentAssertions.Numeric.ComparableTypeAssertions Should(this System.IComparable comparableValue) { } public static FluentAssertions.Specialized.TaskCompletionSourceAssertions Should(this System.Threading.Tasks.TaskCompletionSource tcs) { } - [System.Obsolete("You are asserting the \'AndConstraint\' itself. Remove the \'Should()\' method direct" + - "ly following \'And\'", true)] + [System.Obsolete(("You are asserting the \'AndConstraint\' itself. Remove the \'Should()\' method direct" + + "ly following \'And\'"), true)] public static void Should(this FluentAssertions.Numeric.NumericAssertions _) where TSubject : struct, System.IComparable where TAssertions : FluentAssertions.Numeric.NumericAssertions { } - [System.Obsolete("You are asserting the \'AndConstraint\' itself. Remove the \'Should()\' method direct" + - "ly following \'And\'", true)] + [System.Obsolete(("You are asserting the \'AndConstraint\' itself. Remove the \'Should()\' method direct" + + "ly following \'And\'"), true)] public static void Should(this FluentAssertions.Primitives.EnumAssertions _) where TEnum : struct, System.Enum where TAssertions : FluentAssertions.Primitives.EnumAssertions { } - [System.Obsolete("You are asserting the \'AndConstraint\' itself. Remove the \'Should()\' method direct" + - "ly following \'And\'", true)] + [System.Obsolete(("You are asserting the \'AndConstraint\' itself. Remove the \'Should()\' method direct" + + "ly following \'And\'"), true)] public static void Should(this FluentAssertions.Primitives.ReferenceTypeAssertions _) where TAssertions : FluentAssertions.Primitives.ReferenceTypeAssertions { } public static FluentAssertions.Collections.GenericDictionaryAssertions, TKey, TValue> Should(this System.Collections.Generic.IDictionary actualValue) { } @@ -2268,11 +2268,11 @@ namespace FluentAssertions.Specialized where TTask : System.Threading.Tasks.Task where TAssertions : FluentAssertions.Specialized.AsyncFunctionAssertions { - [System.Obsolete("This class is intended as base class. This ctor is accidentally public and will b" + - "e removed in Version 7.")] + [System.Obsolete(("This class is intended as base class. This ctor is accidentally public and will b" + + "e removed in Version 7."))] public AsyncFunctionAssertions(System.Func subject, FluentAssertions.Specialized.IExtractExceptions extractor) { } - [System.Obsolete("This class is intended as base class. This ctor is accidentally public and will b" + - "e made protected in Version 7.")] + [System.Obsolete(("This class is intended as base class. This ctor is accidentally public and will b" + + "e made protected in Version 7."))] public AsyncFunctionAssertions(System.Func subject, FluentAssertions.Specialized.IExtractExceptions extractor, FluentAssertions.Common.IClock clock) { } protected override string Identifier { get; } public System.Threading.Tasks.Task> CompleteWithinAsync(System.TimeSpan timeSpan, string because = "", params object[] becauseArgs) { } diff --git a/Tests/FSharp.Specs/FSharp.Specs.fsproj b/Tests/FSharp.Specs/FSharp.Specs.fsproj index dbd0ceceeb..d1bb7629f6 100644 --- a/Tests/FSharp.Specs/FSharp.Specs.fsproj +++ b/Tests/FSharp.Specs/FSharp.Specs.fsproj @@ -11,7 +11,7 @@ - + runtime; build; native; contentfiles; analyzers; buildtransitive all @@ -20,6 +20,7 @@ runtime; build; native; contentfiles; analyzers; buildtransitive all + diff --git a/Tests/FluentAssertions.Equivalency.Specs/FluentAssertions.Equivalency.Specs.csproj b/Tests/FluentAssertions.Equivalency.Specs/FluentAssertions.Equivalency.Specs.csproj index c48906bb6a..c85b3e8680 100644 --- a/Tests/FluentAssertions.Equivalency.Specs/FluentAssertions.Equivalency.Specs.csproj +++ b/Tests/FluentAssertions.Equivalency.Specs/FluentAssertions.Equivalency.Specs.csproj @@ -45,7 +45,7 @@ - + diff --git a/Tests/FluentAssertions.Specs/FluentAssertions.Specs.csproj b/Tests/FluentAssertions.Specs/FluentAssertions.Specs.csproj index 356262741d..1dd55e0b5c 100644 --- a/Tests/FluentAssertions.Specs/FluentAssertions.Specs.csproj +++ b/Tests/FluentAssertions.Specs/FluentAssertions.Specs.csproj @@ -44,7 +44,7 @@ - + diff --git a/Tests/TestFrameworks/MSTestV2.Specs/MSTestV2.Specs.csproj b/Tests/TestFrameworks/MSTestV2.Specs/MSTestV2.Specs.csproj index 17c7e7c127..fc8f8a44ca 100644 --- a/Tests/TestFrameworks/MSTestV2.Specs/MSTestV2.Specs.csproj +++ b/Tests/TestFrameworks/MSTestV2.Specs/MSTestV2.Specs.csproj @@ -12,7 +12,7 @@ runtime; build; native; contentfiles; analyzers; buildtransitive - - + + \ No newline at end of file diff --git a/Tests/TestFrameworks/XUnit2.Specs/XUnit2.Specs.csproj b/Tests/TestFrameworks/XUnit2.Specs/XUnit2.Specs.csproj index b49c02527f..493780eb74 100644 --- a/Tests/TestFrameworks/XUnit2.Specs/XUnit2.Specs.csproj +++ b/Tests/TestFrameworks/XUnit2.Specs/XUnit2.Specs.csproj @@ -12,7 +12,7 @@ runtime; build; native; contentfiles; analyzers; buildtransitive - + all runtime; build; native; contentfiles; analyzers diff --git a/Tests/UWP.Specs/UWP.Specs.csproj b/Tests/UWP.Specs/UWP.Specs.csproj index 9f73358eae..ec5f728aae 100644 --- a/Tests/UWP.Specs/UWP.Specs.csproj +++ b/Tests/UWP.Specs/UWP.Specs.csproj @@ -92,7 +92,7 @@ 2.2.10 - 4.3.0 + 4.7.0 diff --git a/Tests/VB.Specs/VB.Specs.vbproj b/Tests/VB.Specs/VB.Specs.vbproj index bdc93f368c..cde46a13b7 100644 --- a/Tests/VB.Specs/VB.Specs.vbproj +++ b/Tests/VB.Specs/VB.Specs.vbproj @@ -7,12 +7,12 @@ - + runtime; build; native; contentfiles; analyzers; buildtransitive all - + runtime; build; native; contentfiles; analyzers; buildtransitive all diff --git a/global.json b/global.json index 87f1d59214..96ca5e04e9 100644 --- a/global.json +++ b/global.json @@ -1,6 +1,6 @@ { "sdk": { - "version": "7.0.101", + "version": "8.0.404", "rollForward": "latestMajor" } } From 0273ed70262fe8e3b24a5a4c636021e77601938e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Luthi?= Date: Sat, 23 Nov 2024 14:50:47 +0100 Subject: [PATCH 2/3] Add support for xUnit.net v3 (#2718) (cherry picked from commit 3e00296d7e62bd81418b2954a128a101f7da1018) --- Build/Build.cs | 4 +- FluentAssertions.sln | 18 +++++++ .../Execution/AssertionFailedException.cs | 14 +----- .../Execution/IAssertionException.cs | 7 +++ .../Execution/LateBoundTestFramework.cs | 50 +++++++++++++------ .../Execution/TestFrameworkProvider.cs | 5 +- .../Execution/XUnit2TestFramework.cs | 40 --------------- .../Execution/XUnitTestFramework.cs | 11 ++++ Src/FluentAssertions/FluentAssertions.csproj | 2 +- .../FluentAssertions/net47.verified.txt | 2 - .../FluentAssertions/net6.0.verified.txt | 2 - .../netstandard2.0.verified.txt | 2 - .../netstandard2.1.verified.txt | 2 - .../MSTestV2.Specs/FrameworkSpecs.cs | 7 +-- .../MSpec.Specs/FrameworkSpecs.cs | 7 ++- .../NUnit3.Specs/FrameworkSpecs.cs | 7 +-- .../XUnit2.Specs/FrameworkSpecs.cs | 5 +- .../XUnit3.Specs/FrameworkSpecs.cs | 24 +++++++++ .../XUnit3.Specs/XUnit3.Specs.csproj | 18 +++++++ .../XUnit3Core.Specs/FrameworkSpecs.cs | 20 ++++++++ .../XUnit3Core.Specs/XUnit3Core.Specs.csproj | 18 +++++++ docs/_pages/introduction.md | 4 +- docs/_pages/releases.md | 6 +++ docs/index.html | 2 +- 24 files changed, 186 insertions(+), 91 deletions(-) create mode 100644 Src/FluentAssertions/Execution/IAssertionException.cs delete mode 100644 Src/FluentAssertions/Execution/XUnit2TestFramework.cs create mode 100644 Src/FluentAssertions/Execution/XUnitTestFramework.cs create mode 100644 Tests/TestFrameworks/XUnit3.Specs/FrameworkSpecs.cs create mode 100644 Tests/TestFrameworks/XUnit3.Specs/XUnit3.Specs.csproj create mode 100644 Tests/TestFrameworks/XUnit3Core.Specs/FrameworkSpecs.cs create mode 100644 Tests/TestFrameworks/XUnit3Core.Specs/XUnit3Core.Specs.csproj diff --git a/Build/Build.cs b/Build/Build.cs index 6f9881e68c..c3aebb1654 100644 --- a/Build/Build.cs +++ b/Build/Build.cs @@ -271,7 +271,9 @@ void ReportTestOutcome(params string[] globFilters) Solution.TestFrameworks.MSpec_Specs, Solution.TestFrameworks.MSTestV2_Specs, Solution.TestFrameworks.NUnit3_Specs, - Solution.TestFrameworks.XUnit2_Specs + Solution.TestFrameworks.XUnit2_Specs, + Solution.TestFrameworks.XUnit3_Specs, + Solution.TestFrameworks.XUnit3Core_Specs, }; var testCombinations = diff --git a/FluentAssertions.sln b/FluentAssertions.sln index 31ee369de2..a3b1d492de 100644 --- a/FluentAssertions.sln +++ b/FluentAssertions.sln @@ -51,6 +51,10 @@ Project("{778DAE3C-4631-46EA-AA77-85C1314464D9}") = "VB.Specs", "Tests\VB.Specs\ EndProject Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "FSharp.Specs", "Tests\FSharp.Specs\FSharp.Specs.fsproj", "{0A69DC62-CA14-44E5-BAF9-2EB2E2E2CADF}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "XUnit3.Specs", "Tests\TestFrameworks\XUnit3.Specs\XUnit3.Specs.csproj", "{60335A74-208E-4B33-BA4F-70A36541705E}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "XUnit3Core.Specs", "Tests\TestFrameworks\XUnit3Core.Specs\XUnit3Core.Specs.csproj", "{FCD60E63-F1DC-4DF0-AB75-69CCB6931FF7}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution CI|Any CPU = CI|Any CPU @@ -141,6 +145,18 @@ Global {0A69DC62-CA14-44E5-BAF9-2EB2E2E2CADF}.Debug|Any CPU.Build.0 = Debug|Any CPU {0A69DC62-CA14-44E5-BAF9-2EB2E2E2CADF}.Release|Any CPU.ActiveCfg = Release|Any CPU {0A69DC62-CA14-44E5-BAF9-2EB2E2E2CADF}.Release|Any CPU.Build.0 = Release|Any CPU + {60335A74-208E-4B33-BA4F-70A36541705E}.CI|Any CPU.ActiveCfg = Debug|Any CPU + {60335A74-208E-4B33-BA4F-70A36541705E}.CI|Any CPU.Build.0 = Debug|Any CPU + {60335A74-208E-4B33-BA4F-70A36541705E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {60335A74-208E-4B33-BA4F-70A36541705E}.Debug|Any CPU.Build.0 = Debug|Any CPU + {60335A74-208E-4B33-BA4F-70A36541705E}.Release|Any CPU.ActiveCfg = Release|Any CPU + {60335A74-208E-4B33-BA4F-70A36541705E}.Release|Any CPU.Build.0 = Release|Any CPU + {FCD60E63-F1DC-4DF0-AB75-69CCB6931FF7}.CI|Any CPU.ActiveCfg = Debug|Any CPU + {FCD60E63-F1DC-4DF0-AB75-69CCB6931FF7}.CI|Any CPU.Build.0 = Debug|Any CPU + {FCD60E63-F1DC-4DF0-AB75-69CCB6931FF7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {FCD60E63-F1DC-4DF0-AB75-69CCB6931FF7}.Debug|Any CPU.Build.0 = Debug|Any CPU + {FCD60E63-F1DC-4DF0-AB75-69CCB6931FF7}.Release|Any CPU.ActiveCfg = Release|Any CPU + {FCD60E63-F1DC-4DF0-AB75-69CCB6931FF7}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -160,6 +176,8 @@ Global {A946043D-D3F8-46A4-B485-A88412C417FE} = {963262D0-9FD5-4741-8C0E-E2F34F110EF3} {0C0211B6-D185-4518-A15A-38AC092EDC50} = {963262D0-9FD5-4741-8C0E-E2F34F110EF3} {0A69DC62-CA14-44E5-BAF9-2EB2E2E2CADF} = {963262D0-9FD5-4741-8C0E-E2F34F110EF3} + {60335A74-208E-4B33-BA4F-70A36541705E} = {4D8FA213-8724-4C43-B68A-F018148D238C} + {FCD60E63-F1DC-4DF0-AB75-69CCB6931FF7} = {4D8FA213-8724-4C43-B68A-F018148D238C} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {75DDA3D8-9D6F-4865-93F4-DDE11DEE8290} diff --git a/Src/FluentAssertions/Execution/AssertionFailedException.cs b/Src/FluentAssertions/Execution/AssertionFailedException.cs index 391b67227c..d21f2f6ab8 100644 --- a/Src/FluentAssertions/Execution/AssertionFailedException.cs +++ b/Src/FluentAssertions/Execution/AssertionFailedException.cs @@ -1,23 +1,13 @@ using System; -using System.Runtime.Serialization; namespace FluentAssertions.Execution; /// /// Represents the default exception in case no test framework is configured. /// -[Serializable] +/// The mandatory exception message #pragma warning disable CA1032, RCS1194 // AssertionFailedException should never be constructed with an empty message -public class AssertionFailedException : Exception +public class AssertionFailedException(string message) : Exception(message), IAssertionException #pragma warning restore CA1032, RCS1194 { - public AssertionFailedException(string message) - : base(message) - { - } - - protected AssertionFailedException(SerializationInfo info, StreamingContext context) - : base(info, context) - { - } } diff --git a/Src/FluentAssertions/Execution/IAssertionException.cs b/Src/FluentAssertions/Execution/IAssertionException.cs new file mode 100644 index 0000000000..8c8c519d46 --- /dev/null +++ b/Src/FluentAssertions/Execution/IAssertionException.cs @@ -0,0 +1,7 @@ +namespace FluentAssertions.Execution; + +/// +/// This is a marker interface for xUnit.net v3 to set the test failure cause as an assertion failure. +/// See What’s New in xUnit.net v3 - Third party assertion library extension points. +/// +internal interface IAssertionException; diff --git a/Src/FluentAssertions/Execution/LateBoundTestFramework.cs b/Src/FluentAssertions/Execution/LateBoundTestFramework.cs index 087f4043e5..5c7cbbe423 100644 --- a/Src/FluentAssertions/Execution/LateBoundTestFramework.cs +++ b/Src/FluentAssertions/Execution/LateBoundTestFramework.cs @@ -1,40 +1,58 @@ using System; using System.Diagnostics.CodeAnalysis; +using System.IO; using System.Reflection; namespace FluentAssertions.Execution; internal abstract class LateBoundTestFramework : ITestFramework { - private Assembly assembly; + private readonly bool loadAssembly; + private Func exceptionFactory; - [DoesNotReturn] - public void Throw(string message) + protected LateBoundTestFramework(bool loadAssembly = false) { - Type exceptionType = assembly.GetType(ExceptionFullName); - - if (exceptionType is null) - { - throw new NotSupportedException( - $"Failed to create the assertion exception for the current test framework: \"{ExceptionFullName}, {assembly.FullName}\""); - } - - throw (Exception)Activator.CreateInstance(exceptionType, message); + this.loadAssembly = loadAssembly; + exceptionFactory = _ => throw new InvalidOperationException($"{nameof(IsAvailable)} must be called first."); } + [DoesNotReturn] + public void Throw(string message) => throw exceptionFactory(message); + public bool IsAvailable { get { - string prefix = AssemblyName + ","; + var assembly = FindExceptionAssembly(); + var exceptionType = assembly?.GetType(ExceptionFullName); - assembly = Array.Find(AppDomain.CurrentDomain - .GetAssemblies(), a => a.FullName.StartsWith(prefix, StringComparison.OrdinalIgnoreCase)); + exceptionFactory = exceptionType != null + ? message => (Exception)Activator.CreateInstance(exceptionType, message) + : _ => throw new InvalidOperationException($"{GetType().Name} is not available"); - return assembly is not null; + return exceptionType is not null; } } + private Assembly FindExceptionAssembly() + { + var assembly = Array.Find(AppDomain.CurrentDomain.GetAssemblies(), a => a.GetName().Name == AssemblyName); + + if (assembly is null && loadAssembly) + { + try + { + return Assembly.Load(new AssemblyName(AssemblyName)); + } + catch (FileNotFoundException) + { + return null; + } + } + + return assembly; + } + protected internal abstract string AssemblyName { get; } protected abstract string ExceptionFullName { get; } diff --git a/Src/FluentAssertions/Execution/TestFrameworkProvider.cs b/Src/FluentAssertions/Execution/TestFrameworkProvider.cs index f5e291d8f9..dc73e8105e 100644 --- a/Src/FluentAssertions/Execution/TestFrameworkProvider.cs +++ b/Src/FluentAssertions/Execution/TestFrameworkProvider.cs @@ -18,7 +18,10 @@ internal class TestFrameworkProvider ["mspec"] = new MSpecFramework(), ["nunit"] = new NUnitTestFramework(), ["mstestv2"] = new MSTestFrameworkV2(), - ["xunit2"] = new XUnit2TestFramework() // Keep this the last one as it uses a try/catch approach + + // Keep XUnitTestFramework last as they use a try/catch approach + ["xunit2"] = new XUnitTestFramework("xunit.assert"), + ["xunit3"] = new XUnitTestFramework("xunit.v3.assert"), }; private readonly Configuration configuration; diff --git a/Src/FluentAssertions/Execution/XUnit2TestFramework.cs b/Src/FluentAssertions/Execution/XUnit2TestFramework.cs deleted file mode 100644 index 5dc2b38012..0000000000 --- a/Src/FluentAssertions/Execution/XUnit2TestFramework.cs +++ /dev/null @@ -1,40 +0,0 @@ -using System; -using System.Diagnostics.CodeAnalysis; -using System.Reflection; - -namespace FluentAssertions.Execution; - -/// -/// Implements the XUnit (version 2) test framework adapter. -/// -internal class XUnit2TestFramework : ITestFramework -{ - private Assembly assembly; - - public bool IsAvailable - { - get - { - try - { - // For netfx the assembly is not in AppDomain by default, so we can't just scan AppDomain.CurrentDomain - assembly = Assembly.Load(new AssemblyName("xunit.assert")); - - return assembly is not null; - } - catch - { - return false; - } - } - } - - [DoesNotReturn] - public void Throw(string message) - { - Type exceptionType = assembly.GetType("Xunit.Sdk.XunitException") - ?? throw new NotSupportedException("Failed to create the XUnit assertion type"); - - throw (Exception)Activator.CreateInstance(exceptionType, message); - } -} diff --git a/Src/FluentAssertions/Execution/XUnitTestFramework.cs b/Src/FluentAssertions/Execution/XUnitTestFramework.cs new file mode 100644 index 0000000000..6c68fb5b1e --- /dev/null +++ b/Src/FluentAssertions/Execution/XUnitTestFramework.cs @@ -0,0 +1,11 @@ +namespace FluentAssertions.Execution; + +/// +/// Implements the xUnit (version 2 and 3) test framework adapter. +/// +internal class XUnitTestFramework(string assemblyName) : LateBoundTestFramework(loadAssembly: true) +{ + protected internal override string AssemblyName => assemblyName; + + protected override string ExceptionFullName => "Xunit.Sdk.XunitException"; +} diff --git a/Src/FluentAssertions/FluentAssertions.csproj b/Src/FluentAssertions/FluentAssertions.csproj index 030f9996cb..8a498e446e 100644 --- a/Src/FluentAssertions/FluentAssertions.csproj +++ b/Src/FluentAssertions/FluentAssertions.csproj @@ -19,7 +19,7 @@ A very extensive set of extension methods that allow you to more naturally specify the expected outcome of a TDD or BDD-style unit tests. Targets .NET Framework 4.7, .NET 6, as well as .NET Standard 2.0 and 2.1. - Supports the unit test frameworks MSTest2, NUnit3, XUnit2 and MSpec. + Supports the unit test frameworks MSTest2, NUnit3, XUnit2, XUnit3 and MSpec. Supported by InfoSupport B.V. diff --git a/Tests/Approval.Tests/ApprovedApi/FluentAssertions/net47.verified.txt b/Tests/Approval.Tests/ApprovedApi/FluentAssertions/net47.verified.txt index 51370f44e4..021b98ac14 100644 --- a/Tests/Approval.Tests/ApprovedApi/FluentAssertions/net47.verified.txt +++ b/Tests/Approval.Tests/ApprovedApi/FluentAssertions/net47.verified.txt @@ -1300,11 +1300,9 @@ namespace FluentAssertions.Events } namespace FluentAssertions.Execution { - [System.Serializable] public class AssertionFailedException : System.Exception { public AssertionFailedException(string message) { } - protected AssertionFailedException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } } public sealed class AssertionScope : FluentAssertions.Execution.IAssertionScope, System.IDisposable { diff --git a/Tests/Approval.Tests/ApprovedApi/FluentAssertions/net6.0.verified.txt b/Tests/Approval.Tests/ApprovedApi/FluentAssertions/net6.0.verified.txt index 374a48da02..4f53076eae 100644 --- a/Tests/Approval.Tests/ApprovedApi/FluentAssertions/net6.0.verified.txt +++ b/Tests/Approval.Tests/ApprovedApi/FluentAssertions/net6.0.verified.txt @@ -1313,11 +1313,9 @@ namespace FluentAssertions.Events } namespace FluentAssertions.Execution { - [System.Serializable] public class AssertionFailedException : System.Exception { public AssertionFailedException(string message) { } - protected AssertionFailedException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } } public sealed class AssertionScope : FluentAssertions.Execution.IAssertionScope, System.IDisposable { diff --git a/Tests/Approval.Tests/ApprovedApi/FluentAssertions/netstandard2.0.verified.txt b/Tests/Approval.Tests/ApprovedApi/FluentAssertions/netstandard2.0.verified.txt index b0bf642d36..65a643089c 100644 --- a/Tests/Approval.Tests/ApprovedApi/FluentAssertions/netstandard2.0.verified.txt +++ b/Tests/Approval.Tests/ApprovedApi/FluentAssertions/netstandard2.0.verified.txt @@ -1251,11 +1251,9 @@ namespace FluentAssertions.Equivalency.Tracing } namespace FluentAssertions.Execution { - [System.Serializable] public class AssertionFailedException : System.Exception { public AssertionFailedException(string message) { } - protected AssertionFailedException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } } public sealed class AssertionScope : FluentAssertions.Execution.IAssertionScope, System.IDisposable { diff --git a/Tests/Approval.Tests/ApprovedApi/FluentAssertions/netstandard2.1.verified.txt b/Tests/Approval.Tests/ApprovedApi/FluentAssertions/netstandard2.1.verified.txt index e79d8fcb72..a225ab0c10 100644 --- a/Tests/Approval.Tests/ApprovedApi/FluentAssertions/netstandard2.1.verified.txt +++ b/Tests/Approval.Tests/ApprovedApi/FluentAssertions/netstandard2.1.verified.txt @@ -1300,11 +1300,9 @@ namespace FluentAssertions.Events } namespace FluentAssertions.Execution { - [System.Serializable] public class AssertionFailedException : System.Exception { public AssertionFailedException(string message) { } - protected AssertionFailedException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } } public sealed class AssertionScope : FluentAssertions.Execution.IAssertionScope, System.IDisposable { diff --git a/Tests/TestFrameworks/MSTestV2.Specs/FrameworkSpecs.cs b/Tests/TestFrameworks/MSTestV2.Specs/FrameworkSpecs.cs index a6ce6387b6..a6f8b1e663 100644 --- a/Tests/TestFrameworks/MSTestV2.Specs/FrameworkSpecs.cs +++ b/Tests/TestFrameworks/MSTestV2.Specs/FrameworkSpecs.cs @@ -15,8 +15,9 @@ public void When_mstestv2_is_used_it_should_throw_mstest_exceptions_for_assertio // Assert Exception exception = act.Should().Throw().Which; - exception.GetType() - .FullName.Should() - .ContainEquivalentOf("Microsoft.VisualStudio.TestTools.UnitTesting.AssertFailedException"); + + // Don't reference the exception type explicitly like this: act.Should().Throw() + // It could cause this specs project to load the assembly containing the exception (this actually happens for xUnit) + exception.GetType().FullName.Should().Be("Microsoft.VisualStudio.TestTools.UnitTesting.AssertFailedException"); } } diff --git a/Tests/TestFrameworks/MSpec.Specs/FrameworkSpecs.cs b/Tests/TestFrameworks/MSpec.Specs/FrameworkSpecs.cs index 4572dd850c..4c26788adb 100644 --- a/Tests/TestFrameworks/MSpec.Specs/FrameworkSpecs.cs +++ b/Tests/TestFrameworks/MSpec.Specs/FrameworkSpecs.cs @@ -9,8 +9,11 @@ public class When_mspec_is_used { Because of = () => Exception = Catch.Exception(() => 0.Should().Be(1)); - It should_fail = () => Exception.Should().NotBeNull().And.BeAssignableTo(); - It should_have_a_specific_reason = () => Exception.GetType().FullName.Should().ContainEquivalentOf("Machine.Specifications.SpecificationException"); + It should_fail = () => Exception.Should().BeAssignableTo(); + + // Don't reference the exception type explicitly like this: Exception.Should().BeAssignableTo() + // It could cause this specs project to load the assembly containing the exception (this actually happens for xUnit) + It should_fail_with_a_specification_exception = () => Exception.GetType().FullName.Should().Be("Machine.Specifications.SpecificationException"); private static Exception Exception; } diff --git a/Tests/TestFrameworks/NUnit3.Specs/FrameworkSpecs.cs b/Tests/TestFrameworks/NUnit3.Specs/FrameworkSpecs.cs index 95576d269f..ad15835584 100644 --- a/Tests/TestFrameworks/NUnit3.Specs/FrameworkSpecs.cs +++ b/Tests/TestFrameworks/NUnit3.Specs/FrameworkSpecs.cs @@ -15,8 +15,9 @@ public void When_nunit3_is_used_it_should_throw_nunit_exceptions_for_assertion_f // Assert Exception exception = act.Should().Throw().Which; - exception.GetType() - .FullName.Should() - .ContainEquivalentOf("NUnit.Framework.AssertionException"); + + // Don't reference the exception type explicitly like this: act.Should().Throw() + // It could cause this specs project to load the assembly containing the exception (this actually happens for xUnit) + exception.GetType().FullName.Should().Be("NUnit.Framework.AssertionException"); } } diff --git a/Tests/TestFrameworks/XUnit2.Specs/FrameworkSpecs.cs b/Tests/TestFrameworks/XUnit2.Specs/FrameworkSpecs.cs index af307cbc30..7920d90718 100644 --- a/Tests/TestFrameworks/XUnit2.Specs/FrameworkSpecs.cs +++ b/Tests/TestFrameworks/XUnit2.Specs/FrameworkSpecs.cs @@ -14,6 +14,9 @@ public void When_xunit2_is_used_it_should_throw_xunit_exceptions_for_assertion_f // Assert Exception exception = act.Should().Throw().Which; - exception.GetType().FullName.Should().ContainEquivalentOf("xunit"); + + // Don't reference the exception type explicitly like this: act.Should().Throw() + // It could cause this specs project to load the assembly containing the exception (this actually happens for xUnit) + exception.GetType().FullName.Should().Be("Xunit.Sdk.XunitException"); } } diff --git a/Tests/TestFrameworks/XUnit3.Specs/FrameworkSpecs.cs b/Tests/TestFrameworks/XUnit3.Specs/FrameworkSpecs.cs new file mode 100644 index 0000000000..87db4492eb --- /dev/null +++ b/Tests/TestFrameworks/XUnit3.Specs/FrameworkSpecs.cs @@ -0,0 +1,24 @@ +using System; +using System.Linq; +using FluentAssertions; +using Xunit; + +namespace XUnit3.Specs; + +public class FrameworkSpecs +{ + [Fact] + public void When_xunit3_is_used_it_should_throw_xunit_exceptions_for_assertion_failures() + { + // Act + Action act = () => 0.Should().Be(1); + + // Assert + Exception exception = act.Should().Throw().Which; + + // Don't reference the exception type explicitly like this: act.Should().Throw() + // It could cause this specs project to load the assembly containing the exception (this actually happens for xUnit) + exception.GetType().GetInterfaces().Select(e => e.Name).Should().Contain("IAssertionException"); + exception.GetType().FullName.Should().Be("Xunit.Sdk.XunitException"); + } +} diff --git a/Tests/TestFrameworks/XUnit3.Specs/XUnit3.Specs.csproj b/Tests/TestFrameworks/XUnit3.Specs/XUnit3.Specs.csproj new file mode 100644 index 0000000000..8ee4b9bbb8 --- /dev/null +++ b/Tests/TestFrameworks/XUnit3.Specs/XUnit3.Specs.csproj @@ -0,0 +1,18 @@ + + + net472;net6.0 + Exe + + + + + + + + + + + + + + diff --git a/Tests/TestFrameworks/XUnit3Core.Specs/FrameworkSpecs.cs b/Tests/TestFrameworks/XUnit3Core.Specs/FrameworkSpecs.cs new file mode 100644 index 0000000000..d72a1825fc --- /dev/null +++ b/Tests/TestFrameworks/XUnit3Core.Specs/FrameworkSpecs.cs @@ -0,0 +1,20 @@ +using System; +using System.Linq; +using FluentAssertions; +using Xunit; + +namespace XUnit3Core.Specs; + +public class FrameworkSpecs +{ + [Fact] + public void When_xunit3_without_xunit_assert_is_used_it_should_throw_IAssertionException_for_assertion_failures() + { + // Act + Action act = () => 0.Should().Be(1); + + // Assert + Exception exception = act.Should().Throw().Which; + exception.GetType().GetInterfaces().Select(e => e.Name).Should().Contain("IAssertionException"); + } +} diff --git a/Tests/TestFrameworks/XUnit3Core.Specs/XUnit3Core.Specs.csproj b/Tests/TestFrameworks/XUnit3Core.Specs/XUnit3Core.Specs.csproj new file mode 100644 index 0000000000..96eac8f312 --- /dev/null +++ b/Tests/TestFrameworks/XUnit3Core.Specs/XUnit3Core.Specs.csproj @@ -0,0 +1,18 @@ + + + net472;net6.0 + Exe + + + + + + + + + + + + + + diff --git a/docs/_pages/introduction.md b/docs/_pages/introduction.md index a4c9d93a04..f46cb7e549 100644 --- a/docs/_pages/introduction.md +++ b/docs/_pages/introduction.md @@ -67,12 +67,12 @@ This chaining can make your unit tests a lot easier to read. Fluent Assertions supports a lot of different unit testing frameworks. Just add a reference to the corresponding test framework assembly to the unit test project. Fluent Assertions will automatically find the corresponding assembly and use it for throwing the framework-specific exceptions. -If, for some unknown reason, Fluent Assertions fails to find the assembly, and you're running under .NET 4.7 or a .NET 6.0 project, try specifying the framework explicitly using a configuration setting in the project’s app.config. If it cannot find any of the supported frameworks, it will fall back to using a custom `AssertFailedException` exception class. +If, for some unknown reason, Fluent Assertions fails to find the assembly, and you're running under .NET 4.7 or a .NET 6.0 project, try specifying the framework explicitly using a configuration setting in the project’s app.config. If it cannot find any of the supported frameworks, it will fall back to using a custom `AssertionFailedException` exception class. ```xml - + diff --git a/docs/_pages/releases.md b/docs/_pages/releases.md index 268f904b27..a0f7858813 100644 --- a/docs/_pages/releases.md +++ b/docs/_pages/releases.md @@ -7,6 +7,12 @@ sidebar: nav: "sidebar" --- +## 7.1.0 + +### Improvements + +* Added compatibility with xUnit.net v3 - [#2970](https://github.com/fluentassertions/fluentassertions/issues/2970) + ## 7.0.0 ### Breaking Changes diff --git a/docs/index.html b/docs/index.html index 1a143b203b..42a7ac9400 100644 --- a/docs/index.html +++ b/docs/index.html @@ -54,7 +54,7 @@ image_path: /assets/images/checklist.svg excerpt: ' Targets .NET 4.7, .NET 6, .NET Standard 2.0 and 2.1. -Supports MSTest2, xUnit2, NUnit3 and MSpec. +Supports MSTest2, XUnit2, XUnit3, NUnit3 and MSpec. ' - title: "Great Support" image_path: /assets/images/customer-service.svg From 719db2a7df943a1587aa95c5538350479d829601 Mon Sep 17 00:00:00 2001 From: Tom Longhurst <30480171+thomhurst@users.noreply.github.com> Date: Thu, 24 Oct 2024 16:14:51 +0200 Subject: [PATCH 3/3] Backport TUnit support --- .nuke/build.schema.json | 4 +- Build/Build.cs | 42 ++++++++++++++++++- FluentAssertions.sln | 9 ++++ .../Execution/LateBoundTestFramework.cs | 4 ++ .../Execution/TUnitFramework.cs | 8 ++++ .../Execution/TestFrameworkProvider.cs | 1 + Src/FluentAssertions/FluentAssertions.csproj | 4 +- .../TUnit.Specs/FrameworkSpecs.cs | 21 ++++++++++ .../TUnit.Specs/TUnit.Specs.csproj | 19 +++++++++ docs/_pages/about.md | 1 + docs/_pages/introduction.md | 2 +- docs/_pages/releases.md | 1 + docs/index.html | 2 +- 13 files changed, 112 insertions(+), 6 deletions(-) create mode 100644 Src/FluentAssertions/Execution/TUnitFramework.cs create mode 100644 Tests/TestFrameworks/TUnit.Specs/FrameworkSpecs.cs create mode 100644 Tests/TestFrameworks/TUnit.Specs/TUnit.Specs.csproj diff --git a/.nuke/build.schema.json b/.nuke/build.schema.json index 50c8444452..5d9893991d 100644 --- a/.nuke/build.schema.json +++ b/.nuke/build.schema.json @@ -34,9 +34,11 @@ "Restore", "SpellCheck", "TestFrameworks", + "TestingPlatformFrameworks", "UnitTests", "UnitTestsNetCore", - "UnitTestsNetFramework" + "UnitTestsNetFramework", + "VSTestFrameworks" ] }, "Verbosity": { diff --git a/Build/Build.cs b/Build/Build.cs index c3aebb1654..64a7ab7c79 100644 --- a/Build/Build.cs +++ b/Build/Build.cs @@ -261,7 +261,7 @@ void ReportTestOutcome(params string[] globFilters) Information($"Code coverage report: \x1b]8;;file://{link.Replace('\\', '/')}\x1b\\{link}\x1b]8;;\x1b\\"); }); - Target TestFrameworks => _ => _ + Target VSTestFrameworks => _ => _ .DependsOn(Compile) .OnlyWhenDynamic(() => RunAllTargets || HasSourceChanges) .Executes(() => @@ -302,6 +302,46 @@ from framework in supportedFrameworks ReportTestOutcome(projects.Select(p => $"*{p.Name}*.trx").ToArray()); }); + Target TestingPlatformFrameworks => _ => _ + .DependsOn(Compile) + .OnlyWhenDynamic(() => RunAllTargets || HasSourceChanges) + .Executes(() => + { + Project[] projects = + [ + Solution.TestFrameworks.TUnit_Specs + ]; + + var testCombinations = + from project in projects + let frameworks = project.GetTargetFrameworks() + from framework in frameworks + select new { project, framework }; + + DotNetTest(s => s + .SetConfiguration(Configuration.Debug) + .SetProcessEnvironmentVariable("DOTNET_CLI_UI_LANGUAGE", "en-US") + .EnableNoBuild() + .CombineWith( + testCombinations, + (settings, v) => settings + .SetProjectFile(v.project) + .SetFramework(v.framework) + .SetProcessAdditionalArguments( + "--", + "--coverage", + "--report-trx", + $"--report-trx-filename {v.project.Name}_{v.framework}.trx", + $"--results-directory {TestResultsDirectory}" + ) + ) + ); + }); + + Target TestFrameworks => _ => _ + .DependsOn(VSTestFrameworks) + .DependsOn(TestingPlatformFrameworks); + Target Pack => _ => _ .DependsOn(ApiChecks) .DependsOn(TestFrameworks) diff --git a/FluentAssertions.sln b/FluentAssertions.sln index a3b1d492de..a8c40fb34f 100644 --- a/FluentAssertions.sln +++ b/FluentAssertions.sln @@ -55,6 +55,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "XUnit3.Specs", "Tests\TestF EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "XUnit3Core.Specs", "Tests\TestFrameworks\XUnit3Core.Specs\XUnit3Core.Specs.csproj", "{FCD60E63-F1DC-4DF0-AB75-69CCB6931FF7}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TUnit.Specs", "Tests\TestFrameworks\TUnit.Specs\TUnit.Specs.csproj", "{61DC52C4-C0EF-4059-B634-A8FC6826EFA1}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution CI|Any CPU = CI|Any CPU @@ -157,6 +159,12 @@ Global {FCD60E63-F1DC-4DF0-AB75-69CCB6931FF7}.Debug|Any CPU.Build.0 = Debug|Any CPU {FCD60E63-F1DC-4DF0-AB75-69CCB6931FF7}.Release|Any CPU.ActiveCfg = Release|Any CPU {FCD60E63-F1DC-4DF0-AB75-69CCB6931FF7}.Release|Any CPU.Build.0 = Release|Any CPU + {61DC52C4-C0EF-4059-B634-A8FC6826EFA1}.CI|Any CPU.ActiveCfg = Debug|Any CPU + {61DC52C4-C0EF-4059-B634-A8FC6826EFA1}.CI|Any CPU.Build.0 = Debug|Any CPU + {61DC52C4-C0EF-4059-B634-A8FC6826EFA1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {61DC52C4-C0EF-4059-B634-A8FC6826EFA1}.Debug|Any CPU.Build.0 = Debug|Any CPU + {61DC52C4-C0EF-4059-B634-A8FC6826EFA1}.Release|Any CPU.ActiveCfg = Release|Any CPU + {61DC52C4-C0EF-4059-B634-A8FC6826EFA1}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -178,6 +186,7 @@ Global {0A69DC62-CA14-44E5-BAF9-2EB2E2E2CADF} = {963262D0-9FD5-4741-8C0E-E2F34F110EF3} {60335A74-208E-4B33-BA4F-70A36541705E} = {4D8FA213-8724-4C43-B68A-F018148D238C} {FCD60E63-F1DC-4DF0-AB75-69CCB6931FF7} = {4D8FA213-8724-4C43-B68A-F018148D238C} + {61DC52C4-C0EF-4059-B634-A8FC6826EFA1} = {4D8FA213-8724-4C43-B68A-F018148D238C} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {75DDA3D8-9D6F-4865-93F4-DDE11DEE8290} diff --git a/Src/FluentAssertions/Execution/LateBoundTestFramework.cs b/Src/FluentAssertions/Execution/LateBoundTestFramework.cs index 5c7cbbe423..112b678bb0 100644 --- a/Src/FluentAssertions/Execution/LateBoundTestFramework.cs +++ b/Src/FluentAssertions/Execution/LateBoundTestFramework.cs @@ -48,6 +48,10 @@ private Assembly FindExceptionAssembly() { return null; } + catch (FileLoadException) + { + return null; + } } return assembly; diff --git a/Src/FluentAssertions/Execution/TUnitFramework.cs b/Src/FluentAssertions/Execution/TUnitFramework.cs new file mode 100644 index 0000000000..33fe376f49 --- /dev/null +++ b/Src/FluentAssertions/Execution/TUnitFramework.cs @@ -0,0 +1,8 @@ +namespace FluentAssertions.Execution; + +internal class TUnitFramework() : LateBoundTestFramework(loadAssembly: true) +{ + protected override string ExceptionFullName => "TUnit.Assertions.Exceptions.AssertionException"; + + protected internal override string AssemblyName => "TUnit.Assertions"; +} diff --git a/Src/FluentAssertions/Execution/TestFrameworkProvider.cs b/Src/FluentAssertions/Execution/TestFrameworkProvider.cs index dc73e8105e..0c140dfc44 100644 --- a/Src/FluentAssertions/Execution/TestFrameworkProvider.cs +++ b/Src/FluentAssertions/Execution/TestFrameworkProvider.cs @@ -20,6 +20,7 @@ internal class TestFrameworkProvider ["mstestv2"] = new MSTestFrameworkV2(), // Keep XUnitTestFramework last as they use a try/catch approach + ["tunit"] = new TUnitFramework(), ["xunit2"] = new XUnitTestFramework("xunit.assert"), ["xunit3"] = new XUnitTestFramework("xunit.v3.assert"), }; diff --git a/Src/FluentAssertions/FluentAssertions.csproj b/Src/FluentAssertions/FluentAssertions.csproj index 8a498e446e..0cd30876ef 100644 --- a/Src/FluentAssertions/FluentAssertions.csproj +++ b/Src/FluentAssertions/FluentAssertions.csproj @@ -19,14 +19,14 @@ A very extensive set of extension methods that allow you to more naturally specify the expected outcome of a TDD or BDD-style unit tests. Targets .NET Framework 4.7, .NET 6, as well as .NET Standard 2.0 and 2.1. - Supports the unit test frameworks MSTest2, NUnit3, XUnit2, XUnit3 and MSpec. + Supports the unit test frameworks MSTest2, NUnit3, XUnit2, XUnit3, MSpec and TUnit. Supported by InfoSupport B.V. https://www.fluentassertions.com https://github.com/fluentassertions/fluentassertions git - MSTest2;xUnit;NUnit;MSpec;TDD;BDD;Fluent;netstandard;uwp + MSTest2;xUnit;NUnit;MSpec;TUnit;TDD;BDD;Fluent;netstandard;uwp Apache-2.0 FluentAssertions.png See https://fluentassertions.com/releases/ diff --git a/Tests/TestFrameworks/TUnit.Specs/FrameworkSpecs.cs b/Tests/TestFrameworks/TUnit.Specs/FrameworkSpecs.cs new file mode 100644 index 0000000000..ee06efd844 --- /dev/null +++ b/Tests/TestFrameworks/TUnit.Specs/FrameworkSpecs.cs @@ -0,0 +1,21 @@ +using System; +using FluentAssertions; + +namespace TUnit.Specs; + +public class FrameworkSpecs +{ + [Test] + public void When_tunit_is_used_it_should_throw_tunit_exceptions_for_assertion_failures() + { + // Act + Action act = () => 0.Should().Be(1); + + // Assert + Exception exception = act.Should().Throw().Which; + + // Don't reference the exception type explicitly like this: act.Should().Throw() + // It could cause this specs project to load the assembly containing the exception (this actually happens for xUnit) + exception.GetType().FullName.Should().Be("TUnit.Assertions.Exceptions.AssertionException"); + } +} diff --git a/Tests/TestFrameworks/TUnit.Specs/TUnit.Specs.csproj b/Tests/TestFrameworks/TUnit.Specs/TUnit.Specs.csproj new file mode 100644 index 0000000000..736e0df558 --- /dev/null +++ b/Tests/TestFrameworks/TUnit.Specs/TUnit.Specs.csproj @@ -0,0 +1,19 @@ + + + + Exe + net8.0 + TUnit.Specs + TUnit.Specs + + + + + + + + + + + + diff --git a/docs/_pages/about.md b/docs/_pages/about.md index f193c1a4d4..e35d4c20d9 100644 --- a/docs/_pages/about.md +++ b/docs/_pages/about.md @@ -54,6 +54,7 @@ Fluent Assertions supports the following unit test frameworks: * [NUnit](http://www.nunit.org/) * [XUnit2](https://github.com/xunit/xunit/releases) * [MSpec](https://github.com/machine/machine.specifications) +* [TUnit](https://github.com/thomhurst/TUnit) ## Coding by Example diff --git a/docs/_pages/introduction.md b/docs/_pages/introduction.md index f46cb7e549..6a94dbfeaf 100644 --- a/docs/_pages/introduction.md +++ b/docs/_pages/introduction.md @@ -72,7 +72,7 @@ If, for some unknown reason, Fluent Assertions fails to find the assembly, and y ```xml - + diff --git a/docs/_pages/releases.md b/docs/_pages/releases.md index a0f7858813..b4b64ab92a 100644 --- a/docs/_pages/releases.md +++ b/docs/_pages/releases.md @@ -12,6 +12,7 @@ sidebar: ### Improvements * Added compatibility with xUnit.net v3 - [#2970](https://github.com/fluentassertions/fluentassertions/issues/2970) +* Added support for throwing TUnit exceptions when using TUnit as your testing framework - [#2971](https://github.com/fluentassertions/fluentassertions/pull/2971) ## 7.0.0 diff --git a/docs/index.html b/docs/index.html index 42a7ac9400..8df4b7f1c8 100644 --- a/docs/index.html +++ b/docs/index.html @@ -54,7 +54,7 @@ image_path: /assets/images/checklist.svg excerpt: ' Targets .NET 4.7, .NET 6, .NET Standard 2.0 and 2.1. -Supports MSTest2, XUnit2, XUnit3, NUnit3 and MSpec. +Supports MSTest2, XUnit2, XUnit3, NUnit3, MSpec and TUnit. ' - title: "Great Support" image_path: /assets/images/customer-service.svg pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy