diff --git a/.cspell.json b/.cspell.json
index 3fc59e62..fa16d943 100644
--- a/.cspell.json
+++ b/.cspell.json
@@ -23,7 +23,7 @@
},
{
"languageId": "csproj",
- "words": ["buildtransitive", "contentfiles", "ruleset", "visualstudio"]
+ "words": ["buildtransitive", "contentfiles", "linq", "ruleset", "visualstudio"]
},
{
"languageId": "nuspec",
@@ -31,7 +31,7 @@
},
{
"languageId": "props",
- "words": ["analyzers", "netstandard"]
+ "words": ["analyzers", "linq", "netstandard"]
}
],
"overrides": [
diff --git a/.editorconfig b/.editorconfig
index 72b09d32..3180bb83 100644
--- a/.editorconfig
+++ b/.editorconfig
@@ -138,6 +138,9 @@ dotnet_style_require_accessibility_modifiers = for_
file_header_template = unset
indent_size = 4
+dotnet_diagnostic.CA1034.severity = none
+dotnet_diagnostic.CA2007.severity = none
+
[*.sh]
end_of_line = lf
diff --git a/CHANGELOG.md b/CHANGELOG.md
index e11e2b28..45ca22d1 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,9 @@
# Changelog
+## 2.9.2
+
+cleanup suppressions (mostly)
+
## 2.9.1
support injecting `ITestOutputHelper` (with some [Gotchas](./README.md#gotchas))
diff --git a/Directory.Packages.props b/Directory.Packages.props
index 78c2e11b..5de8b857 100644
--- a/Directory.Packages.props
+++ b/Directory.Packages.props
@@ -11,6 +11,7 @@
+
diff --git a/LambdaTale.sln b/LambdaTale.sln
index 496e1318..e177eff2 100644
--- a/LambdaTale.sln
+++ b/LambdaTale.sln
@@ -22,6 +22,7 @@ EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{736B22BD-3BAB-41B7-A556-585A1839CE70}"
ProjectSection(SolutionItems) = preProject
Directory.Build.props = Directory.Build.props
+ Directory.Packages.props = Directory.Packages.props
EndProjectSection
EndProject
Global
diff --git a/src/LambdaTale.Execution/Extensions/MethodInfoExtensions.cs b/src/LambdaTale.Execution/Extensions/MethodInfoExtensions.cs
index 288bc122..de83bd05 100644
--- a/src/LambdaTale.Execution/Extensions/MethodInfoExtensions.cs
+++ b/src/LambdaTale.Execution/Extensions/MethodInfoExtensions.cs
@@ -1,5 +1,4 @@
using System;
-using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Reflection;
using System.Threading.Tasks;
@@ -9,13 +8,12 @@ namespace LambdaTale.Execution.Extensions;
internal static class MethodInfoExtensions
{
- [SuppressMessage("Microsoft.Naming", "CA1720:IdentifiersShouldNotContainTypeNames", MessageId = "obj", Justification = "Propagating sync method parameter name.")]
public static async Task InvokeAsync(this MethodInfo method, object obj, object[] arguments)
{
method = method ?? throw new ArgumentNullException(nameof(method));
var parameterTypes = method.GetParameters().Select(parameter => parameter.ParameterType).ToArray();
- Reflector.ConvertArguments(arguments, parameterTypes);
+ arguments = Reflector.ConvertArguments(arguments, parameterTypes);
if (method.Invoke(obj, arguments) is Task task)
{
diff --git a/src/LambdaTale.Execution/GlobalSuppressions.cs b/src/LambdaTale.Execution/GlobalSuppressions.cs
deleted file mode 100644
index ddf0897a..00000000
--- a/src/LambdaTale.Execution/GlobalSuppressions.cs
+++ /dev/null
@@ -1,4 +0,0 @@
-using System.Diagnostics.CodeAnalysis;
-
-[assembly: SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "desktop", Justification = "Matching xunit casing.")]
-[assembly: SuppressMessage("Design", "CA1031:Do not catch general exception types", Justification = "Copy-pasted upstream code.", Scope = "namespaceanddescendants", Target = "~N:Xunit")]
diff --git a/src/LambdaTale.Execution/Invoker.cs b/src/LambdaTale.Execution/Invoker.cs
index 22b5ed60..c34cb3fd 100644
--- a/src/LambdaTale.Execution/Invoker.cs
+++ b/src/LambdaTale.Execution/Invoker.cs
@@ -1,5 +1,4 @@
using System;
-using System.Diagnostics.CodeAnalysis;
using System.Security;
using System.Threading;
using System.Threading.Tasks;
diff --git a/src/LambdaTale.Execution/ScenarioInvoker.cs b/src/LambdaTale.Execution/ScenarioInvoker.cs
index 01bff031..749b6490 100644
--- a/src/LambdaTale.Execution/ScenarioInvoker.cs
+++ b/src/LambdaTale.Execution/ScenarioInvoker.cs
@@ -113,11 +113,7 @@ private Task BeforeScenarioMethodInvokedAsync()
this.timer.Aggregate(() => beforeAfterAttribute.Before(this.scenarioMethod));
this.beforeAfterScenarioAttributesRun.Push(beforeAfterAttribute);
}
-#pragma warning disable IDE0079 // Remove unnecessary suppression
-#pragma warning disable CA1031 // Do not catch general exception types
catch (Exception ex)
-#pragma warning restore CA1031 // Do not catch general exception types
-#pragma warning restore IDE0079 // Remove unnecessary suppression
{
this.aggregator.Add(ex);
break;
@@ -237,13 +233,12 @@ private async Task InvokeStepsAsync(
var stepTeardowns = stepContext.Disposables
.Where(disposable => disposable != null)
.Select((Func>)(disposable =>
- context =>
+ _ =>
{
disposable.Dispose();
return Task.CompletedTask;
}))
- .Concat(stepDefinition.Teardowns)
- .Where(teardown => teardown != null)
+ .Concat(stepDefinition.Teardowns.Where(teardown => teardown != null))
.Select(teardown => Tuple.Create(stepContext, teardown));
scenarioTeardowns.AddRange(stepTeardowns);
diff --git a/src/LambdaTale.Execution/ScenarioOutlineTestCaseRunner.cs b/src/LambdaTale.Execution/ScenarioOutlineTestCaseRunner.cs
index 698044db..136ef314 100644
--- a/src/LambdaTale.Execution/ScenarioOutlineTestCaseRunner.cs
+++ b/src/LambdaTale.Execution/ScenarioOutlineTestCaseRunner.cs
@@ -9,35 +9,31 @@
namespace LambdaTale.Execution;
-public class ScenarioOutlineTestCaseRunner : XunitTestCaseRunner
+public class ScenarioOutlineTestCaseRunner(
+ IMessageSink diagnosticMessageSink,
+ IXunitTestCase scenarioOutline,
+ string displayName,
+ string skipReason,
+ object[] constructorArguments,
+ IMessageBus messageBus,
+ ExceptionAggregator aggregator,
+ CancellationTokenSource cancellationTokenSource)
+ : XunitTestCaseRunner(scenarioOutline,
+ displayName,
+ skipReason,
+ constructorArguments,
+ NoArguments,
+ messageBus,
+ aggregator,
+ cancellationTokenSource)
{
- private static readonly object[] noArguments = [];
+ private static readonly object[] NoArguments = [];
- private readonly IMessageSink diagnosticMessageSink;
private readonly ExceptionAggregator cleanupAggregator = new();
private readonly List scenarioRunners = [];
private readonly List disposables = [];
private Exception dataDiscoveryException;
- public ScenarioOutlineTestCaseRunner(
- IMessageSink diagnosticMessageSink,
- IXunitTestCase scenarioOutline,
- string displayName,
- string skipReason,
- object[] constructorArguments,
- IMessageBus messageBus,
- ExceptionAggregator aggregator,
- CancellationTokenSource cancellationTokenSource)
- : base(
- scenarioOutline,
- displayName,
- skipReason,
- constructorArguments,
- noArguments,
- messageBus,
- aggregator,
- cancellationTokenSource) => this.diagnosticMessageSink = diagnosticMessageSink;
-
protected override async Task AfterTestCaseStartingAsync()
{
await base.AfterTestCaseStartingAsync();
@@ -49,7 +45,7 @@ protected override async Task AfterTestCaseStartingAsync()
{
var discovererAttribute = dataAttribute.GetCustomAttributes(typeof(DataDiscovererAttribute)).First();
var discoverer =
- ExtensibilityPointFactory.GetDataDiscoverer(this.diagnosticMessageSink, discovererAttribute);
+ ExtensibilityPointFactory.GetDataDiscoverer(diagnosticMessageSink, discovererAttribute);
foreach (var dataRow in discoverer.GetData(dataAttribute, this.TestCase.TestMethod.Method))
{
@@ -75,7 +71,7 @@ protected override async Task AfterTestCaseStartingAsync()
if (!this.scenarioRunners.Any())
{
- var info = new ScenarioInfo(this.TestCase.TestMethod.Method, noArguments, this.DisplayName);
+ var info = new ScenarioInfo(this.TestCase.TestMethod.Method, NoArguments, this.DisplayName);
var test = new Scenario(this.TestCase, info.ScenarioDisplayName);
var runner = new ScenarioRunner(
test,
@@ -91,9 +87,7 @@ protected override async Task AfterTestCaseStartingAsync()
this.scenarioRunners.Add(runner);
}
}
-#pragma warning disable CA1031 // Do not catch general exception types
catch (Exception ex)
-#pragma warning restore CA1031 // Do not catch general exception types
{
this.dataDiscoveryException = ex;
}
diff --git a/src/LambdaTale.Execution/StepTest.cs b/src/LambdaTale.Execution/StepTest.cs
index 60257b92..08ac83b2 100644
--- a/src/LambdaTale.Execution/StepTest.cs
+++ b/src/LambdaTale.Execution/StepTest.cs
@@ -1,12 +1,10 @@
using System;
-using System.Diagnostics.CodeAnalysis;
using LambdaTale.Sdk;
using Xunit;
using Xunit.Abstractions;
namespace LambdaTale.Execution;
-[SuppressMessage("Microsoft.Naming", "CA1716:IdentifiersShouldNotMatchKeywords", MessageId = "Step", Justification = "By design.")]
public class StepTest : LongLivedMarshalByRefObject, IStep
{
public StepTest(IScenario scenario, string displayName)
diff --git a/src/LambdaTale.Execution/StepTestRunner.cs b/src/LambdaTale.Execution/StepTestRunner.cs
index 8a18d6fb..861ffd45 100644
--- a/src/LambdaTale.Execution/StepTestRunner.cs
+++ b/src/LambdaTale.Execution/StepTestRunner.cs
@@ -4,44 +4,33 @@
using System.Threading;
using System.Threading.Tasks;
using LambdaTale.Sdk;
-using Xunit.Abstractions;
using Xunit.Sdk;
namespace LambdaTale.Execution;
-public class StepTestRunner : XunitTestRunner
+public class StepTestRunner(
+ IStepContext stepContext,
+ Func body,
+ IMessageBus messageBus,
+ Type scenarioClass,
+ object[] constructorArguments,
+ MethodInfo scenarioMethod,
+ object[] scenarioMethodArguments,
+ string skipReason,
+ IReadOnlyList beforeAfterAttributes,
+ ExceptionAggregator aggregator,
+ CancellationTokenSource cancellationTokenSource)
+ : XunitTestRunner(stepContext.Step,
+ messageBus,
+ scenarioClass,
+ constructorArguments,
+ scenarioMethod,
+ scenarioMethodArguments,
+ skipReason,
+ beforeAfterAttributes,
+ aggregator,
+ cancellationTokenSource)
{
- private readonly IStepContext stepContext;
- private readonly Func body;
-
- public StepTestRunner(
- IStepContext stepContext,
- Func body,
- IMessageBus messageBus,
- Type scenarioClass,
- object[] constructorArguments,
- MethodInfo scenarioMethod,
- object[] scenarioMethodArguments,
- string skipReason,
- IReadOnlyList beforeAfterAttributes,
- ExceptionAggregator aggregator,
- CancellationTokenSource cancellationTokenSource)
- : base(
- stepContext.Step,
- messageBus,
- scenarioClass,
- constructorArguments,
- scenarioMethod,
- scenarioMethodArguments,
- skipReason,
- beforeAfterAttributes,
- aggregator,
- cancellationTokenSource)
- {
- this.stepContext = stepContext;
- this.body = body;
- }
-
protected override Task InvokeTestMethodAsync(ExceptionAggregator aggregator) =>
- new StepInvoker(this.stepContext, this.body, aggregator, this.CancellationTokenSource).RunAsync();
+ new StepInvoker(stepContext, body, aggregator, this.CancellationTokenSource).RunAsync();
}
diff --git a/src/LambdaTale/BackgroundAttribute.cs b/src/LambdaTale/BackgroundAttribute.cs
index c73d5551..25c8f39d 100644
--- a/src/LambdaTale/BackgroundAttribute.cs
+++ b/src/LambdaTale/BackgroundAttribute.cs
@@ -1,5 +1,4 @@
using System;
-using System.Diagnostics.CodeAnalysis;
namespace LambdaTale;
@@ -7,14 +6,9 @@ namespace LambdaTale;
/// Applied to a method to indicate a background for each scenario defined in the same feature class.
///
[AttributeUsage(AttributeTargets.Method)]
-#pragma warning disable IDE0079 // Remove unnecessary suppression
-[SuppressMessage("Microsoft.Performance", "CA1813:AvoidUnsealedAttributes", Justification = "Designed for extensibility.")]
-#pragma warning restore IDE0079 // Remove unnecessary suppression
[IgnoreXunitAnalyzersRule1013]
public class BackgroundAttribute : Attribute
{
[AttributeUsage(AttributeTargets.Class)]
- private class IgnoreXunitAnalyzersRule1013Attribute : Attribute
- {
- }
+ private class IgnoreXunitAnalyzersRule1013Attribute : Attribute;
}
diff --git a/src/LambdaTale/BeforeAfterScenarioAttribute.cs b/src/LambdaTale/BeforeAfterScenarioAttribute.cs
index 0335f22b..3a4df048 100644
--- a/src/LambdaTale/BeforeAfterScenarioAttribute.cs
+++ b/src/LambdaTale/BeforeAfterScenarioAttribute.cs
@@ -1,5 +1,4 @@
using System;
-using System.Diagnostics.CodeAnalysis;
using Xunit.Sdk;
namespace LambdaTale;
@@ -15,8 +14,5 @@ namespace LambdaTale;
///
/// will be run before and after the scenario, rather than before and after each step in the scenario.
///
-[AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, AllowMultiple = true, Inherited = true)]
-[SuppressMessage("Microsoft.Performance", "CA1813:AvoidUnsealedAttributes", Justification = "Designed for extensibility.")]
-public abstract class BeforeAfterScenarioAttribute : BeforeAfterTestAttribute
-{
-}
+[AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, AllowMultiple = true)]
+public abstract class BeforeAfterScenarioAttribute : BeforeAfterTestAttribute;
diff --git a/src/LambdaTale/ExampleAttribute.cs b/src/LambdaTale/ExampleAttribute.cs
index b76dad1b..a5d0ccd1 100644
--- a/src/LambdaTale/ExampleAttribute.cs
+++ b/src/LambdaTale/ExampleAttribute.cs
@@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
-using System.Diagnostics.CodeAnalysis;
using System.Reflection;
using Xunit.Sdk;
@@ -10,31 +9,15 @@ namespace LambdaTale;
/// Provides example values for a scenario passed as arguments to the scenario method.
/// This attribute is designed as a synonym of ,
/// which is the most commonly used data attribute, but you can also use any type of attribute derived from
-/// to provide a data source for a scenario.
+/// to provide a data source for a scenario.
/// E.g. or
/// .
///
+/// /// The data values to pass to the scenario.
[DataDiscoverer("Xunit.Sdk.InlineDataDiscoverer", "xunit.core")]
[AttributeUsage(AttributeTargets.Method, AllowMultiple = true)]
-[SuppressMessage("Microsoft.Design", "CA1019:DefineAccessorsForAttributeArguments", Justification = "Following the pattern of Xunit.InlineDataAttribute.")]
-public sealed class ExampleAttribute : DataAttribute
+public sealed class ExampleAttribute(params object[] data) : DataAttribute
{
- ///
- /// Initializes a new instance of the class.
- /// This attribute is designed as a synonym of ,
- /// which is the most commonly used data attribute, but you can also use any type of attribute derived from
- /// to provide a data source for a scenario.
- /// E.g. or
- /// .
- ///
- /// The data values to pass to the scenario.
- [SuppressMessage("Microsoft.Usage", "CA1801:ReviewUnusedParameters", MessageId = "data", Justification = "Following the pattern of Xunit.InlineDataAttribute.")]
-#pragma warning disable IDE0060 // Remove unused parameter
- public ExampleAttribute(params object[] data)
-#pragma warning restore IDE0060 // Remove unused parameter
- {
- }
-
///
- public override IEnumerable