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 GetData(MethodInfo testMethod) => throw new InvalidOperationException(); + public override IEnumerable GetData(MethodInfo testMethod) => [data]; } diff --git a/src/LambdaTale/LambdaTale.csproj b/src/LambdaTale/LambdaTale.csproj index 8b574b06..ab5616c5 100644 --- a/src/LambdaTale/LambdaTale.csproj +++ b/src/LambdaTale/LambdaTale.csproj @@ -2,7 +2,6 @@ true - $(NoWarn);NU5128;CA1303 $(NUSPEC_FILE) diff --git a/src/LambdaTale/LambdaTale.nuspec b/src/LambdaTale/LambdaTale.nuspec index 3946ef93..35a387d2 100644 --- a/src/LambdaTale/LambdaTale.nuspec +++ b/src/LambdaTale/LambdaTale.nuspec @@ -13,8 +13,10 @@ testing xunit $Version$ - - + + + + diff --git a/src/LambdaTale/RemainingSteps.cs b/src/LambdaTale/RemainingSteps.cs index bae42b91..8e4953be 100644 --- a/src/LambdaTale/RemainingSteps.cs +++ b/src/LambdaTale/RemainingSteps.cs @@ -1,11 +1,8 @@ -using System.Diagnostics.CodeAnalysis; - namespace LambdaTale; /// /// Indicates the behavior of remaining steps when a step fails. /// -[SuppressMessage("Microsoft.Naming", "CA1717:OnlyFlagsEnumsShouldHavePluralNames", Justification = "Makes sense here.")] public enum RemainingSteps { /// diff --git a/src/LambdaTale/ScenarioAttribute.cs b/src/LambdaTale/ScenarioAttribute.cs index 4b28da2d..25f4fa28 100644 --- a/src/LambdaTale/ScenarioAttribute.cs +++ b/src/LambdaTale/ScenarioAttribute.cs @@ -1,5 +1,4 @@ using System; -using System.Diagnostics.CodeAnalysis; using Xunit; using Xunit.Sdk; @@ -17,7 +16,4 @@ namespace LambdaTale; /// [XunitTestCaseDiscoverer("LambdaTale.Execution.ScenarioDiscoverer", "LambdaTale.Execution")] [AttributeUsage(AttributeTargets.Method)] -[SuppressMessage("Microsoft.Performance", "CA1813:AvoidUnsealedAttributes", Justification = "Designed for extensibility.")] -public class ScenarioAttribute : FactAttribute -{ -} +public class ScenarioAttribute : FactAttribute; diff --git a/src/LambdaTale/Sdk/IStepContext.cs b/src/LambdaTale/Sdk/IStepContext.cs index d73ef201..44daf11e 100644 --- a/src/LambdaTale/Sdk/IStepContext.cs +++ b/src/LambdaTale/Sdk/IStepContext.cs @@ -1,5 +1,4 @@ using System; -using System.Diagnostics.CodeAnalysis; namespace LambdaTale.Sdk; @@ -12,7 +11,6 @@ public interface IStepContext /// /// Gets the step which owns this context. /// - [SuppressMessage("Microsoft.Naming", "CA1716:IdentifiersShouldNotMatchKeywords", MessageId = "Step", Justification = "Makes sense here.")] IStep Step { get; } /// @@ -21,6 +19,5 @@ public interface IStepContext /// /// The object to be disposed. /// The current . - [SuppressMessage("Microsoft.Naming", "CA1716:IdentifiersShouldNotMatchKeywords", MessageId = "Using", Justification = "Makes sense here.")] IStepContext Using(IDisposable disposable); } diff --git a/src/LambdaTale/StringExtensions.cs b/src/LambdaTale/StringExtensions.cs index 3c35a4e6..539c227e 100644 --- a/src/LambdaTale/StringExtensions.cs +++ b/src/LambdaTale/StringExtensions.cs @@ -9,7 +9,6 @@ namespace LambdaTale; /// public static class StringExtensions { -#pragma warning disable IDE1006 // Naming Styles /// /// Defines a step in the current scenario. /// @@ -96,5 +95,4 @@ public static IStepBuilder x(this string text, Func body) CurrentThread.Add(stepDefinition); return stepDefinition; } -#pragma warning restore IDE1006 // Naming Styles } diff --git a/targets/Targets.csproj b/targets/Targets.csproj index 9838e05a..896bf76d 100644 --- a/targets/Targets.csproj +++ b/targets/Targets.csproj @@ -9,6 +9,7 @@ + diff --git a/targets/Update.cs b/targets/Update.cs index 78369aa3..958a2c28 100644 --- a/targets/Update.cs +++ b/targets/Update.cs @@ -21,11 +21,11 @@ public static async Task Upstream() var srcDir = Path.GetFullPath(Path.Combine(currentDir, "..", "src")); var nuspec = XDocument.Load(Path.Combine(srcDir, "LambdaTale", "LambdaTale.nuspec")); var xUnitVersionRange = nuspec.XPathSelectElement("//dependency[@id=\"xunit.core\"]")!.Attribute("version")!.Value; - var xUnitVersion = Version.Parse(xUnitVersionRange[1..xUnitVersionRange.IndexOf(',')]).ToString(); + var xUnitVersion = Version.Parse(xUnitVersionRange[1..xUnitVersionRange.IndexOf(',', StringComparison.Ordinal)]).ToString(); using var httpClient = new HttpClient(); foreach (var upstreamSource in Directory.EnumerateFiles(Path.Combine(srcDir, "LambdaTale.Execution", "Upstream"), "*.cs")) { - var header = File.ReadLines(upstreamSource).First(); + var header = await File.ReadLinesAsync(upstreamSource).FirstAsync(); var newUpstream = VersionedUpstream().Replace(header, match => { var v = match.Groups["version"]; @@ -33,7 +33,7 @@ public static async Task Upstream() return match.Value.Remove(start, v.Length).Insert(start, xUnitVersion); })[Prefix.Length..]; - await using var newContent = await httpClient.GetStreamAsync(newUpstream); + await using var newContent = await httpClient.GetStreamAsync(new Uri(newUpstream)); await using var writer = new StreamWriter(upstreamSource, Encoding.UTF8, new FileStreamOptions { Mode = FileMode.Truncate, Access = FileAccess.Write }); await writer.WriteLineAsync(Prefix + newUpstream); diff --git a/targets/packages.lock.json b/targets/packages.lock.json index 5547c420..c739a513 100644 --- a/targets/packages.lock.json +++ b/targets/packages.lock.json @@ -13,6 +13,20 @@ "requested": "[12.0.0, )", "resolved": "12.0.0", "contentHash": "ptxlWtxC8vM6Y6e3h9ZTxBBkOWnWrm/Sa1HT+2i1xcXY3Hx2hmKDZP5RShPf8Xr9D+ivlrXNy57ktzyH8kyt+Q==" + }, + "System.Linq.Async": { + "type": "Direct", + "requested": "[6.0.1, )", + "resolved": "6.0.1", + "contentHash": "0YhHcaroWpQ9UCot3Pizah7ryAzQhNvobLMSxeDIGmnXfkQn8u5owvpOH0K6EVB+z9L7u6Cc4W17Br/+jyttEQ==", + "dependencies": { + "Microsoft.Bcl.AsyncInterfaces": "6.0.0" + } + }, + "Microsoft.Bcl.AsyncInterfaces": { + "type": "Transitive", + "resolved": "6.0.0", + "contentHash": "UcSjPsst+DfAdJGVDsu346FX0ci0ah+lw3WRtn18NUwEqRt70HaOQ7lI72vy3+1LxtqI3T5GWwV39rQSrCzAeg==" } } } diff --git a/tests/LambdaTale.Test/CollectionFixtureFeature.cs b/tests/LambdaTale.Test/CollectionFixtureFeature.cs index 064cdeba..7bd140a9 100644 --- a/tests/LambdaTale.Test/CollectionFixtureFeature.cs +++ b/tests/LambdaTale.Test/CollectionFixtureFeature.cs @@ -32,9 +32,7 @@ public void CollectionFixture(string collectionName, ITestResultMessage[] result } [CollectionDefinition("CollectionFixtureTestFeatures")] - public class CollectionFixtureTestFeatures : ICollectionFixture - { - } + public class CollectionFixtureTestFeatures : ICollectionFixture; [Collection("CollectionFixtureTestFeatures")] public class ScenarioWithACollectionFixture1 diff --git a/tests/LambdaTale.Test/ExampleFeature.cs b/tests/LambdaTale.Test/ExampleFeature.cs index 23ba47db..968c5ab2 100644 --- a/tests/LambdaTale.Test/ExampleFeature.cs +++ b/tests/LambdaTale.Test/ExampleFeature.cs @@ -324,9 +324,7 @@ private static class ArrayExamples { [Scenario] [Example(new[] { "one", "two" }, new[] { 1, 2 })] -#pragma warning disable IDE0060 // Remove unused parameter public static void Scenario(string[] words, int[] numbers) => -#pragma warning restore IDE0060 // Remove unused parameter "Given something" .x(() => { }); } diff --git a/tests/LambdaTale.Test/GlobalSuppressions.cs b/tests/LambdaTale.Test/GlobalSuppressions.cs deleted file mode 100644 index c23bed1b..00000000 --- a/tests/LambdaTale.Test/GlobalSuppressions.cs +++ /dev/null @@ -1,3 +0,0 @@ -using System.Diagnostics.CodeAnalysis; - -[assembly: SuppressMessage("Style", "IDE0058:Expression value is never used", Justification = "string.x method")] diff --git a/tests/LambdaTale.Test/Infrastructure/Xunit2Extensions.cs b/tests/LambdaTale.Test/Infrastructure/Xunit2Extensions.cs index 157b64e5..68e1a7ef 100644 --- a/tests/LambdaTale.Test/Infrastructure/Xunit2Extensions.cs +++ b/tests/LambdaTale.Test/Infrastructure/Xunit2Extensions.cs @@ -1,5 +1,4 @@ using System.Collections.Generic; -using System.Linq; using Xunit; using Xunit.Abstractions; diff --git a/tests/LambdaTale.Test/MemberDataFeature.cs b/tests/LambdaTale.Test/MemberDataFeature.cs index 95629fd9..4b4c08e3 100644 --- a/tests/LambdaTale.Test/MemberDataFeature.cs +++ b/tests/LambdaTale.Test/MemberDataFeature.cs @@ -36,9 +36,9 @@ public static IEnumerable MemberData { get { - yield return new object[] { 1, 2, 3 }; - yield return new object[] { 10, 20, 30 }; - yield return new object[] { 100, 200, 300 }; + yield return [1, 2, 3]; + yield return [10, 20, 30]; + yield return [100, 200, 300]; } } diff --git a/tests/LambdaTale.Test/MetadataFeature.cs b/tests/LambdaTale.Test/MetadataFeature.cs index 0489d78c..32521aaf 100644 --- a/tests/LambdaTale.Test/MetadataFeature.cs +++ b/tests/LambdaTale.Test/MetadataFeature.cs @@ -14,12 +14,12 @@ public void UsingMetadata(string text, IStepContext stepContext, IStep step, ISc .Teardown(c => Assert.Same(stepContext, c)); "Then the step context contains metadata about the step" - .x(() => Assert.Equal("LambdaTale.Test.MetadataFeature.UsingMetadata(text: \"abc\") [01] When I execute a step", (step = stepContext.Step)?.DisplayName)); + .x(() => Assert.EndsWith("UsingMetadata(text: \"abc\") [01] When I execute a step", (step = stepContext.Step)?.DisplayName)); "And the step contains metadata about the scenario" - .x(() => Assert.Equal("LambdaTale.Test.MetadataFeature.UsingMetadata(text: \"abc\")", (scenario = step.Scenario)?.DisplayName)); + .x(() => Assert.EndsWith("UsingMetadata(text: \"abc\")", (scenario = step.Scenario)?.DisplayName)); "And the step contains metadata about the scenario outline" - .x(() => Assert.Equal("LambdaTale.Test.MetadataFeature.UsingMetadata", scenario.ScenarioOutline?.DisplayName)); + .x(() => Assert.EndsWith("UsingMetadata", scenario.ScenarioOutline?.DisplayName)); } } diff --git a/tests/LambdaTale.Test/ScenarioFeature.cs b/tests/LambdaTale.Test/ScenarioFeature.cs index 0f9ace67..b3457c2c 100644 --- a/tests/LambdaTale.Test/ScenarioFeature.cs +++ b/tests/LambdaTale.Test/ScenarioFeature.cs @@ -1,5 +1,4 @@ using System; -using System.Diagnostics.CodeAnalysis; using System.Linq; using LambdaTale.Sdk; using LambdaTale.Test.Infrastructure; @@ -342,13 +341,10 @@ public static void Scenario() private class FeatureWithANonStaticScenarioButNoDefaultConstructor { -#pragma warning disable IDE0060 // Remove unused parameter public FeatureWithANonStaticScenarioButNoDefaultConstructor(int _) -#pragma warning restore IDE0060 // Remove unused parameter { } - [SuppressMessage("Microsoft.Performance", "CA1822:MarkMembersAsStatic", Justification = "Required for testing.")] [Scenario] public void Scenario() => "Given something" @@ -359,7 +355,6 @@ private class FeatureWithAFailingConstructor { public FeatureWithAFailingConstructor() => throw new InvalidOperationException(); - [SuppressMessage("Microsoft.Performance", "CA1822:MarkMembersAsStatic", Justification = "Required for testing.")] [Scenario] public void Scenario() => "Given something" diff --git a/tests/LambdaTale.Test/SkippedScenarioFeature.cs b/tests/LambdaTale.Test/SkippedScenarioFeature.cs index 82a8eb86..a0e0c885 100644 --- a/tests/LambdaTale.Test/SkippedScenarioFeature.cs +++ b/tests/LambdaTale.Test/SkippedScenarioFeature.cs @@ -28,9 +28,7 @@ public void SkippedScenario(Type feature, ITestResultMessage[] results) private static class FeatureWithASkippedScenario { -#pragma warning disable xUnit1004 // Test methods should not be skipped [Scenario(Skip = "Test")] -#pragma warning restore xUnit1004 // Test methods should not be skipped public static void Scenario1() => throw new InvalidOperationException(); } }