From 66ebebe4054813b25a2db03c093bfcb2c088a74c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Amaury=20Lev=C3=A9?= Date: Fri, 1 Jul 2022 10:30:31 +0200 Subject: [PATCH] Enable more rules on test projects (#3832) --- test/.editorconfig | 29 +++++++++++++++++++ .../ExecutionTests.cs | 2 +- .../Extension/CompatibilityRowsBuilder.cs | 22 +++++++------- .../MSTestCompatibilityDataSource.cs | 2 +- ...oreRunner.cs => NetCoreRunnerAttribute.cs} | 5 ++-- ...CoreTargetFrameworkDataSourceAttribute.cs} | 7 +++-- ...nner.cs => NetFrameworkRunnerAttribute.cs} | 7 +++-- ...FullTargetFrameworkDataSourceAttribute.cs} | 7 +++-- .../RunnerCompatibilityDataSource.cs | 2 +- ...taSource.cs => TestDataSourceAttribute.cs} | 8 ++--- .../TestPlatformCompatibilityDataSource.cs | 2 +- .../TesthostCompatibilityDataSource.cs | 2 +- .../RunsettingsTests.cs | 18 ++++++------ .../SelfContainedAppTests.cs | 2 +- .../TelemetryTests.cs | 4 +-- .../TestCaseFilterTests.cs | 2 +- .../TestPlatformNugetPackageTests.cs | 4 +-- .../CodeCoverageTests.cs | 4 +-- .../TranslationLayerTests/DiscoverTests.cs | 2 +- ...estRunAttachmentsProcessingEventHandler.cs | 2 +- .../TranslationLayerTests/RunTests.cs | 4 +-- .../ManagedNameRoundTripTests.cs | 3 ++ .../Utilities/FakesUtilitiesTests.cs | 2 +- .../TestRequestSenderTests.cs | 14 ++++----- .../CommandLineArgumentsHelperTests.cs | 2 +- .../Adapter/FrameworkHandleTests.cs | 4 +-- .../ProcessDumpUtilityTests.cs | 2 +- .../TranslationLayer/TelemetryPerfTestBase.cs | 11 +++---- .../CommandLineUtilitiesTest.cs | 2 +- .../PathResolverTests.cs | 2 +- .../ProgramTests.cs | 2 +- .../BlameUnitTestProject/Program.cs | 2 +- test/TestAssets/ConsoleManagedApp/Program.cs | 2 +- .../UnitTest1.cs | 5 ---- test/TestAssets/SimpleClassLibrary/Class1.cs | 2 +- test/TestAssets/SimpleTestProject2/Program.cs | 2 +- .../SimpleTestProjectARM/Program.cs | 2 +- .../SimpleTestProjectx86/Program.cs | 2 +- .../performance/MSTest1000Passing/MSTests.cs | 4 +-- .../performance/MSTest1000Passing/MSTests.tt | 11 ++++--- .../performance/MSTest100Passing/MSTests.cs | 4 +-- .../performance/MSTest100Passing/MSTests.tt | 11 ++++--- .../performance/MSTest10kPassing/MSTests.cs | 4 +-- .../performance/MSTest10kPassing/MSTests.tt | 11 ++++--- .../performance/MSTest1Passing/MSTests.cs | 4 +-- .../performance/MSTest1Passing/MSTests.tt | 11 ++++--- .../NUnit1000Passing/NunitTests.cs | 4 +-- .../NUnit1000Passing/NunitTests.tt | 11 ++++--- .../performance/NUnit100Passing/NunitTests.cs | 4 +-- .../performance/NUnit100Passing/NunitTests.tt | 11 ++++--- .../performance/NUnit10kPassing/NunitTests.cs | 4 +-- .../performance/NUnit10kPassing/NunitTests.tt | 11 ++++--- .../performance/NUnit1Passing/NunitTests.cs | 4 +-- .../performance/NUnit1Passing/NunitTests.tt | 11 ++++--- .../XUnit1000Passing/XunitTests.cs | 4 +-- .../XUnit1000Passing/XunitTests.tt | 11 ++++--- .../performance/XUnit100Passing/XunitTests.cs | 4 +-- .../performance/XUnit100Passing/XunitTests.tt | 11 ++++--- .../performance/XUnit10kPassing/XunitTests.cs | 4 +-- .../performance/XUnit10kPassing/XunitTests.tt | 11 ++++--- .../performance/XUnit1Passing/XunitTests.cs | 4 +-- .../performance/XUnit1Passing/XunitTests.tt | 11 ++++--- .../VsTestConsoleRequestSenderTests.cs | 2 +- .../TestHostTraceListenerTests.cs | 4 +-- .../MultiTFMRunAndDiscovery.cs | 2 +- .../GenerateFakesUtilitiesTests.cs | 2 +- .../CLIRunSettingsArgumentProcessorTests.cs | 4 +-- 67 files changed, 192 insertions(+), 200 deletions(-) create mode 100644 test/.editorconfig rename test/Microsoft.TestPlatform.AcceptanceTests/Extension/{NetCoreRunner.cs => NetCoreRunnerAttribute.cs} (93%) rename test/Microsoft.TestPlatform.AcceptanceTests/Extension/{NetCoreTargetFrameworkDataSource.cs => NetCoreTargetFrameworkDataSourceAttribute.cs} (95%) rename test/Microsoft.TestPlatform.AcceptanceTests/Extension/{NetFrameworkRunner.cs => NetFrameworkRunnerAttribute.cs} (91%) rename test/Microsoft.TestPlatform.AcceptanceTests/Extension/{NetFullTargetFrameworkDataSource.cs => NetFullTargetFrameworkDataSourceAttribute.cs} (93%) rename test/Microsoft.TestPlatform.AcceptanceTests/Extension/{TestDataSource.cs => TestDataSourceAttribute.cs} (90%) diff --git a/test/.editorconfig b/test/.editorconfig new file mode 100644 index 0000000000..2be7bb24d6 --- /dev/null +++ b/test/.editorconfig @@ -0,0 +1,29 @@ +# Tests specific configuration +# Applies on top of other .editorconfig files + +# C# files +[*.cs] + +#### .NET Coding Conventions #### + +# CA1825: Avoid zero-length array allocations +dotnet_diagnostic.CA1825.severity = warning + +# IDE0060: Remove unused parameter +dotnet_diagnostic.IDE0060.severity = warning + +# CA1018: Mark attributes with AttributeUsageAttribute +dotnet_diagnostic.CA1018.severity = warning + +#### C# Coding Conventions #### + +#### .NET Formatting Rules #### + +#### C# Formatting Rules #### + +#### .NET Naming styles #### + +# CA1710: Identifiers should have correct suffix +dotnet_diagnostic.CA1710.severity = warning + +#### C# Naming styles #### diff --git a/test/Microsoft.TestPlatform.AcceptanceTests/ExecutionTests.cs b/test/Microsoft.TestPlatform.AcceptanceTests/ExecutionTests.cs index 0732a5115f..4b6df159a1 100644 --- a/test/Microsoft.TestPlatform.AcceptanceTests/ExecutionTests.cs +++ b/test/Microsoft.TestPlatform.AcceptanceTests/ExecutionTests.cs @@ -35,7 +35,7 @@ public void RunMultipleTestAssemblies(RunnerInfo runnerInfo) [TestMethod] [TestCategory("Windows-Review")] - [TestPlatformCompatibilityDataSource()] + [TestPlatformCompatibilityDataSource] public void RunTestsFromMultipleMSTestAssemblies(RunnerInfo runnerInfo) { SetTestEnvironment(_testEnvironment, runnerInfo); diff --git a/test/Microsoft.TestPlatform.AcceptanceTests/Extension/CompatibilityRowsBuilder.cs b/test/Microsoft.TestPlatform.AcceptanceTests/Extension/CompatibilityRowsBuilder.cs index 02fd84ff9f..272b2ce6fb 100644 --- a/test/Microsoft.TestPlatform.AcceptanceTests/Extension/CompatibilityRowsBuilder.cs +++ b/test/Microsoft.TestPlatform.AcceptanceTests/Extension/CompatibilityRowsBuilder.cs @@ -181,7 +181,7 @@ private void AddInProcess(List dataRows) { foreach (var adapterVersion in _adapterVersions) { - AddRow(dataRows, "In process", runnerVersion, runnerFramework, runnerVersion, runnerFramework, adapter, adapterVersion, inIsolation: false); + AddRow(dataRows, "In process", runnerVersion, runnerFramework, runnerVersion, runnerFramework, adapterVersion, inIsolation: false); } } } @@ -200,10 +200,10 @@ private void AddOlderConfigurations(List dataRows) { var isNetFramework = hostFramework.StartsWith("net4"); var hostVersion = runnerVersion; - foreach (var adapter in _adapters) + foreach (var _ in _adapters) { var adapterVersion = _adapterVersions[0]; - AddRow(dataRows, "Older", runnerVersion, runnerFramework, hostVersion, hostFramework, adapter, adapterVersion, inIsolation: true); + AddRow(dataRows, "Older", runnerVersion, runnerFramework, hostVersion, hostFramework, adapterVersion, inIsolation: true); } } } @@ -225,7 +225,7 @@ private void AddEveryVersionOfAdapter(List dataRows) { foreach (var adapterVersion in _adapterVersions) { - AddRow(dataRows, "Every adapter", runnerVersion, runnerFramework, hostVersion, hostFramework, adapter, adapterVersion, inIsolation: true); + AddRow(dataRows, "Every adapter", runnerVersion, runnerFramework, hostVersion, hostFramework, adapterVersion, inIsolation: true); } } } @@ -247,11 +247,11 @@ private void AddEveryVersionOfHost(List dataRows) var hostVersions = isNetFramework ? Array.Empty() : _hostVersions.ToArray(); foreach (var hostVersion in hostVersions) { - foreach (var adapter in _adapters) + foreach (var _ in _adapters) { // use the newest var adapterVersion = _adapterVersions[0]; - AddRow(dataRows, "Every host", runnerVersion, runnerFramework, hostVersion, hostFramework, adapter, adapterVersion, inIsolation: true); + AddRow(dataRows, "Every host", runnerVersion, runnerFramework, hostVersion, hostFramework, adapterVersion, inIsolation: true); } } } @@ -270,11 +270,11 @@ private void AddEveryVersionOfRunner(List dataRows) // .NET Framework testhost ships with the runner, and the version from the // runner directory is always selected, otherwise select the newest version from _hostFrameworks. var hostVersion = isNetFramework ? runnerVersion : _hostVersions[0]; - foreach (var adapter in _adapters) + foreach (var _ in _adapters) { // use the newest var adapterVersion = _adapterVersions[0]; - AddRow(dataRows, "Every runner", runnerVersion, runnerFramework, hostVersion, hostFramework, adapter, adapterVersion, inIsolation: true); + AddRow(dataRows, "Every runner", runnerVersion, runnerFramework, hostVersion, hostFramework, adapterVersion, inIsolation: true); } } } @@ -282,7 +282,7 @@ private void AddEveryVersionOfRunner(List dataRows) } private void AddRow(List dataRows, string batch, - string runnerVersion, string runnerFramework, string hostVersion, string hostFramework, string adapter, string adapterVersion, bool inIsolation) + string runnerVersion, string runnerFramework, string hostVersion, string hostFramework, string adapterVersion, bool inIsolation) { RunnerInfo runnerInfo = GetRunnerInfo(batch, runnerFramework, hostFramework, inIsolation); runnerInfo.DebugInfo = GetDebugInfo(); @@ -347,7 +347,7 @@ private static VSTestConsoleInfo GetVSTestConsoleInfo(string vstestConsoleVersio var depsXml = GetDependenciesXml(); // When version is Latest, we built it locally, but it gets restored into our nuget cache on build - // same as other versions, we just need to grab the version from a different property. + // same as other versions, we just need to grab the version from a different property. var propertyName = vstestConsoleVersion == AcceptanceTestBase.LATEST ? "NETTestSdkVersion" @@ -386,7 +386,7 @@ private static NetTestSdkInfo GetNetTestSdkInfo(string testhostVersionType) var depsXml = GetDependenciesXml(); // When version is Latest, we built it locally, but it gets restored into our nuget cache on build - // same as other versions, we just need to grab the version from a different property. + // same as other versions, we just need to grab the version from a different property. var propertyName = testhostVersionType == AcceptanceTestBase.LATEST ? "NETTestSdkVersion" diff --git a/test/Microsoft.TestPlatform.AcceptanceTests/Extension/MSTestCompatibilityDataSource.cs b/test/Microsoft.TestPlatform.AcceptanceTests/Extension/MSTestCompatibilityDataSource.cs index e75bc87594..27d41b3401 100644 --- a/test/Microsoft.TestPlatform.AcceptanceTests/Extension/MSTestCompatibilityDataSource.cs +++ b/test/Microsoft.TestPlatform.AcceptanceTests/Extension/MSTestCompatibilityDataSource.cs @@ -5,7 +5,7 @@ namespace Microsoft.TestPlatform.AcceptanceTests; -public class MSTestCompatibilityDataSource : TestDataSource +public class MSTestCompatibilityDataSource : TestDataSourceAttribute { private readonly CompatibilityRowsBuilder _builder; diff --git a/test/Microsoft.TestPlatform.AcceptanceTests/Extension/NetCoreRunner.cs b/test/Microsoft.TestPlatform.AcceptanceTests/Extension/NetCoreRunnerAttribute.cs similarity index 93% rename from test/Microsoft.TestPlatform.AcceptanceTests/Extension/NetCoreRunner.cs rename to test/Microsoft.TestPlatform.AcceptanceTests/Extension/NetCoreRunnerAttribute.cs index 013ccc1be0..8f7afb2029 100644 --- a/test/Microsoft.TestPlatform.AcceptanceTests/Extension/NetCoreRunner.cs +++ b/test/Microsoft.TestPlatform.AcceptanceTests/Extension/NetCoreRunnerAttribute.cs @@ -19,7 +19,8 @@ namespace Microsoft.TestPlatform.AcceptanceTests; /// AcceptanceTestBase.NETFX452_NET50 = "net452;net472;net48;netcoreapp2.1;netcoreapp3.1;net5.0" to determine which target framework of the project /// to test. The target project must list those TFMs in the TargetFrameworks property in csproj. /// -public class NetCoreRunner : Attribute, ITestDataSource +[AttributeUsage(AttributeTargets.Method)] +public class NetCoreRunnerAttribute : Attribute, ITestDataSource { private readonly string _targetFrameworks; @@ -27,7 +28,7 @@ public class NetCoreRunner : Attribute, ITestDataSource /// Initializes a new instance of the class. /// /// To run tests with desktop runner(vstest.console.exe), use AcceptanceTestBase.Net452TargetFramework or alike values. - public NetCoreRunner(string targetFrameworks = AcceptanceTestBase.NETFX452_NET50) + public NetCoreRunnerAttribute(string targetFrameworks = AcceptanceTestBase.NETFX452_NET50) { _targetFrameworks = targetFrameworks; } diff --git a/test/Microsoft.TestPlatform.AcceptanceTests/Extension/NetCoreTargetFrameworkDataSource.cs b/test/Microsoft.TestPlatform.AcceptanceTests/Extension/NetCoreTargetFrameworkDataSourceAttribute.cs similarity index 95% rename from test/Microsoft.TestPlatform.AcceptanceTests/Extension/NetCoreTargetFrameworkDataSource.cs rename to test/Microsoft.TestPlatform.AcceptanceTests/Extension/NetCoreTargetFrameworkDataSourceAttribute.cs index dc274c9172..0c330e6c30 100644 --- a/test/Microsoft.TestPlatform.AcceptanceTests/Extension/NetCoreTargetFrameworkDataSource.cs +++ b/test/Microsoft.TestPlatform.AcceptanceTests/Extension/NetCoreTargetFrameworkDataSourceAttribute.cs @@ -18,7 +18,8 @@ namespace Microsoft.TestPlatform.AcceptanceTests; /// If runner framework is net46 then vstest.console.exe will run the tests. /// Second argument (target framework) = The framework for which test will run /// -public class NetCoreTargetFrameworkDataSource : Attribute, ITestDataSource +[AttributeUsage(AttributeTargets.Method)] +public class NetCoreTargetFrameworkDataSourceAttribute : Attribute, ITestDataSource { private readonly bool _useDesktopRunner; private readonly bool _useCoreRunner; @@ -26,11 +27,11 @@ public class NetCoreTargetFrameworkDataSource : Attribute, ITestDataSource private readonly bool _useNetCore31Target; /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// /// To run tests with desktop runner(vstest.console.exe) /// To run tests with core runner(dotnet vstest.console.dll) - public NetCoreTargetFrameworkDataSource( + public NetCoreTargetFrameworkDataSourceAttribute( bool useDesktopRunner = true, // adding another runner is not necessary until we need to start building against another // sdk, because the netcoreapp2.1 executable is forward compatible diff --git a/test/Microsoft.TestPlatform.AcceptanceTests/Extension/NetFrameworkRunner.cs b/test/Microsoft.TestPlatform.AcceptanceTests/Extension/NetFrameworkRunnerAttribute.cs similarity index 91% rename from test/Microsoft.TestPlatform.AcceptanceTests/Extension/NetFrameworkRunner.cs rename to test/Microsoft.TestPlatform.AcceptanceTests/Extension/NetFrameworkRunnerAttribute.cs index aebc4ba3e9..fea04b9356 100644 --- a/test/Microsoft.TestPlatform.AcceptanceTests/Extension/NetFrameworkRunner.cs +++ b/test/Microsoft.TestPlatform.AcceptanceTests/Extension/NetFrameworkRunnerAttribute.cs @@ -18,13 +18,14 @@ namespace Microsoft.TestPlatform.AcceptanceTests; /// AcceptanceTestBase.NETFX452_NET50 = "net452;net472;net48;netcoreapp2.1;netcoreapp3.1;net5.0" to determine which target framework of the project /// to test. The target project must list those TFMs in the TargetFrameworks property in csproj. /// -public class NetFrameworkRunner : Attribute, ITestDataSource +[AttributeUsage(AttributeTargets.Method)] +public class NetFrameworkRunnerAttribute : Attribute, ITestDataSource { /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// /// To run tests with desktop runner(vstest.console.exe), use AcceptanceTestBase.Net452TargetFramework or alike values. - public NetFrameworkRunner(string targetFrameworks = AcceptanceTestBase.NETFX452_NET50) + public NetFrameworkRunnerAttribute(string targetFrameworks = AcceptanceTestBase.NETFX452_NET50) { _targetFrameworks = targetFrameworks; } diff --git a/test/Microsoft.TestPlatform.AcceptanceTests/Extension/NetFullTargetFrameworkDataSource.cs b/test/Microsoft.TestPlatform.AcceptanceTests/Extension/NetFullTargetFrameworkDataSourceAttribute.cs similarity index 93% rename from test/Microsoft.TestPlatform.AcceptanceTests/Extension/NetFullTargetFrameworkDataSource.cs rename to test/Microsoft.TestPlatform.AcceptanceTests/Extension/NetFullTargetFrameworkDataSourceAttribute.cs index 808b48a1aa..10400d852a 100644 --- a/test/Microsoft.TestPlatform.AcceptanceTests/Extension/NetFullTargetFrameworkDataSource.cs +++ b/test/Microsoft.TestPlatform.AcceptanceTests/Extension/NetFullTargetFrameworkDataSourceAttribute.cs @@ -18,7 +18,8 @@ namespace Microsoft.TestPlatform.AcceptanceTests; /// If runner framework is net46 then vstest.console.exe will run the tests. /// Second argument (target framework) = The framework for which test will run /// -public class NetFullTargetFrameworkDataSource : Attribute, ITestDataSource +[AttributeUsage(AttributeTargets.Method)] +public class NetFullTargetFrameworkDataSourceAttribute : Attribute, ITestDataSource { private readonly bool _inIsolation; private readonly bool _inProcess; @@ -26,13 +27,13 @@ public class NetFullTargetFrameworkDataSource : Attribute, ITestDataSource private readonly bool _useCoreRunner; /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// /// Run test in isolation /// Run tests in process /// To run tests with desktop runner(vstest.console.exe) /// To run tests with core runner(dotnet vstest.console.dll) - public NetFullTargetFrameworkDataSource(bool inIsolation = true, bool inProcess = false, bool useDesktopRunner = true, bool useCoreRunner = true) + public NetFullTargetFrameworkDataSourceAttribute(bool inIsolation = true, bool inProcess = false, bool useDesktopRunner = true, bool useCoreRunner = true) { _inIsolation = inIsolation; _inProcess = inProcess; diff --git a/test/Microsoft.TestPlatform.AcceptanceTests/Extension/RunnerCompatibilityDataSource.cs b/test/Microsoft.TestPlatform.AcceptanceTests/Extension/RunnerCompatibilityDataSource.cs index 026afa38b8..6dc008c732 100644 --- a/test/Microsoft.TestPlatform.AcceptanceTests/Extension/RunnerCompatibilityDataSource.cs +++ b/test/Microsoft.TestPlatform.AcceptanceTests/Extension/RunnerCompatibilityDataSource.cs @@ -10,7 +10,7 @@ namespace Microsoft.TestPlatform.AcceptanceTests; /// /// When that adds up to no configuration exception is thrown. /// -public class RunnerCompatibilityDataSource : TestDataSource +public class RunnerCompatibilityDataSource : TestDataSourceAttribute { private readonly CompatibilityRowsBuilder _builder; diff --git a/test/Microsoft.TestPlatform.AcceptanceTests/Extension/TestDataSource.cs b/test/Microsoft.TestPlatform.AcceptanceTests/Extension/TestDataSourceAttribute.cs similarity index 90% rename from test/Microsoft.TestPlatform.AcceptanceTests/Extension/TestDataSource.cs rename to test/Microsoft.TestPlatform.AcceptanceTests/Extension/TestDataSourceAttribute.cs index d041d36e79..6f7a6adae2 100644 --- a/test/Microsoft.TestPlatform.AcceptanceTests/Extension/TestDataSource.cs +++ b/test/Microsoft.TestPlatform.AcceptanceTests/Extension/TestDataSourceAttribute.cs @@ -10,7 +10,7 @@ namespace Microsoft.TestPlatform.AcceptanceTests; [AttributeUsage(AttributeTargets.Method)] -public abstract class TestDataSource : Attribute, ITestDataSource where T1 : notnull +public abstract class TestDataSourceAttribute : Attribute, ITestDataSource where T1 : notnull { private readonly List _data = new(); @@ -39,7 +39,7 @@ string ITestDataSource.GetDisplayName(MethodInfo methodInfo, object[] data) } [AttributeUsage(AttributeTargets.Method)] -public abstract class TestDataSource : Attribute, ITestDataSource +public abstract class TestDataSourceAttribute : Attribute, ITestDataSource where T1 : notnull where T2 : notnull { @@ -70,7 +70,7 @@ string ITestDataSource.GetDisplayName(MethodInfo methodInfo, object[] data) } [AttributeUsage(AttributeTargets.Method)] -public abstract class TestDataSource : Attribute, ITestDataSource +public abstract class TestDataSourceAttribute : Attribute, ITestDataSource where T1 : notnull where T2 : notnull where T3 : notnull @@ -102,7 +102,7 @@ string ITestDataSource.GetDisplayName(MethodInfo methodInfo, object[] data) } [AttributeUsage(AttributeTargets.Method)] -public abstract class TestDataSource : Attribute, ITestDataSource +public abstract class TestDataSourceAttribute : Attribute, ITestDataSource where T1 : notnull where T2 : notnull where T3 : notnull diff --git a/test/Microsoft.TestPlatform.AcceptanceTests/Extension/TestPlatformCompatibilityDataSource.cs b/test/Microsoft.TestPlatform.AcceptanceTests/Extension/TestPlatformCompatibilityDataSource.cs index 95c0e290d6..7836809f8e 100644 --- a/test/Microsoft.TestPlatform.AcceptanceTests/Extension/TestPlatformCompatibilityDataSource.cs +++ b/test/Microsoft.TestPlatform.AcceptanceTests/Extension/TestPlatformCompatibilityDataSource.cs @@ -22,7 +22,7 @@ namespace Microsoft.TestPlatform.AcceptanceTests; /// /// When that adds up to no configuration exception is thrown. /// -public class TestPlatformCompatibilityDataSource : TestDataSource +public class TestPlatformCompatibilityDataSource : TestDataSourceAttribute { private readonly CompatibilityRowsBuilder _builder; diff --git a/test/Microsoft.TestPlatform.AcceptanceTests/Extension/TesthostCompatibilityDataSource.cs b/test/Microsoft.TestPlatform.AcceptanceTests/Extension/TesthostCompatibilityDataSource.cs index 2af3e23e5d..70db6ca909 100644 --- a/test/Microsoft.TestPlatform.AcceptanceTests/Extension/TesthostCompatibilityDataSource.cs +++ b/test/Microsoft.TestPlatform.AcceptanceTests/Extension/TesthostCompatibilityDataSource.cs @@ -10,7 +10,7 @@ namespace Microsoft.TestPlatform.AcceptanceTests; /// /// When that adds up to no configuration exception is thrown. /// -public class TestHostCompatibilityDataSource : TestDataSource +public class TestHostCompatibilityDataSource : TestDataSourceAttribute { private readonly CompatibilityRowsBuilder _builder; diff --git a/test/Microsoft.TestPlatform.AcceptanceTests/RunsettingsTests.cs b/test/Microsoft.TestPlatform.AcceptanceTests/RunsettingsTests.cs index 9faee78ca9..cd90ac8cce 100644 --- a/test/Microsoft.TestPlatform.AcceptanceTests/RunsettingsTests.cs +++ b/test/Microsoft.TestPlatform.AcceptanceTests/RunsettingsTests.cs @@ -238,7 +238,7 @@ public void RunSettingsWithParallelAndPlatformX64(RunnerInfo runnerInfo) } [TestMethod] - [NetFullTargetFrameworkDataSource(inIsolation: true, inProcess: true)] + [NetFullTargetFrameworkDataSourceAttribute(inIsolation: true, inProcess: true)] [NetCoreTargetFrameworkDataSource] public void RunSettingsWithInvalidValueShouldLogError(RunnerInfo runnerInfo) { @@ -259,7 +259,7 @@ public void RunSettingsWithInvalidValueShouldLogError(RunnerInfo runnerInfo) } [TestMethod] - [NetFullTargetFrameworkDataSource(inIsolation: true, inProcess: true)] + [NetFullTargetFrameworkDataSourceAttribute(inIsolation: true, inProcess: true)] [NetCoreTargetFrameworkDataSource] public void TestAdapterPathFromRunSettings(RunnerInfo runnerInfo) { @@ -283,7 +283,7 @@ public void TestAdapterPathFromRunSettings(RunnerInfo runnerInfo) [TestMethod] [TestCategory("Windows-Review")] - [NetFullTargetFrameworkDataSource(inIsolation: true, useCoreRunner: false)] + [NetFullTargetFrameworkDataSourceAttribute(inIsolation: true, useCoreRunner: false)] public void LegacySettingsWithPlatform(RunnerInfo runnerInfo) { SetTestEnvironment(_testEnvironment, runnerInfo); @@ -314,7 +314,7 @@ public void LegacySettingsWithPlatform(RunnerInfo runnerInfo) [TestMethod] [TestCategory("Windows-Review")] - [NetFullTargetFrameworkDataSource(inIsolation: true, useCoreRunner: false)] + [NetFullTargetFrameworkDataSourceAttribute(inIsolation: true, useCoreRunner: false)] public void LegacySettingsWithScripts(RunnerInfo runnerInfo) { SetTestEnvironment(_testEnvironment, runnerInfo); @@ -360,7 +360,7 @@ public void LegacySettingsWithScripts(RunnerInfo runnerInfo) [TestMethod] [TestCategory("Windows-Review")] - [NetFullTargetFrameworkDataSource(inIsolation: true, useCoreRunner: false)] + [NetFullTargetFrameworkDataSourceAttribute(inIsolation: true, useCoreRunner: false)] public void LegacySettingsWithDeploymentItem(RunnerInfo runnerInfo) { SetTestEnvironment(_testEnvironment, runnerInfo); @@ -397,7 +397,7 @@ public void LegacySettingsWithDeploymentItem(RunnerInfo runnerInfo) [TestMethod] [TestCategory("Windows")] - [NetFullTargetFrameworkDataSource(inIsolation: true, useCoreRunner: false)] + [NetFullTargetFrameworkDataSourceAttribute(inIsolation: true, useCoreRunner: false)] public void LegacySettingsTestTimeout(RunnerInfo runnerInfo) { SetTestEnvironment(_testEnvironment, runnerInfo); @@ -424,7 +424,7 @@ public void LegacySettingsTestTimeout(RunnerInfo runnerInfo) [TestMethod] [TestCategory("Windows-Review")] - [NetFullTargetFrameworkDataSource(inIsolation: true, useCoreRunner: false)] + [NetFullTargetFrameworkDataSourceAttribute(inIsolation: true, useCoreRunner: false)] public void LegacySettingsAssemblyResolution(RunnerInfo runnerInfo) { SetTestEnvironment(_testEnvironment, runnerInfo); @@ -505,8 +505,8 @@ public void EnvironmentVariablesSettingsShouldSetEnvironmentVariables(RunnerInfo [TestMethod] // patched dotnet is not published on non-windows systems [TestCategory("Windows-Review")] - [NetFullTargetFrameworkDataSource(useDesktopRunner: false)] - [NetCoreTargetFrameworkDataSource(useDesktopRunner: false)] + [NetFullTargetFrameworkDataSourceAttribute(useDesktopRunner: false)] + [NetCoreTargetFrameworkDataSourceAttribute(useDesktopRunner: false)] public void RunSettingsAreLoadedFromProject(RunnerInfo runnerInfo) { SetTestEnvironment(_testEnvironment, runnerInfo); diff --git a/test/Microsoft.TestPlatform.AcceptanceTests/SelfContainedAppTests.cs b/test/Microsoft.TestPlatform.AcceptanceTests/SelfContainedAppTests.cs index daf371507c..3e72203f31 100644 --- a/test/Microsoft.TestPlatform.AcceptanceTests/SelfContainedAppTests.cs +++ b/test/Microsoft.TestPlatform.AcceptanceTests/SelfContainedAppTests.cs @@ -15,7 +15,7 @@ public class SelfContainedAppTests : AcceptanceTestBase [TestCategory("Windows-Review")] // this is core 3.1 only, full framework and netcoreapp2.1 don't "publish" automatically during build // but if you run it on 2.1 it will pass because we execute the test normally - [NetCoreTargetFrameworkDataSource(useDesktopRunner: false, useNetCore21Target: false, useNetCore31Target: true)] + [NetCoreTargetFrameworkDataSourceAttribute(useDesktopRunner: false, useNetCore21Target: false, useNetCore31Target: true)] public void RunningApplicationThatIsBuiltAsSelfContainedWillNotFailToFindHostpolicyDll(RunnerInfo runnerInfo) { // when the application is self-contained which is dictated by the RuntimeIdentifier and OutputType project diff --git a/test/Microsoft.TestPlatform.AcceptanceTests/TelemetryTests.cs b/test/Microsoft.TestPlatform.AcceptanceTests/TelemetryTests.cs index f95f694349..33efe78895 100644 --- a/test/Microsoft.TestPlatform.AcceptanceTests/TelemetryTests.cs +++ b/test/Microsoft.TestPlatform.AcceptanceTests/TelemetryTests.cs @@ -20,7 +20,7 @@ public class TelemetryTests : AcceptanceTestBase private const string LOG_TELEMETRY_PATH = "VSTEST_LOGTELEMETRY_PATH"; [TestMethod] - [NetFullTargetFrameworkDataSource(inIsolation: true, inProcess: true)] + [NetFullTargetFrameworkDataSourceAttribute(inIsolation: true, inProcess: true)] [NetCoreTargetFrameworkDataSource] public void RunTestsShouldPublishMetrics(RunnerInfo runnerInfo) { @@ -30,7 +30,7 @@ public void RunTestsShouldPublishMetrics(RunnerInfo runnerInfo) } [TestMethod] - [NetFullTargetFrameworkDataSource(inIsolation: true, inProcess: true)] + [NetFullTargetFrameworkDataSourceAttribute(inIsolation: true, inProcess: true)] [NetCoreTargetFrameworkDataSource] public void DiscoverTestsShouldPublishMetrics(RunnerInfo runnerInfo) { diff --git a/test/Microsoft.TestPlatform.AcceptanceTests/TestCaseFilterTests.cs b/test/Microsoft.TestPlatform.AcceptanceTests/TestCaseFilterTests.cs index 5175b1b24b..e5e451ddd4 100644 --- a/test/Microsoft.TestPlatform.AcceptanceTests/TestCaseFilterTests.cs +++ b/test/Microsoft.TestPlatform.AcceptanceTests/TestCaseFilterTests.cs @@ -12,7 +12,7 @@ namespace Microsoft.TestPlatform.AcceptanceTests; public class TestCaseFilterTests : AcceptanceTestBase { [TestMethod] - [NetFullTargetFrameworkDataSource(inIsolation: true, inProcess: true)] + [NetFullTargetFrameworkDataSourceAttribute(inIsolation: true, inProcess: true)] [NetCoreTargetFrameworkDataSource] public void RunSelectedTestsWithAndOperatorTrait(RunnerInfo runnerInfo) { diff --git a/test/Microsoft.TestPlatform.AcceptanceTests/TestPlatformNugetPackageTests.cs b/test/Microsoft.TestPlatform.AcceptanceTests/TestPlatformNugetPackageTests.cs index e0aac0c9e0..20cc9c45d3 100644 --- a/test/Microsoft.TestPlatform.AcceptanceTests/TestPlatformNugetPackageTests.cs +++ b/test/Microsoft.TestPlatform.AcceptanceTests/TestPlatformNugetPackageTests.cs @@ -43,8 +43,8 @@ public static void ClassCleanup() [TestMethod] [TestCategory("Windows-Review")] - [NetFullTargetFrameworkDataSource(useCoreRunner: false)] - [NetCoreTargetFrameworkDataSource(useCoreRunner: false)] + [NetFullTargetFrameworkDataSourceAttribute(useCoreRunner: false)] + [NetCoreTargetFrameworkDataSourceAttribute(useCoreRunner: false)] public void RunMultipleTestAssembliesWithCodeCoverage(RunnerInfo runnerInfo) { SetTestEnvironment(_testEnvironment, runnerInfo); diff --git a/test/Microsoft.TestPlatform.AcceptanceTests/TranslationLayerTests/CodeCoverageTests.cs b/test/Microsoft.TestPlatform.AcceptanceTests/TranslationLayerTests/CodeCoverageTests.cs index 5f2a28d2be..ba26081948 100644 --- a/test/Microsoft.TestPlatform.AcceptanceTests/TranslationLayerTests/CodeCoverageTests.cs +++ b/test/Microsoft.TestPlatform.AcceptanceTests/TranslationLayerTests/CodeCoverageTests.cs @@ -114,13 +114,13 @@ public void TestRunWithCodeCoverageParallel(RunnerInfo runnerInfo) } [TestMethod] - [NetFullTargetFrameworkDataSource()] + [NetFullTargetFrameworkDataSource] [NetCoreTargetFrameworkDataSource] public async Task TestRunWithCodeCoverageAndAttachmentsProcessingWithInvokedDataCollectors(RunnerInfo runnerInfo) => await TestRunWithCodeCoverageAndAttachmentsProcessingInternal(runnerInfo, true); [TestMethod] - [NetFullTargetFrameworkDataSource()] + [NetFullTargetFrameworkDataSource] [NetCoreTargetFrameworkDataSource] public async Task TestRunWithCodeCoverageAndAttachmentsProcessingWithoutInvokedDataCollectors(RunnerInfo runnerInfo) => await TestRunWithCodeCoverageAndAttachmentsProcessingInternal(runnerInfo, false); diff --git a/test/Microsoft.TestPlatform.AcceptanceTests/TranslationLayerTests/DiscoverTests.cs b/test/Microsoft.TestPlatform.AcceptanceTests/TranslationLayerTests/DiscoverTests.cs index fed95f1ba7..eb9b078493 100644 --- a/test/Microsoft.TestPlatform.AcceptanceTests/TranslationLayerTests/DiscoverTests.cs +++ b/test/Microsoft.TestPlatform.AcceptanceTests/TranslationLayerTests/DiscoverTests.cs @@ -62,7 +62,7 @@ public void DiscoverTestsUsingDiscoveryEventHandler1(RunnerInfo runnerInfo) [TestMethod] [TestCategory("Windows-Review")] - [RunnerCompatibilityDataSource()] + [RunnerCompatibilityDataSource] public void DiscoverTestsUsingDiscoveryEventHandler2AndTelemetryOptedOut(RunnerInfo runnerInfo) { SetTestEnvironment(_testEnvironment, runnerInfo); diff --git a/test/Microsoft.TestPlatform.AcceptanceTests/TranslationLayerTests/EventHandler/TestRunAttachmentsProcessingEventHandler.cs b/test/Microsoft.TestPlatform.AcceptanceTests/TranslationLayerTests/EventHandler/TestRunAttachmentsProcessingEventHandler.cs index ca3b598f8d..b862143985 100644 --- a/test/Microsoft.TestPlatform.AcceptanceTests/TranslationLayerTests/EventHandler/TestRunAttachmentsProcessingEventHandler.cs +++ b/test/Microsoft.TestPlatform.AcceptanceTests/TranslationLayerTests/EventHandler/TestRunAttachmentsProcessingEventHandler.cs @@ -68,7 +68,7 @@ public int LaunchProcessWithDebuggerAttached(TestProcessStartInfo _) return -1; } - public bool AttachDebuggerToProcess(int pid) + public bool AttachDebuggerToProcess(int _) { // No op return true; diff --git a/test/Microsoft.TestPlatform.AcceptanceTests/TranslationLayerTests/RunTests.cs b/test/Microsoft.TestPlatform.AcceptanceTests/TranslationLayerTests/RunTests.cs index 7210608c65..ef7f030edf 100644 --- a/test/Microsoft.TestPlatform.AcceptanceTests/TranslationLayerTests/RunTests.cs +++ b/test/Microsoft.TestPlatform.AcceptanceTests/TranslationLayerTests/RunTests.cs @@ -205,8 +205,8 @@ public void RunTestsShouldThrowOnStackOverflowException(RunnerInfo runnerInfo) [TestMethod] [TestCategory("Windows-Review")] - [NetFullTargetFrameworkDataSource(useCoreRunner: false)] - [NetCoreTargetFrameworkDataSource(useCoreRunner: false)] + [NetFullTargetFrameworkDataSourceAttribute(useCoreRunner: false)] + [NetCoreTargetFrameworkDataSourceAttribute(useCoreRunner: false)] public void RunTestsShouldShowProperWarningOnNoTestsForTestCaseFilter(RunnerInfo runnerInfo) { SetTestEnvironment(_testEnvironment, runnerInfo); diff --git a/test/Microsoft.TestPlatform.AdapterUtilities.UnitTests/ManagedNameUtilities/ManagedNameRoundTripTests.cs b/test/Microsoft.TestPlatform.AdapterUtilities.UnitTests/ManagedNameUtilities/ManagedNameRoundTripTests.cs index 657fba5549..6f659f01e9 100644 --- a/test/Microsoft.TestPlatform.AdapterUtilities.UnitTests/ManagedNameUtilities/ManagedNameRoundTripTests.cs +++ b/test/Microsoft.TestPlatform.AdapterUtilities.UnitTests/ManagedNameUtilities/ManagedNameRoundTripTests.cs @@ -1,6 +1,7 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. +using System.Diagnostics.CodeAnalysis; using System.IO; using System.Linq; using System.Reflection; @@ -818,6 +819,7 @@ public void Overloads18() } #region Helpers + [SuppressMessage("Style", "IDE0060:Remove unused parameter", Justification = "Code using the parameters is commented out temporarly.")] private static void VerifyRoundTrip( MethodInfo methodInfo, INamedTypeSymbol containingTypeSymbol, @@ -827,6 +829,7 @@ private static void VerifyRoundTrip( { VerifyRoundTripFromMethodInfo(methodInfo, managedTypeName, managedMethodName); VerifyRoundTripFromName(managedTypeName, managedMethodName, methodInfo); + // TODO: Enable these checks and remove attributes on method // VerifyRoundTripFromMethodSymbol(containingTypeSymbol, methodSymbol, managedTypeName, managedMethodName); // VerifyRoundTripFromName(managedTypeName, managedMethodName, containingTypeSymbol, methodSymbol); } diff --git a/test/Microsoft.TestPlatform.Common.UnitTests/Utilities/FakesUtilitiesTests.cs b/test/Microsoft.TestPlatform.Common.UnitTests/Utilities/FakesUtilitiesTests.cs index a3b2a51f8f..1b1b598cdc 100644 --- a/test/Microsoft.TestPlatform.Common.UnitTests/Utilities/FakesUtilitiesTests.cs +++ b/test/Microsoft.TestPlatform.Common.UnitTests/Utilities/FakesUtilitiesTests.cs @@ -25,7 +25,7 @@ public void FakesSettingsShouldThrowExceptionIfSourcesArePassedAsNull() [TestMethod] public void FakesSettingsShouldThrowExceptionIfRunSettingsIsPassedAsNull() { - Assert.ThrowsException(() => FakesUtilities.GenerateFakesSettingsForRunConfiguration(new string[] { }, null!)); + Assert.ThrowsException(() => FakesUtilities.GenerateFakesSettingsForRunConfiguration(Array.Empty(), null!)); } [TestMethod] diff --git a/test/Microsoft.TestPlatform.CommunicationUtilities.UnitTests/TestRequestSenderTests.cs b/test/Microsoft.TestPlatform.CommunicationUtilities.UnitTests/TestRequestSenderTests.cs index 826ab805fb..45e2a7b475 100644 --- a/test/Microsoft.TestPlatform.CommunicationUtilities.UnitTests/TestRequestSenderTests.cs +++ b/test/Microsoft.TestPlatform.CommunicationUtilities.UnitTests/TestRequestSenderTests.cs @@ -302,7 +302,7 @@ public void InitializeDiscoveryShouldSendCommunicationMessageWithCorrectParamete [TestMethod] public void InitializeDiscoveryShouldSendCommunicationMessageWithCorrectParametersWithVersion() { - SetupFakeChannelWithVersionNegotiation(Dummynegotiatedprotocolversion); + SetupFakeChannelWithVersionNegotiation(); _testRequestSender.InitializeDiscovery(_pathToAdditionalExtensions); @@ -325,7 +325,7 @@ public void DiscoverTestsShouldSendStartDiscoveryMessageOnChannel() [TestMethod] public void DiscoverTestsShouldSendStartDiscoveryMessageOnChannelWithVersion() { - SetupFakeChannelWithVersionNegotiation(Dummynegotiatedprotocolversion); + SetupFakeChannelWithVersionNegotiation(); _testRequestSender.DiscoverTests(new DiscoveryCriteria(), _mockDiscoveryEventsHandler.Object); @@ -498,7 +498,7 @@ public void InitializeExecutionShouldSendCommunicationMessageWithCorrectParamete [TestMethod] public void InitializeExecutionShouldSendCommunicationMessageWithCorrectParametersWithVersion() { - SetupFakeChannelWithVersionNegotiation(Dummynegotiatedprotocolversion); + SetupFakeChannelWithVersionNegotiation(); _testRequestSender.InitializeExecution(_pathToAdditionalExtensions); @@ -519,7 +519,7 @@ public void StartTestRunShouldSendStartTestExecutionWithSourcesOnChannel() [TestMethod] public void StartTestRunShouldSendStartTestExecutionWithSourcesOnChannelWithVersion() { - SetupFakeChannelWithVersionNegotiation(Dummynegotiatedprotocolversion); + SetupFakeChannelWithVersionNegotiation(); _testRequestSender.StartTestRun(_testRunCriteriaWithSources, _mockExecutionEventsHandler.Object); @@ -542,7 +542,7 @@ public void StartTestRunWithTestsShouldSendStartTestExecutionWithTestsOnChannel( public void StartTestRunWithTestsShouldSendStartTestExecutionWithTestsOnChannelWithVersion() { var runCriteria = new TestRunCriteriaWithTests(new TestCase[2], "runsettings", null, null!); - SetupFakeChannelWithVersionNegotiation(Dummynegotiatedprotocolversion); + SetupFakeChannelWithVersionNegotiation(); _testRequestSender.StartTestRun(runCriteria, _mockExecutionEventsHandler.Object); @@ -664,7 +664,7 @@ public void StartTestRunShouldSendLaunchDebuggerAttachedCallbackOnMessageReceive public void StartTestRunShouldSendLaunchDebuggerAttachedCallbackOnMessageReceivedWithVersion() { var launchMessagePayload = new TestProcessStartInfo(); - SetupFakeChannelWithVersionNegotiation(Dummynegotiatedprotocolversion); + SetupFakeChannelWithVersionNegotiation(); SetupDeserializeMessage(MessageType.LaunchAdapterProcessWithDebuggerAttached, launchMessagePayload); _testRequestSender.StartTestRun(_testRunCriteriaWithSources, _mockExecutionEventsHandler.Object); @@ -799,7 +799,7 @@ private string SetupFakeCommunicationChannel(string connectionArgs = "123") return _testRequestSender.InitializeCommunication().ToString(); } - private void SetupFakeChannelWithVersionNegotiation(int protocolVersion) + private void SetupFakeChannelWithVersionNegotiation() { // Sends a check version message to setup the negotiated protocol version. // This method is only required in specific tests. diff --git a/test/Microsoft.TestPlatform.CoreUtilities.UnitTests/Helpers/CommandLineArgumentsHelperTests.cs b/test/Microsoft.TestPlatform.CoreUtilities.UnitTests/Helpers/CommandLineArgumentsHelperTests.cs index dbb9abb8a9..7f9b7cf5f0 100644 --- a/test/Microsoft.TestPlatform.CoreUtilities.UnitTests/Helpers/CommandLineArgumentsHelperTests.cs +++ b/test/Microsoft.TestPlatform.CoreUtilities.UnitTests/Helpers/CommandLineArgumentsHelperTests.cs @@ -81,7 +81,7 @@ public void GetArgumentsDictionaryShouldReturnEmptyDictionaryIfEmptyArgIsPassed( var argsDictionary = CommandLineArgumentsHelper.GetArgumentsDictionary(null); Assert.IsTrue(argsDictionary.Count == 0); - argsDictionary = CommandLineArgumentsHelper.GetArgumentsDictionary(new string[] { }); + argsDictionary = CommandLineArgumentsHelper.GetArgumentsDictionary(System.Array.Empty()); Assert.IsTrue(argsDictionary.Count == 0); } diff --git a/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Adapter/FrameworkHandleTests.cs b/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Adapter/FrameworkHandleTests.cs index 766f517a3e..504ee4a33f 100644 --- a/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Adapter/FrameworkHandleTests.cs +++ b/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Adapter/FrameworkHandleTests.cs @@ -47,8 +47,8 @@ public void LaunchProcessWithDebuggerAttachedShouldThrowIfObjectIsDisposed() Assert.ThrowsException(() => frameworkHandle.LaunchProcessWithDebuggerAttached(null!, null!, null!, null!)); } - // TODO: Enable method once we fix the "IsDebug" in TestExecutionContext - // [TestMethod] + [TestMethod] + [Ignore("TODO: Enable method once we fix the \"IsDebug\" in TestExecutionContext")] public void LaunchProcessWithDebuggerAttachedShouldThrowIfNotInDebugContext() { var tec = GetTestExecutionContext(); diff --git a/test/Microsoft.TestPlatform.Extensions.BlameDataCollector.UnitTests/ProcessDumpUtilityTests.cs b/test/Microsoft.TestPlatform.Extensions.BlameDataCollector.UnitTests/ProcessDumpUtilityTests.cs index 4594ee1beb..629b94f369 100644 --- a/test/Microsoft.TestPlatform.Extensions.BlameDataCollector.UnitTests/ProcessDumpUtilityTests.cs +++ b/test/Microsoft.TestPlatform.Extensions.BlameDataCollector.UnitTests/ProcessDumpUtilityTests.cs @@ -44,7 +44,7 @@ public void GetDumpFileWillThrowExceptionIfNoDumpfile() var testResultsDirectory = "D:\\TestResults"; _mockFileHelper.Setup(x => x.GetFiles(It.IsAny(), It.IsAny(), It.IsAny())) - .Returns(new string[] { }); + .Returns(System.Array.Empty()); _mockProcessHelper.Setup(x => x.GetProcessName(processId)) .Returns(process); diff --git a/test/Microsoft.TestPlatform.PerformanceTests/TranslationLayer/TelemetryPerfTestBase.cs b/test/Microsoft.TestPlatform.PerformanceTests/TranslationLayer/TelemetryPerfTestBase.cs index 77b6fd9cdc..a4605a44ae 100644 --- a/test/Microsoft.TestPlatform.PerformanceTests/TranslationLayer/TelemetryPerfTestBase.cs +++ b/test/Microsoft.TestPlatform.PerformanceTests/TranslationLayer/TelemetryPerfTestBase.cs @@ -89,7 +89,7 @@ public void PostTelemetry(IDictionary handlerMetrics, PerfAnalyz _client.Flush(); } - private string GetAdapterName(string projectName) + private static string GetAdapterName(string projectName) { var name = projectName.ToLowerInvariant(); if (name.Contains("xunit")) @@ -116,12 +116,9 @@ private string GetAdapterName(string projectName) public string[] GetPerfAssetFullPath(string name, string framework = "net6.0") { var dllPath = Path.Combine(_rootDirectory, "test", "TestAssets", "performance", name, "bin", BuildConfiguration, framework, $"{name}.dll"); - if (!File.Exists(dllPath)) - { - throw new FileNotFoundException(null, dllPath); - } - - return new[] { dllPath }; + return !File.Exists(dllPath) + ? throw new FileNotFoundException(null, dllPath) + : new[] { dllPath }; } /// diff --git a/test/Microsoft.TestPlatform.Utilities.UnitTests/CommandLineUtilitiesTest.cs b/test/Microsoft.TestPlatform.Utilities.UnitTests/CommandLineUtilitiesTest.cs index eca85d9705..30789efec3 100644 --- a/test/Microsoft.TestPlatform.Utilities.UnitTests/CommandLineUtilitiesTest.cs +++ b/test/Microsoft.TestPlatform.Utilities.UnitTests/CommandLineUtilitiesTest.cs @@ -24,7 +24,7 @@ private static void VerifyCommandLineSplitter(string commandLine, string[] expec [TestMethod] public void TestCommandLineSplitter() { - VerifyCommandLineSplitter("", new string[0]); + VerifyCommandLineSplitter("", System.Array.Empty()); VerifyCommandLineSplitter("/testadapterpath:\"c:\\Path\"", new[] { @"/testadapterpath:c:\Path" }); VerifyCommandLineSplitter("/testadapterpath:\"c:\\Path\" /logger:\"trx\"", new[] { @"/testadapterpath:c:\Path", "/logger:trx" }); VerifyCommandLineSplitter("/testadapterpath:\"c:\\Path\" /logger:\"trx\" /diag:\"log.txt\"", new[] { @"/testadapterpath:c:\Path", "/logger:trx", "/diag:log.txt" }); diff --git a/test/SettingsMigrator.UnitTests/PathResolverTests.cs b/test/SettingsMigrator.UnitTests/PathResolverTests.cs index ab80e10019..c1becbad8b 100644 --- a/test/SettingsMigrator.UnitTests/PathResolverTests.cs +++ b/test/SettingsMigrator.UnitTests/PathResolverTests.cs @@ -22,7 +22,7 @@ public PathResolverTests() [TestMethod] public void PathResolverShouldReturnNullForEmptyArguments() { - var newFilePath = _pathResolver.GetTargetPath(new string[] { }); + var newFilePath = _pathResolver.GetTargetPath(Array.Empty()); Assert.IsNull(newFilePath, "Empty arguments should return null"); } diff --git a/test/SettingsMigrator.UnitTests/ProgramTests.cs b/test/SettingsMigrator.UnitTests/ProgramTests.cs index 8afeb3462f..5025e97963 100644 --- a/test/SettingsMigrator.UnitTests/ProgramTests.cs +++ b/test/SettingsMigrator.UnitTests/ProgramTests.cs @@ -18,7 +18,7 @@ public void MoreThanTwoArgumentsShouldNotBeAccepted() [TestMethod] public void NoArgumentsShouldNotBeAccepted() { - int returnCode = Program.Main(new string[] { }); + int returnCode = Program.Main(System.Array.Empty()); Assert.AreEqual(1, returnCode, "No arguments should not be accepted."); } } diff --git a/test/TestAssets/BlameUnitTestProject/Program.cs b/test/TestAssets/BlameUnitTestProject/Program.cs index 8cd953b668..1c8140cd25 100644 --- a/test/TestAssets/BlameUnitTestProject/Program.cs +++ b/test/TestAssets/BlameUnitTestProject/Program.cs @@ -5,7 +5,7 @@ namespace BlameUnitTestProject { public class Program { - public static void Main(string[] args) + public static void Main() { } diff --git a/test/TestAssets/ConsoleManagedApp/Program.cs b/test/TestAssets/ConsoleManagedApp/Program.cs index 1c0542b084..566447dfac 100644 --- a/test/TestAssets/ConsoleManagedApp/Program.cs +++ b/test/TestAssets/ConsoleManagedApp/Program.cs @@ -7,7 +7,7 @@ namespace ConsoleManagedApp { class Program { - static void Main(string[] args) + static void Main() { Console.WriteLine("Hello World!"); } diff --git a/test/TestAssets/MultitargetedNetFrameworkProject/UnitTest1.cs b/test/TestAssets/MultitargetedNetFrameworkProject/UnitTest1.cs index 35a6b30809..7c34d745c0 100644 --- a/test/TestAssets/MultitargetedNetFrameworkProject/UnitTest1.cs +++ b/test/TestAssets/MultitargetedNetFrameworkProject/UnitTest1.cs @@ -2,11 +2,6 @@ // Licensed under the MIT license. See LICENSE file in the project root for full license information. using System; -using System.Diagnostics; -using System.IO; -using System.Linq; -using System.Net.Security; -using System.Security.Authentication; using Xunit; diff --git a/test/TestAssets/SimpleClassLibrary/Class1.cs b/test/TestAssets/SimpleClassLibrary/Class1.cs index 2637b19106..a967b82aaf 100644 --- a/test/TestAssets/SimpleClassLibrary/Class1.cs +++ b/test/TestAssets/SimpleClassLibrary/Class1.cs @@ -21,7 +21,7 @@ public void OverLoadedMethod() { } - public void OverLoadedMethod(string name) + public void OverLoadedMethod(string _) { } } diff --git a/test/TestAssets/SimpleTestProject2/Program.cs b/test/TestAssets/SimpleTestProject2/Program.cs index 80615b0898..2c0d24fe72 100644 --- a/test/TestAssets/SimpleTestProject2/Program.cs +++ b/test/TestAssets/SimpleTestProject2/Program.cs @@ -5,7 +5,7 @@ namespace SimpleTestProject2 { public class Program { - public static void Main(string[] args) + public static void Main() { } diff --git a/test/TestAssets/SimpleTestProjectARM/Program.cs b/test/TestAssets/SimpleTestProjectARM/Program.cs index 72a9860cf2..70cc25dce4 100644 --- a/test/TestAssets/SimpleTestProjectARM/Program.cs +++ b/test/TestAssets/SimpleTestProjectARM/Program.cs @@ -5,7 +5,7 @@ namespace SimpleTestProjectARM { public class Program { - public static void Main(string[] args) + public static void Main() { } } diff --git a/test/TestAssets/SimpleTestProjectx86/Program.cs b/test/TestAssets/SimpleTestProjectx86/Program.cs index 8988f8c442..96bdb5fda2 100644 --- a/test/TestAssets/SimpleTestProjectx86/Program.cs +++ b/test/TestAssets/SimpleTestProjectx86/Program.cs @@ -5,7 +5,7 @@ namespace SimpleTestProjectx86 { public class Program { - public static void Main(string[] args) + public static void Main() { } diff --git a/test/TestAssets/performance/MSTest1000Passing/MSTests.cs b/test/TestAssets/performance/MSTest1000Passing/MSTests.cs index 7f91cce1ce..d896ce5180 100644 --- a/test/TestAssets/performance/MSTest1000Passing/MSTests.cs +++ b/test/TestAssets/performance/MSTest1000Passing/MSTests.cs @@ -1,5 +1,4 @@ -using System; -using Microsoft.VisualStudio.TestTools.UnitTesting; +using Microsoft.VisualStudio.TestTools.UnitTesting; namespace Tests { @@ -5453,5 +5452,4 @@ public void Test_50_20() #region FailingTests #endregion } - } diff --git a/test/TestAssets/performance/MSTest1000Passing/MSTests.tt b/test/TestAssets/performance/MSTest1000Passing/MSTests.tt index ded935b7e9..dfbb3afc54 100644 --- a/test/TestAssets/performance/MSTest1000Passing/MSTests.tt +++ b/test/TestAssets/performance/MSTest1000Passing/MSTests.tt @@ -1,5 +1,4 @@ -using System; -using Microsoft.VisualStudio.TestTools.UnitTesting; +using Microsoft.VisualStudio.TestTools.UnitTesting; namespace Tests { @@ -30,7 +29,7 @@ namespace Tests { } -<# +<# } #> #endregion @@ -46,12 +45,12 @@ namespace Tests { Assert.Fail(); } -<# +<# } #> #endregion } -<# +<# } -#> +#> } diff --git a/test/TestAssets/performance/MSTest100Passing/MSTests.cs b/test/TestAssets/performance/MSTest100Passing/MSTests.cs index 56513682e3..0820bf071a 100644 --- a/test/TestAssets/performance/MSTest100Passing/MSTests.cs +++ b/test/TestAssets/performance/MSTest100Passing/MSTests.cs @@ -1,5 +1,4 @@ -using System; -using Microsoft.VisualStudio.TestTools.UnitTesting; +using Microsoft.VisualStudio.TestTools.UnitTesting; namespace Tests { @@ -548,5 +547,4 @@ public void Test_05_20() #region FailingTests #endregion } - } diff --git a/test/TestAssets/performance/MSTest100Passing/MSTests.tt b/test/TestAssets/performance/MSTest100Passing/MSTests.tt index 78067d2d05..bf88b84c78 100644 --- a/test/TestAssets/performance/MSTest100Passing/MSTests.tt +++ b/test/TestAssets/performance/MSTest100Passing/MSTests.tt @@ -1,5 +1,4 @@ -using System; -using Microsoft.VisualStudio.TestTools.UnitTesting; +using Microsoft.VisualStudio.TestTools.UnitTesting; namespace Tests { @@ -30,7 +29,7 @@ namespace Tests { } -<# +<# } #> #endregion @@ -46,12 +45,12 @@ namespace Tests { Assert.Fail(); } -<# +<# } #> #endregion } -<# +<# } -#> +#> } diff --git a/test/TestAssets/performance/MSTest10kPassing/MSTests.cs b/test/TestAssets/performance/MSTest10kPassing/MSTests.cs index f2ae6701fc..20e9319c11 100644 --- a/test/TestAssets/performance/MSTest10kPassing/MSTests.cs +++ b/test/TestAssets/performance/MSTest10kPassing/MSTests.cs @@ -1,5 +1,4 @@ -using System; -using Microsoft.VisualStudio.TestTools.UnitTesting; +using Microsoft.VisualStudio.TestTools.UnitTesting; namespace Tests { @@ -54503,5 +54502,4 @@ public void Test_500_20() #region FailingTests #endregion } - } diff --git a/test/TestAssets/performance/MSTest10kPassing/MSTests.tt b/test/TestAssets/performance/MSTest10kPassing/MSTests.tt index fbbc66de5b..f476b44d51 100644 --- a/test/TestAssets/performance/MSTest10kPassing/MSTests.tt +++ b/test/TestAssets/performance/MSTest10kPassing/MSTests.tt @@ -1,5 +1,4 @@ -using System; -using Microsoft.VisualStudio.TestTools.UnitTesting; +using Microsoft.VisualStudio.TestTools.UnitTesting; namespace Tests { @@ -30,7 +29,7 @@ namespace Tests { } -<# +<# } #> #endregion @@ -46,12 +45,12 @@ namespace Tests { Assert.Fail(); } -<# +<# } #> #endregion } -<# +<# } -#> +#> } diff --git a/test/TestAssets/performance/MSTest1Passing/MSTests.cs b/test/TestAssets/performance/MSTest1Passing/MSTests.cs index 9100e9eb3f..c5300f1880 100644 --- a/test/TestAssets/performance/MSTest1Passing/MSTests.cs +++ b/test/TestAssets/performance/MSTest1Passing/MSTests.cs @@ -1,5 +1,4 @@ -using System; -using Microsoft.VisualStudio.TestTools.UnitTesting; +using Microsoft.VisualStudio.TestTools.UnitTesting; namespace Tests { @@ -17,5 +16,4 @@ public void Test_01_01() #region FailingTests #endregion } - } diff --git a/test/TestAssets/performance/MSTest1Passing/MSTests.tt b/test/TestAssets/performance/MSTest1Passing/MSTests.tt index 20ac9a4ac4..f6374efefe 100644 --- a/test/TestAssets/performance/MSTest1Passing/MSTests.tt +++ b/test/TestAssets/performance/MSTest1Passing/MSTests.tt @@ -1,5 +1,4 @@ -using System; -using Microsoft.VisualStudio.TestTools.UnitTesting; +using Microsoft.VisualStudio.TestTools.UnitTesting; namespace Tests { @@ -30,7 +29,7 @@ namespace Tests { } -<# +<# } #> #endregion @@ -46,12 +45,12 @@ namespace Tests { Assert.Fail(); } -<# +<# } #> #endregion } -<# +<# } -#> +#> } diff --git a/test/TestAssets/performance/NUnit1000Passing/NunitTests.cs b/test/TestAssets/performance/NUnit1000Passing/NunitTests.cs index ad0d1aa500..375f852d12 100644 --- a/test/TestAssets/performance/NUnit1000Passing/NunitTests.cs +++ b/test/TestAssets/performance/NUnit1000Passing/NunitTests.cs @@ -1,5 +1,4 @@ -using System; -using NUnit.Framework; +using NUnit.Framework; namespace Tests { @@ -5453,5 +5452,4 @@ public void Test_50_20() #region FailingTests #endregion } - } diff --git a/test/TestAssets/performance/NUnit1000Passing/NunitTests.tt b/test/TestAssets/performance/NUnit1000Passing/NunitTests.tt index 002158dd90..5203ef532f 100644 --- a/test/TestAssets/performance/NUnit1000Passing/NunitTests.tt +++ b/test/TestAssets/performance/NUnit1000Passing/NunitTests.tt @@ -1,5 +1,4 @@ -using System; -using NUnit.Framework; +using NUnit.Framework; namespace Tests { @@ -30,7 +29,7 @@ namespace Tests { } -<# +<# } #> #endregion @@ -46,12 +45,12 @@ namespace Tests { Assert.Fail(); } -<# +<# } #> #endregion } -<# +<# } -#> +#> } diff --git a/test/TestAssets/performance/NUnit100Passing/NunitTests.cs b/test/TestAssets/performance/NUnit100Passing/NunitTests.cs index 0d246b7a38..2102117bfb 100644 --- a/test/TestAssets/performance/NUnit100Passing/NunitTests.cs +++ b/test/TestAssets/performance/NUnit100Passing/NunitTests.cs @@ -1,5 +1,4 @@ -using System; -using NUnit.Framework; +using NUnit.Framework; namespace Tests { @@ -548,5 +547,4 @@ public void Test_05_20() #region FailingTests #endregion } - } diff --git a/test/TestAssets/performance/NUnit100Passing/NunitTests.tt b/test/TestAssets/performance/NUnit100Passing/NunitTests.tt index 97e15d0565..6db97ec3dd 100644 --- a/test/TestAssets/performance/NUnit100Passing/NunitTests.tt +++ b/test/TestAssets/performance/NUnit100Passing/NunitTests.tt @@ -1,5 +1,4 @@ -using System; -using NUnit.Framework; +using NUnit.Framework; namespace Tests { @@ -30,7 +29,7 @@ namespace Tests { } -<# +<# } #> #endregion @@ -46,12 +45,12 @@ namespace Tests { Assert.Fail(); } -<# +<# } #> #endregion } -<# +<# } -#> +#> } diff --git a/test/TestAssets/performance/NUnit10kPassing/NunitTests.cs b/test/TestAssets/performance/NUnit10kPassing/NunitTests.cs index 9a3cacc13e..7cb2d4760d 100644 --- a/test/TestAssets/performance/NUnit10kPassing/NunitTests.cs +++ b/test/TestAssets/performance/NUnit10kPassing/NunitTests.cs @@ -1,5 +1,4 @@ -using System; -using NUnit.Framework; +using NUnit.Framework; namespace Tests { @@ -54503,5 +54502,4 @@ public void Test_500_20() #region FailingTests #endregion } - } diff --git a/test/TestAssets/performance/NUnit10kPassing/NunitTests.tt b/test/TestAssets/performance/NUnit10kPassing/NunitTests.tt index 23b3cf8f51..e84470ad3d 100644 --- a/test/TestAssets/performance/NUnit10kPassing/NunitTests.tt +++ b/test/TestAssets/performance/NUnit10kPassing/NunitTests.tt @@ -1,5 +1,4 @@ -using System; -using NUnit.Framework; +using NUnit.Framework; namespace Tests { @@ -30,7 +29,7 @@ namespace Tests { } -<# +<# } #> #endregion @@ -46,12 +45,12 @@ namespace Tests { Assert.Fail(); } -<# +<# } #> #endregion } -<# +<# } -#> +#> } diff --git a/test/TestAssets/performance/NUnit1Passing/NunitTests.cs b/test/TestAssets/performance/NUnit1Passing/NunitTests.cs index a55c9a6554..b0fd7a3c9c 100644 --- a/test/TestAssets/performance/NUnit1Passing/NunitTests.cs +++ b/test/TestAssets/performance/NUnit1Passing/NunitTests.cs @@ -1,5 +1,4 @@ -using System; -using NUnit.Framework; +using NUnit.Framework; namespace Tests { @@ -17,5 +16,4 @@ public void Test_01_01() #region FailingTests #endregion } - } diff --git a/test/TestAssets/performance/NUnit1Passing/NunitTests.tt b/test/TestAssets/performance/NUnit1Passing/NunitTests.tt index 54e2782704..482c0ff2f9 100644 --- a/test/TestAssets/performance/NUnit1Passing/NunitTests.tt +++ b/test/TestAssets/performance/NUnit1Passing/NunitTests.tt @@ -1,5 +1,4 @@ -using System; -using NUnit.Framework; +using NUnit.Framework; namespace Tests { @@ -30,7 +29,7 @@ namespace Tests { } -<# +<# } #> #endregion @@ -46,12 +45,12 @@ namespace Tests { Assert.Fail(); } -<# +<# } #> #endregion } -<# +<# } -#> +#> } diff --git a/test/TestAssets/performance/XUnit1000Passing/XunitTests.cs b/test/TestAssets/performance/XUnit1000Passing/XunitTests.cs index b4c6c2a6aa..db3236d8ae 100644 --- a/test/TestAssets/performance/XUnit1000Passing/XunitTests.cs +++ b/test/TestAssets/performance/XUnit1000Passing/XunitTests.cs @@ -1,5 +1,4 @@ -using System; -using Xunit; +using Xunit; namespace Tests { @@ -5403,5 +5402,4 @@ public void Test_50_20() #region FailingTests #endregion } - } diff --git a/test/TestAssets/performance/XUnit1000Passing/XunitTests.tt b/test/TestAssets/performance/XUnit1000Passing/XunitTests.tt index 9b39f1189a..7486b49df3 100644 --- a/test/TestAssets/performance/XUnit1000Passing/XunitTests.tt +++ b/test/TestAssets/performance/XUnit1000Passing/XunitTests.tt @@ -1,5 +1,4 @@ -using System; -using Xunit; +using Xunit; namespace Tests { @@ -29,7 +28,7 @@ namespace Tests { } -<# +<# } #> #endregion @@ -45,12 +44,12 @@ namespace Tests { Assert.Fail(); } -<# +<# } #> #endregion } -<# +<# } -#> +#> } diff --git a/test/TestAssets/performance/XUnit100Passing/XunitTests.cs b/test/TestAssets/performance/XUnit100Passing/XunitTests.cs index 5e490f3383..23ce625eac 100644 --- a/test/TestAssets/performance/XUnit100Passing/XunitTests.cs +++ b/test/TestAssets/performance/XUnit100Passing/XunitTests.cs @@ -1,5 +1,4 @@ -using System; -using Xunit; +using Xunit; namespace Tests { @@ -543,5 +542,4 @@ public void Test_05_20() #region FailingTests #endregion } - } diff --git a/test/TestAssets/performance/XUnit100Passing/XunitTests.tt b/test/TestAssets/performance/XUnit100Passing/XunitTests.tt index d56f4d31e7..0d05a30ff3 100644 --- a/test/TestAssets/performance/XUnit100Passing/XunitTests.tt +++ b/test/TestAssets/performance/XUnit100Passing/XunitTests.tt @@ -1,5 +1,4 @@ -using System; -using Xunit; +using Xunit; namespace Tests { @@ -29,7 +28,7 @@ namespace Tests { } -<# +<# } #> #endregion @@ -45,12 +44,12 @@ namespace Tests { Assert.Fail(); } -<# +<# } #> #endregion } -<# +<# } -#> +#> } diff --git a/test/TestAssets/performance/XUnit10kPassing/XunitTests.cs b/test/TestAssets/performance/XUnit10kPassing/XunitTests.cs index c9861d505d..b91251de85 100644 --- a/test/TestAssets/performance/XUnit10kPassing/XunitTests.cs +++ b/test/TestAssets/performance/XUnit10kPassing/XunitTests.cs @@ -1,5 +1,4 @@ -using System; -using Xunit; +using Xunit; namespace Tests { @@ -54003,5 +54002,4 @@ public void Test_500_20() #region FailingTests #endregion } - } diff --git a/test/TestAssets/performance/XUnit10kPassing/XunitTests.tt b/test/TestAssets/performance/XUnit10kPassing/XunitTests.tt index c5d78104ce..a4fe823b4d 100644 --- a/test/TestAssets/performance/XUnit10kPassing/XunitTests.tt +++ b/test/TestAssets/performance/XUnit10kPassing/XunitTests.tt @@ -1,5 +1,4 @@ -using System; -using Xunit; +using Xunit; namespace Tests { @@ -29,7 +28,7 @@ namespace Tests { } -<# +<# } #> #endregion @@ -45,12 +44,12 @@ namespace Tests { Assert.Fail(); } -<# +<# } #> #endregion } -<# +<# } -#> +#> } diff --git a/test/TestAssets/performance/XUnit1Passing/XunitTests.cs b/test/TestAssets/performance/XUnit1Passing/XunitTests.cs index b064dd5731..9bf5fb783a 100644 --- a/test/TestAssets/performance/XUnit1Passing/XunitTests.cs +++ b/test/TestAssets/performance/XUnit1Passing/XunitTests.cs @@ -1,5 +1,4 @@ -using System; -using Xunit; +using Xunit; namespace Tests { @@ -16,5 +15,4 @@ public void Test_01_01() #region FailingTests #endregion } - } diff --git a/test/TestAssets/performance/XUnit1Passing/XunitTests.tt b/test/TestAssets/performance/XUnit1Passing/XunitTests.tt index 9079af519e..97f62aefa6 100644 --- a/test/TestAssets/performance/XUnit1Passing/XunitTests.tt +++ b/test/TestAssets/performance/XUnit1Passing/XunitTests.tt @@ -1,5 +1,4 @@ -using System; -using Xunit; +using Xunit; namespace Tests { @@ -29,7 +28,7 @@ namespace Tests { } -<# +<# } #> #endregion @@ -45,12 +44,12 @@ namespace Tests { Assert.Fail(); } -<# +<# } #> #endregion } -<# +<# } -#> +#> } diff --git a/test/TranslationLayer.UnitTests/VsTestConsoleRequestSenderTests.cs b/test/TranslationLayer.UnitTests/VsTestConsoleRequestSenderTests.cs index 063ef2b0ae..f4372c90da 100644 --- a/test/TranslationLayer.UnitTests/VsTestConsoleRequestSenderTests.cs +++ b/test/TranslationLayer.UnitTests/VsTestConsoleRequestSenderTests.cs @@ -1952,7 +1952,7 @@ public async Task ProcessTestRunAttachmentsAsyncShouldCompleteWithZeroAttachment var payload = new TestRunAttachmentsProcessingCompletePayload() { AttachmentsProcessingCompleteEventArgs = new TestRunAttachmentsProcessingCompleteEventArgs(false, null), - Attachments = new AttachmentSet[0] + Attachments = Array.Empty() }; var attachmentsProcessingComplete = new Message() diff --git a/test/testhost.UnitTests/TestHostTraceListenerTests.cs b/test/testhost.UnitTests/TestHostTraceListenerTests.cs index bc35350598..ef2624f54a 100644 --- a/test/testhost.UnitTests/TestHostTraceListenerTests.cs +++ b/test/testhost.UnitTests/TestHostTraceListenerTests.cs @@ -31,7 +31,7 @@ public TestHostTraceListenerTests() Trace.Listeners.Add(new TestHostTraceListener()); } - [TestCleanup()] + [TestCleanup] public void Cleanup() { Trace.Listeners.Clear(); @@ -105,7 +105,7 @@ public TestHostTraceListenerRegistrationTests() Trace.Listeners.CopyTo(_listeners, 0); } - [TestCleanup()] + [TestCleanup] public void Cleanup() { Trace.Listeners.Clear(); diff --git a/test/vstest.ProgrammerTests/MultiTFMRunAndDiscovery.cs b/test/vstest.ProgrammerTests/MultiTFMRunAndDiscovery.cs index 3dfc252bee..87b7a179a1 100644 --- a/test/vstest.ProgrammerTests/MultiTFMRunAndDiscovery.cs +++ b/test/vstest.ProgrammerTests/MultiTFMRunAndDiscovery.cs @@ -661,7 +661,7 @@ internal static string GetRawMessage(this Message request) s_messageProperty = request.GetType().GetProperty("RawMessage")!.GetGetMethod(); } - return (string)s_messageProperty!.Invoke(request, new object[0])!; + return (string)s_messageProperty!.Invoke(request, Array.Empty())!; } } diff --git a/test/vstest.console.UnitTests/CommandLine/GenerateFakesUtilitiesTests.cs b/test/vstest.console.UnitTests/CommandLine/GenerateFakesUtilitiesTests.cs index 80529b293e..720aeeb4be 100644 --- a/test/vstest.console.UnitTests/CommandLine/GenerateFakesUtilitiesTests.cs +++ b/test/vstest.console.UnitTests/CommandLine/GenerateFakesUtilitiesTests.cs @@ -37,7 +37,7 @@ public void FakesShouldNotBeGeneratedIfDisableAutoFakesSetToTrue() CommandLineOptions.Instance.DisableAutoFakes = true; string runSettingsXml = @".netstandard,Version=5.0"; - GenerateFakesUtilities.GenerateFakesSettings(CommandLineOptions.Instance, new string[] { }, ref runSettingsXml); + GenerateFakesUtilities.GenerateFakesSettings(CommandLineOptions.Instance, System.Array.Empty(), ref runSettingsXml); Assert.AreEqual(runSettingsXml, _runSettings); } diff --git a/test/vstest.console.UnitTests/Processors/CLIRunSettingsArgumentProcessorTests.cs b/test/vstest.console.UnitTests/Processors/CLIRunSettingsArgumentProcessorTests.cs index 6547d00dd0..7302a01adc 100644 --- a/test/vstest.console.UnitTests/Processors/CLIRunSettingsArgumentProcessorTests.cs +++ b/test/vstest.console.UnitTests/Processors/CLIRunSettingsArgumentProcessorTests.cs @@ -113,7 +113,7 @@ public void InitializeShouldNotThrowExceptionIfArgumentIsNull() [TestMethod] public void InitializeShouldNotThrowExceptionIfArgumentIsEmpty() { - _executor.Initialize(new string[0]); + _executor.Initialize(Array.Empty()); Assert.IsNull(_settingsProvider.ActiveRunSettings); } @@ -307,7 +307,7 @@ public void InitializeShouldNotUpdateCommandLineOptionsArchitectureAndFxIfNotPro runSettings.LoadSettingsXml(_defaultRunSettings); _settingsProvider.SetActiveRunSettings(runSettings); - var args = new string[] { }; + var args = Array.Empty(); _executor.Initialize(args); Assert.IsFalse(_commandLineOptions.ArchitectureSpecified);