diff --git a/shared/NullableAttributes.cs b/shared/NullableAttributes.cs
index ded53a2c9f..845ee9bdfa 100644
--- a/shared/NullableAttributes.cs
+++ b/shared/NullableAttributes.cs
@@ -96,7 +96,7 @@ internal sealed class MemberNotNullAttribute : Attribute
///
/// The field or property member that is promised to be not-null.
///
- public MemberNotNullAttribute(string member) => Members = new[] { member };
+ public MemberNotNullAttribute(string member) => Members = [member];
/// Initializes the attribute with the list of field and property members.
///
@@ -122,7 +122,7 @@ internal sealed class MemberNotNullWhenAttribute : Attribute
public MemberNotNullWhenAttribute(bool returnValue, string member)
{
ReturnValue = returnValue;
- Members = new[] { member };
+ Members = [member];
}
/// Initializes the attribute with the specified return value condition and list of field and property members.
diff --git a/src/DataCollectors/Microsoft.TestPlatform.Extensions.EventLogCollector/EventLogDataCollector.cs b/src/DataCollectors/Microsoft.TestPlatform.Extensions.EventLogCollector/EventLogDataCollector.cs
index 6d93832971..9296983499 100644
--- a/src/DataCollectors/Microsoft.TestPlatform.Extensions.EventLogCollector/EventLogDataCollector.cs
+++ b/src/DataCollectors/Microsoft.TestPlatform.Extensions.EventLogCollector/EventLogDataCollector.cs
@@ -326,7 +326,7 @@ protected override void Dispose(bool disposing)
private static ISet ParseCommaSeparatedList(string commaSeparatedList)
{
ISet strings = new HashSet();
- string[] items = commaSeparatedList.Split(new char[] { ',' });
+ string[] items = commaSeparatedList.Split([',']);
foreach (string item in items)
{
strings.Add(item.Trim());
diff --git a/src/Microsoft.TestPlatform.Build/Tasks/VSTestTask2.cs b/src/Microsoft.TestPlatform.Build/Tasks/VSTestTask2.cs
index 1443725e62..cbc866d928 100644
--- a/src/Microsoft.TestPlatform.Build/Tasks/VSTestTask2.cs
+++ b/src/Microsoft.TestPlatform.Build/Tasks/VSTestTask2.cs
@@ -48,7 +48,7 @@ public class VSTestTask2 : ToolTask, ITestTask
protected override Encoding StandardOutputEncoding => _disableUtf8ConsoleEncoding ? base.StandardOutputEncoding : Encoding.UTF8;
private readonly string _messageSplitter = "||||";
- private readonly string[] _messageSplitterArray = new[] { "||||" };
+ private readonly string[] _messageSplitterArray = ["||||"];
private readonly string _ansiReset = "\x1b[39;49m";
private readonly bool _disableUtf8ConsoleEncoding;
@@ -271,7 +271,7 @@ private bool TryGetMessage(string singleLine, out string name, out string?[] dat
}
name = string.Empty;
- data = Array.Empty();
+ data = [];
return false;
}
diff --git a/src/Microsoft.TestPlatform.Client/DesignMode/DesignModeClient.cs b/src/Microsoft.TestPlatform.Client/DesignMode/DesignModeClient.cs
index b3e59ba1c5..f64f20374e 100644
--- a/src/Microsoft.TestPlatform.Client/DesignMode/DesignModeClient.cs
+++ b/src/Microsoft.TestPlatform.Client/DesignMode/DesignModeClient.cs
@@ -334,7 +334,7 @@ public int LaunchCustomHost(TestProcessStartInfo testProcessStartInfo, Cancellat
// Even if TP has a timeout here, there is no way TP can abort or stop the thread/task that is hung in IDE or LUT
// Even if TP can abort the API somehow, TP is essentially putting IDEs or Clients in inconsistent state without having info on
// Since the IDEs own user-UI-experience here, TP will let the custom host launch as much time as IDEs define it for their users
- WaitHandle.WaitAny(new WaitHandle[] { waitHandle, cancellationToken.WaitHandle });
+ WaitHandle.WaitAny([waitHandle, cancellationToken.WaitHandle]);
cancellationToken.ThrowTestPlatformExceptionIfCancellationRequested();
@@ -387,7 +387,7 @@ public bool AttachDebuggerToProcess(AttachDebuggerInfo attachDebuggerInfo, Cance
_communicationManager.SendMessage(MessageType.EditorAttachDebugger2, payload);
}
- WaitHandle.WaitAny(new WaitHandle[] { waitHandle, cancellationToken.WaitHandle });
+ WaitHandle.WaitAny([waitHandle, cancellationToken.WaitHandle]);
cancellationToken.ThrowTestPlatformExceptionIfCancellationRequested();
onAttachDebuggerAckRecieved = null;
diff --git a/src/Microsoft.TestPlatform.Client/TestPlatform.cs b/src/Microsoft.TestPlatform.Client/TestPlatform.cs
index 45ee1303a1..73b7a47627 100644
--- a/src/Microsoft.TestPlatform.Client/TestPlatform.cs
+++ b/src/Microsoft.TestPlatform.Client/TestPlatform.cs
@@ -283,7 +283,7 @@ private static void AddExtensionAssembliesFromExtensionDirectory()
TestAdapterLoadingStrategy strategy = runConfiguration.TestAdapterLoadingStrategy;
FileHelper fileHelper = new();
- IEnumerable defaultExtensionPaths = Enumerable.Empty();
+ IEnumerable defaultExtensionPaths = [];
// Explicit adapter loading
if (strategy.HasFlag(TestAdapterLoadingStrategy.Explicit))
@@ -354,7 +354,7 @@ private static IEnumerable ExpandAdaptersWithExplicitStrategy(string pat
{
if (!strategy.HasFlag(TestAdapterLoadingStrategy.Explicit))
{
- return Enumerable.Empty();
+ return [];
}
if (fileHelper.Exists(path))
@@ -377,7 +377,7 @@ private static IEnumerable ExpandAdaptersWithExplicitStrategy(string pat
}
EqtTrace.Warning($"{nameof(TestPlatform)}.{nameof(ExpandAdaptersWithExplicitStrategy)} AdapterPath Not Found: {path}");
- return Enumerable.Empty();
+ return [];
}
private static IEnumerable ExpandAdaptersWithDefaultStrategy(string path, IFileHelper fileHelper)
@@ -388,7 +388,7 @@ private static IEnumerable ExpandAdaptersWithDefaultStrategy(string path
{
EqtTrace.Warning($"{nameof(TestPlatform)}.{nameof(ExpandAdaptersWithDefaultStrategy)} AdapterPath Not Found: {path}");
- return Enumerable.Empty();
+ return [];
}
return fileHelper.EnumerateFiles(
diff --git a/src/Microsoft.TestPlatform.Common/ExtensionFramework/VSExtensionManager.cs b/src/Microsoft.TestPlatform.Common/ExtensionFramework/VSExtensionManager.cs
index cec8312fe0..d4e5224d26 100644
--- a/src/Microsoft.TestPlatform.Common/ExtensionFramework/VSExtensionManager.cs
+++ b/src/Microsoft.TestPlatform.Common/ExtensionFramework/VSExtensionManager.cs
@@ -85,7 +85,7 @@ private IEnumerable GetTestExtensionsInternal(string extensionType)
var resolutionPaths = installContext.GetVisualStudioCommonLocations(vsInstallPath);
using (var assemblyResolver = new AssemblyResolver(resolutionPaths))
{
- var settingsManager = SettingsManagerType.GetMethod("CreateForApplication", new Type[] { typeof(string) })?.Invoke(null, new object[] { installContext.GetVisualStudioPath(vsInstallPath) });
+ var settingsManager = SettingsManagerType.GetMethod("CreateForApplication", [typeof(string)])?.Invoke(null, [installContext.GetVisualStudioPath(vsInstallPath)]);
if (settingsManager == null)
{
EqtTrace.Warning("VSExtensionManager : Unable to create settings manager");
@@ -99,8 +99,8 @@ private IEnumerable GetTestExtensionsInternal(string extensionType)
if (extensionManager != null)
{
- installedExtensions = ExtensionManagerServiceType.GetMethod("GetEnabledExtensionContentLocations", new Type[] { typeof(string) })?.Invoke(
- extensionManager, new object[] { extensionType }) as IEnumerable;
+ installedExtensions = ExtensionManagerServiceType.GetMethod("GetEnabledExtensionContentLocations", [typeof(string)])?.Invoke(
+ extensionManager, [extensionType]) as IEnumerable;
}
else
{
diff --git a/src/Microsoft.TestPlatform.Common/Filtering/FilterExpression.cs b/src/Microsoft.TestPlatform.Common/Filtering/FilterExpression.cs
index 417d10fae4..a587d1a98d 100644
--- a/src/Microsoft.TestPlatform.Common/Filtering/FilterExpression.cs
+++ b/src/Microsoft.TestPlatform.Common/Filtering/FilterExpression.cs
@@ -122,7 +122,7 @@ private static void ProcessOperator(Stack filterStack, Operato
if (null == properties)
{
// if null, initialize to empty list so that invalid properties can be found.
- properties = Enumerable.Empty();
+ properties = [];
}
return IterateFilterExpression((current, result) =>
@@ -132,7 +132,7 @@ private static void ProcessOperator(Stack filterStack, Operato
{
var valid = current._condition.ValidForProperties(properties, propertyProvider);
// If it's not valid will add it to the function's return array.
- return !valid ? new string[1] { current._condition.Name } : null;
+ return !valid ? [current._condition.Name] : null;
}
// Concatenate the children node's result to get their parent result.
diff --git a/src/Microsoft.TestPlatform.Common/Utilities/AssemblyResolver.cs b/src/Microsoft.TestPlatform.Common/Utilities/AssemblyResolver.cs
index 6181dcd5b4..6682231730 100644
--- a/src/Microsoft.TestPlatform.Common/Utilities/AssemblyResolver.cs
+++ b/src/Microsoft.TestPlatform.Common/Utilities/AssemblyResolver.cs
@@ -40,7 +40,7 @@ internal class AssemblyResolver : IDisposable
private readonly IAssemblyLoadContext _platformAssemblyLoadContext;
- private static readonly string[] SupportedFileExtensions = { ".dll", ".exe" };
+ private static readonly string[] SupportedFileExtensions = [".dll", ".exe"];
///
/// Initializes a new instance of the class.
diff --git a/src/Microsoft.TestPlatform.Common/Utilities/FakesUtilities.cs b/src/Microsoft.TestPlatform.Common/Utilities/FakesUtilities.cs
index c493b0c380..feac1e682c 100644
--- a/src/Microsoft.TestPlatform.Common/Utilities/FakesUtilities.cs
+++ b/src/Microsoft.TestPlatform.Common/Utilities/FakesUtilities.cs
@@ -231,7 +231,7 @@ private static void EnsureSettingsNode(XmlDocument settings, TestRunSettings set
{
var assembly = LoadTestPlatformAssembly();
var type = assembly?.GetType(ConfiguratorAssemblyQualifiedName, false);
- var method = type?.GetMethod(NetFrameworkConfiguratorMethodName, new Type[] { typeof(IEnumerable) });
+ var method = type?.GetMethod(NetFrameworkConfiguratorMethodName, [typeof(IEnumerable)]);
if (method != null)
{
return (Func, string>)method.CreateDelegate(typeof(Func, string>));
@@ -251,7 +251,7 @@ private static void EnsureSettingsNode(XmlDocument settings, TestRunSettings set
{
var assembly = LoadTestPlatformAssembly();
var type = assembly?.GetType(ConfiguratorAssemblyQualifiedName, false, false);
- var method = type?.GetMethod(CrossPlatformConfiguratorMethodName, new Type[] { typeof(IDictionary) });
+ var method = type?.GetMethod(CrossPlatformConfiguratorMethodName, [typeof(IDictionary)]);
if (method != null)
{
return (Func, DataCollectorSettings>)method.CreateDelegate(typeof(Func, DataCollectorSettings>));
diff --git a/src/Microsoft.TestPlatform.Common/Utilities/InstallationContext.cs b/src/Microsoft.TestPlatform.Common/Utilities/InstallationContext.cs
index 6c0c0bebaa..4783921204 100644
--- a/src/Microsoft.TestPlatform.Common/Utilities/InstallationContext.cs
+++ b/src/Microsoft.TestPlatform.Common/Utilities/InstallationContext.cs
@@ -48,13 +48,13 @@ public string GetVisualStudioPath(string visualStudioDirectory)
[SuppressMessage("Performance", "CA1822:Mark members as static", Justification = "Part of the public API")]
public string[] GetVisualStudioCommonLocations(string visualStudioDirectory)
{
- return new[]
- {
+ return
+ [
Path.Combine(visualStudioDirectory, PrivateAssembliesDirName),
Path.Combine(visualStudioDirectory, PublicAssembliesDirName),
Path.Combine(visualStudioDirectory, "CommonExtensions", "Microsoft", "TestWindow"),
Path.Combine(visualStudioDirectory, "CommonExtensions", "Microsoft", "TeamFoundation", "Team Explorer"),
visualStudioDirectory
- };
+ ];
}
}
diff --git a/src/Microsoft.TestPlatform.Common/Utilities/MetadataReaderHelper.cs b/src/Microsoft.TestPlatform.Common/Utilities/MetadataReaderHelper.cs
index e515ab5950..a8a6887df7 100644
--- a/src/Microsoft.TestPlatform.Common/Utilities/MetadataReaderHelper.cs
+++ b/src/Microsoft.TestPlatform.Common/Utilities/MetadataReaderHelper.cs
@@ -42,7 +42,7 @@ internal static class MetadataReaderExtensionsHelper
{
private const string TestExtensionTypesAttributeV2 = "Microsoft.VisualStudio.TestPlatform.TestExtensionTypesV2Attribute";
private static readonly ConcurrentDictionary AssemblyCache = new();
- private static readonly Type[] EmptyTypeArray = new Type[0];
+ private static readonly Type[] EmptyTypeArray = [];
public static Type[] DiscoverTestExtensionTypesV2Attribute(Assembly loadedAssembly, string assemblyFilePath)
=> AssemblyCache.GetOrAdd(assemblyFilePath, DiscoverTestExtensionTypesV2AttributeInternal(loadedAssembly, assemblyFilePath));
diff --git a/src/Microsoft.TestPlatform.Common/Utilities/RunSettingsUtilities.cs b/src/Microsoft.TestPlatform.Common/Utilities/RunSettingsUtilities.cs
index a66a6ec57b..f9fb02e684 100644
--- a/src/Microsoft.TestPlatform.Common/Utilities/RunSettingsUtilities.cs
+++ b/src/Microsoft.TestPlatform.Common/Utilities/RunSettingsUtilities.cs
@@ -4,7 +4,6 @@
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
-using System.Linq;
using Microsoft.VisualStudio.TestPlatform.ObjectModel;
using Microsoft.VisualStudio.TestPlatform.ObjectModel.Utilities;
@@ -176,12 +175,12 @@ public static IEnumerable GetTestAdaptersPaths(string? runSettings)
{
var runConfiguration = XmlRunSettingsUtilities.GetRunConfigurationNode(runSettings);
- IEnumerable testAdaptersPaths = Enumerable.Empty();
+ IEnumerable testAdaptersPaths = [];
if (runConfiguration != null)
{
if (runConfiguration.TestAdaptersPathsSet)
{
- testAdaptersPaths = runConfiguration.TestAdaptersPaths.Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
+ testAdaptersPaths = runConfiguration.TestAdaptersPaths.Split([';'], StringSplitOptions.RemoveEmptyEntries);
}
}
diff --git a/src/Microsoft.TestPlatform.CommunicationUtilities/Serialization/TestObjectConverter.cs b/src/Microsoft.TestPlatform.CommunicationUtilities/Serialization/TestObjectConverter.cs
index f7fabcdbf7..fdc615a411 100644
--- a/src/Microsoft.TestPlatform.CommunicationUtilities/Serialization/TestObjectConverter.cs
+++ b/src/Microsoft.TestPlatform.CommunicationUtilities/Serialization/TestObjectConverter.cs
@@ -102,12 +102,12 @@ internal class TestObjectConverter7 : JsonConverter
{
// Empty is not present everywhere
#pragma warning disable CA1825 // Avoid zero-length array allocations
- private static readonly object[] EmptyObjectArray = new object[0];
+ private static readonly object[] EmptyObjectArray = [];
#pragma warning restore CA1825 // Avoid zero-length array allocations
public TestObjectConverter7()
{
- TestPropertyCtor = typeof(TestProperty).GetConstructor(BindingFlags.NonPublic | BindingFlags.Instance, null, new Type[0], null);
+ TestPropertyCtor = typeof(TestProperty).GetConstructor(BindingFlags.NonPublic | BindingFlags.Instance, null, [], null);
}
///
diff --git a/src/Microsoft.TestPlatform.CommunicationUtilities/TestRequestSender.cs b/src/Microsoft.TestPlatform.CommunicationUtilities/TestRequestSender.cs
index ad0b614463..89f7369dbd 100644
--- a/src/Microsoft.TestPlatform.CommunicationUtilities/TestRequestSender.cs
+++ b/src/Microsoft.TestPlatform.CommunicationUtilities/TestRequestSender.cs
@@ -217,7 +217,7 @@ public bool WaitForRequestHandlerConnection(int connectionTimeout, CancellationT
// Wait until either connection is successful, handled by connected.WaitHandle
// or operation is canceled, handled by cancellationToken.WaitHandle
// or testhost exits unexpectedly, handled by clientExited.WaitHandle
- var waitIndex = WaitHandle.WaitAny(new WaitHandle[] { _connected.WaitHandle, cancellationToken.WaitHandle, _clientExited.WaitHandle }, connectionTimeout);
+ var waitIndex = WaitHandle.WaitAny([_connected.WaitHandle, cancellationToken.WaitHandle, _clientExited.WaitHandle], connectionTimeout);
EqtTrace.Verbose("TestRequestSender.WaitForRequestHandlerConnection: waiting took {0} ms, with timeout {1} ms, and result {2}, which is {3}.", sw.ElapsedMilliseconds, connectionTimeout, waitIndex, waitIndex == 0 ? "success" : "failure");
diff --git a/src/Microsoft.TestPlatform.CoreUtilities/Helpers/FileHelper.cs b/src/Microsoft.TestPlatform.CoreUtilities/Helpers/FileHelper.cs
index 6b75f6b8a1..7179155386 100644
--- a/src/Microsoft.TestPlatform.CoreUtilities/Helpers/FileHelper.cs
+++ b/src/Microsoft.TestPlatform.CoreUtilities/Helpers/FileHelper.cs
@@ -50,7 +50,7 @@ public IEnumerable EnumerateFiles(
{
if (endsWithSearchPatterns == null || endsWithSearchPatterns.Length == 0)
{
- return Enumerable.Empty();
+ return [];
}
var files = Directory.EnumerateFiles(directory, "*", searchOption);
diff --git a/src/Microsoft.TestPlatform.CrossPlatEngine/AttachmentsProcessing/DataCollectorAttachmentProcessorAppDomain.cs b/src/Microsoft.TestPlatform.CrossPlatEngine/AttachmentsProcessing/DataCollectorAttachmentProcessorAppDomain.cs
index 28ef57dbd8..744b346976 100644
--- a/src/Microsoft.TestPlatform.CrossPlatEngine/AttachmentsProcessing/DataCollectorAttachmentProcessorAppDomain.cs
+++ b/src/Microsoft.TestPlatform.CrossPlatEngine/AttachmentsProcessing/DataCollectorAttachmentProcessorAppDomain.cs
@@ -63,7 +63,7 @@ public DataCollectorAttachmentProcessorAppDomain(InvokedDataCollector invokedDat
false,
BindingFlags.Default,
null,
- new[] { _pipeShutdownMessagePrefix },
+ [_pipeShutdownMessagePrefix],
null,
null);
diff --git a/src/Microsoft.TestPlatform.CrossPlatEngine/Client/InProcessProxyDiscoveryManager.cs b/src/Microsoft.TestPlatform.CrossPlatEngine/Client/InProcessProxyDiscoveryManager.cs
index a416e5a2f6..093664b8c7 100644
--- a/src/Microsoft.TestPlatform.CrossPlatEngine/Client/InProcessProxyDiscoveryManager.cs
+++ b/src/Microsoft.TestPlatform.CrossPlatEngine/Client/InProcessProxyDiscoveryManager.cs
@@ -74,7 +74,7 @@ public void DiscoverTests(DiscoveryCriteria discoveryCriteria, ITestDiscoveryEve
var discoveryCompeleteEventsArg = new DiscoveryCompleteEventArgs(-1, true);
- eventHandler.HandleDiscoveryComplete(discoveryCompeleteEventsArg, Enumerable.Empty());
+ eventHandler.HandleDiscoveryComplete(discoveryCompeleteEventsArg, []);
}
});
}
@@ -103,7 +103,7 @@ public void Abort(ITestDiscoveryEventsHandler2 eventHandler)
private void InitializeExtensions(IEnumerable sources)
{
- var extensionsFromSource = _testHostManager.GetTestPlatformExtensions(sources, Enumerable.Empty());
+ var extensionsFromSource = _testHostManager.GetTestPlatformExtensions(sources, []);
if (extensionsFromSource.Any())
{
TestPluginCache.Instance.UpdateExtensions(extensionsFromSource, false);
@@ -111,7 +111,7 @@ private void InitializeExtensions(IEnumerable sources)
// We don't need to pass list of extension as we are running inside vstest.console and
// it will use TestPluginCache of vstest.console
- _discoveryManager.Initialize(Enumerable.Empty(), null);
+ _discoveryManager.Initialize([], null);
}
public void InitializeDiscovery(DiscoveryCriteria discoveryCriteria, ITestDiscoveryEventsHandler2 eventHandler, bool skipDefaultAdapters)
diff --git a/src/Microsoft.TestPlatform.CrossPlatEngine/Client/InProcessProxyexecutionManager.cs b/src/Microsoft.TestPlatform.CrossPlatEngine/Client/InProcessProxyexecutionManager.cs
index 27def5dde1..4dd1772c99 100644
--- a/src/Microsoft.TestPlatform.CrossPlatEngine/Client/InProcessProxyexecutionManager.cs
+++ b/src/Microsoft.TestPlatform.CrossPlatEngine/Client/InProcessProxyexecutionManager.cs
@@ -135,7 +135,7 @@ public void Close()
private void InitializeExtensions(IEnumerable sources)
{
- var extensionsFromSource = _testHostManager.GetTestPlatformExtensions(sources, Enumerable.Empty());
+ var extensionsFromSource = _testHostManager.GetTestPlatformExtensions(sources, []);
if (extensionsFromSource.Any())
{
TestPluginCache.Instance.UpdateExtensions(extensionsFromSource, false);
@@ -143,7 +143,7 @@ private void InitializeExtensions(IEnumerable sources)
// We don't need to pass list of extension as we are running inside vstest.console and
// it will use TestPluginCache of vstest.console
- _executionManager.Initialize(Enumerable.Empty(), null);
+ _executionManager.Initialize([], null);
}
public void InitializeTestRun(TestRunCriteria testRunCriteria, IInternalTestRunEventsHandler eventHandler)
diff --git a/src/Microsoft.TestPlatform.CrossPlatEngine/Client/Parallel/ParallelOperationManager.cs b/src/Microsoft.TestPlatform.CrossPlatEngine/Client/Parallel/ParallelOperationManager.cs
index df2ef9133a..9003a84790 100644
--- a/src/Microsoft.TestPlatform.CrossPlatEngine/Client/Parallel/ParallelOperationManager.cs
+++ b/src/Microsoft.TestPlatform.CrossPlatEngine/Client/Parallel/ParallelOperationManager.cs
@@ -312,7 +312,7 @@ private void ClearCompletedSlot(TManager completedManager)
private static string GetSourcesForSlotExpensive(ParallelOperationManager.Slot slot)
{
- return string.Join(", ", (slot.Work as DiscoveryCriteria)?.Sources ?? (slot.Work as TestRunCriteria)?.Sources ?? Array.Empty());
+ return string.Join(", ", (slot.Work as DiscoveryCriteria)?.Sources ?? (slot.Work as TestRunCriteria)?.Sources ?? []);
}
public void DoActionOnAllManagers(Action action, bool doActionsInParallel = false)
diff --git a/src/Microsoft.TestPlatform.CrossPlatEngine/Client/Parallel/ParallelProxyDiscoveryManager.cs b/src/Microsoft.TestPlatform.CrossPlatEngine/Client/Parallel/ParallelProxyDiscoveryManager.cs
index 7b871e4e91..5cae5c4eea 100644
--- a/src/Microsoft.TestPlatform.CrossPlatEngine/Client/Parallel/ParallelProxyDiscoveryManager.cs
+++ b/src/Microsoft.TestPlatform.CrossPlatEngine/Client/Parallel/ParallelProxyDiscoveryManager.cs
@@ -222,7 +222,7 @@ private List> SplitToWorkloads(Disco
if (!_isParallel && testhostProviderInfo.Shared)
{
// Create one big source batch that will be single workload for single testhost.
- sourceBatches = new List { group.Select(w => w.Work).ToArray() };
+ sourceBatches = [group.Select(w => w.Work).ToArray()];
}
else
{
diff --git a/src/Microsoft.TestPlatform.CrossPlatEngine/Client/Parallel/ParallelProxyExecutionManager.cs b/src/Microsoft.TestPlatform.CrossPlatEngine/Client/Parallel/ParallelProxyExecutionManager.cs
index b586cfe934..4329d4620f 100644
--- a/src/Microsoft.TestPlatform.CrossPlatEngine/Client/Parallel/ParallelProxyExecutionManager.cs
+++ b/src/Microsoft.TestPlatform.CrossPlatEngine/Client/Parallel/ParallelProxyExecutionManager.cs
@@ -261,7 +261,7 @@ private List> SplitToWorkloads(TestRun
if (!_isParallel && testhostProviderInfo.Shared)
{
// Create one big batch of testcases that will be single workload for single testhost.
- testCaseBatches = new List { group.SelectMany(w => sourceToTestCasesMap[w.Work]).ToArray() };
+ testCaseBatches = [group.SelectMany(w => sourceToTestCasesMap[w.Work]).ToArray()];
}
else
{
@@ -319,7 +319,7 @@ private List> SplitToWorkloads(TestRun
if (!_isParallel && testhostProviderInfo.Shared)
{
// Create one big source batch that will be single workload for single testhost.
- sourceBatches = new List { group.Select(w => w.Work).ToArray() };
+ sourceBatches = [group.Select(w => w.Work).ToArray()];
}
else
{
diff --git a/src/Microsoft.TestPlatform.CrossPlatEngine/Client/TestLoggerManager.cs b/src/Microsoft.TestPlatform.CrossPlatEngine/Client/TestLoggerManager.cs
index 947c1bad04..232a31145e 100644
--- a/src/Microsoft.TestPlatform.CrossPlatEngine/Client/TestLoggerManager.cs
+++ b/src/Microsoft.TestPlatform.CrossPlatEngine/Client/TestLoggerManager.cs
@@ -543,7 +543,7 @@ private bool InitializeLoggerByType(string assemblyQualifiedName, string codeBas
// Create logger instance
var constructorInfo = loggerType?.GetConstructor(Type.EmptyTypes);
- var logger = constructorInfo?.Invoke(new object[] { });
+ var logger = constructorInfo?.Invoke([]);
// Handle logger null scenario.
if (logger == null)
diff --git a/src/Microsoft.TestPlatform.CrossPlatEngine/DataCollection/InProcDataCollector.cs b/src/Microsoft.TestPlatform.CrossPlatEngine/DataCollection/InProcDataCollector.cs
index f8cdcf9837..466b8d16b4 100644
--- a/src/Microsoft.TestPlatform.CrossPlatEngine/DataCollection/InProcDataCollector.cs
+++ b/src/Microsoft.TestPlatform.CrossPlatEngine/DataCollection/InProcDataCollector.cs
@@ -79,7 +79,7 @@ internal InProcDataCollector(string codeBase, string assemblyQualifiedName, Type
// Coverlet collector is consumed as nuget package we need to add assemblies directory to resolver to correctly load references.
TPDebug.Assert(Path.IsPathRooted(codeBase), "Absolute path expected");
- testPluginCache.AddResolverSearchDirectories(new string[] { Path.GetDirectoryName(codeBase)! });
+ testPluginCache.AddResolverSearchDirectories([Path.GetDirectoryName(codeBase)!]);
}
else
{
@@ -112,24 +112,24 @@ public void LoadDataCollector(IDataCollectionSink inProcDataCollectionSink)
/// Arguments for the method
public void TriggerInProcDataCollectionMethod(string methodName, InProcDataCollectionArgs methodArg)
{
- var methodInfo = GetMethodInfoFromType(_dataCollectorObject?.GetType(), methodName, new[] { methodArg.GetType() });
+ var methodInfo = GetMethodInfoFromType(_dataCollectorObject?.GetType(), methodName, [methodArg.GetType()]);
if (methodName.Equals(Constants.TestSessionStartMethodName))
{
var testSessionStartArgs = (TestSessionStartArgs)methodArg;
testSessionStartArgs.Configuration = _configXml!;
- methodInfo?.Invoke(_dataCollectorObject, new object[] { testSessionStartArgs });
+ methodInfo?.Invoke(_dataCollectorObject, [testSessionStartArgs]);
}
else
{
- methodInfo?.Invoke(_dataCollectorObject, new object[] { methodArg });
+ methodInfo?.Invoke(_dataCollectorObject, [methodArg]);
}
}
private static void InitializeDataCollector(object? obj, IDataCollectionSink inProcDataCollectionSink)
{
- var initializeMethodInfo = GetMethodInfoFromType(obj?.GetType(), "Initialize", new Type[] { typeof(IDataCollectionSink) });
- initializeMethodInfo?.Invoke(obj, new object[] { inProcDataCollectionSink });
+ var initializeMethodInfo = GetMethodInfoFromType(obj?.GetType(), "Initialize", [typeof(IDataCollectionSink)]);
+ initializeMethodInfo?.Invoke(obj, [inProcDataCollectionSink]);
}
private static MethodInfo? GetMethodInfoFromType(Type? type, string funcName, Type[] argumentTypes)
@@ -140,7 +140,7 @@ private static void InitializeDataCollector(object? obj, IDataCollectionSink inP
private static object? CreateObjectFromType(Type? type)
{
var constructorInfo = type?.GetConstructor(Type.EmptyTypes);
- object? obj = constructorInfo?.Invoke(new object[] { });
+ object? obj = constructorInfo?.Invoke([]);
return obj;
}
diff --git a/src/Microsoft.TestPlatform.CrossPlatEngine/Execution/BaseRunTests.cs b/src/Microsoft.TestPlatform.CrossPlatEngine/Execution/BaseRunTests.cs
index 4600200c39..87c19a472e 100644
--- a/src/Microsoft.TestPlatform.CrossPlatEngine/Execution/BaseRunTests.cs
+++ b/src/Microsoft.TestPlatform.CrossPlatEngine/Execution/BaseRunTests.cs
@@ -619,7 +619,7 @@ private void RaiseTestRunComplete(
UpdateTestCaseSourceToPackage(lastChunkTestResults, null, out lastChunkTestResults, out _);
}
- var testRunChangedEventArgs = new TestRunChangedEventArgs(runStats, lastChunkTestResults, Enumerable.Empty());
+ var testRunChangedEventArgs = new TestRunChangedEventArgs(runStats, lastChunkTestResults, []);
// Adding Metrics along with Test Run Complete Event Args
Collection? attachments = FrameworkHandle?.Attachments;
diff --git a/src/Microsoft.TestPlatform.CrossPlatEngine/Execution/RunTestsWithTests.cs b/src/Microsoft.TestPlatform.CrossPlatEngine/Execution/RunTestsWithTests.cs
index 291e7a5671..2049a17bcf 100644
--- a/src/Microsoft.TestPlatform.CrossPlatEngine/Execution/RunTestsWithTests.cs
+++ b/src/Microsoft.TestPlatform.CrossPlatEngine/Execution/RunTestsWithTests.cs
@@ -131,7 +131,7 @@ private static Dictionary, List> GetExecutorVsTestC
}
else
{
- testList = new List { test };
+ testList = [test];
result.Add(executorUriExtensionTuple, testList);
}
}
diff --git a/src/Microsoft.TestPlatform.CrossPlatEngine/PostProcessing/PostProcessingTestRunAttachmentsProcessingEventsHandler.cs b/src/Microsoft.TestPlatform.CrossPlatEngine/PostProcessing/PostProcessingTestRunAttachmentsProcessingEventsHandler.cs
index 686a83d0d0..668f5d4cf4 100644
--- a/src/Microsoft.TestPlatform.CrossPlatEngine/PostProcessing/PostProcessingTestRunAttachmentsProcessingEventsHandler.cs
+++ b/src/Microsoft.TestPlatform.CrossPlatEngine/PostProcessing/PostProcessingTestRunAttachmentsProcessingEventsHandler.cs
@@ -4,7 +4,6 @@
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
-using System.Linq;
using Microsoft.VisualStudio.TestPlatform.ObjectModel;
using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client;
@@ -50,7 +49,7 @@ public void HandleProcessedAttachmentsChunk(IEnumerable attachmen
public void HandleTestRunAttachmentsProcessingComplete(TestRunAttachmentsProcessingCompleteEventArgs attachmentsProcessingCompleteEventArgs, IEnumerable? lastChunk)
{
- foreach (var attachment in lastChunk ?? Enumerable.Empty())
+ foreach (var attachment in lastChunk ?? [])
{
_attachmentsSet.Add(attachment);
}
diff --git a/src/Microsoft.TestPlatform.Extensions.BlameDataCollector/BlameCollector.cs b/src/Microsoft.TestPlatform.Extensions.BlameDataCollector/BlameCollector.cs
index 1f3f483d29..3628a29c89 100644
--- a/src/Microsoft.TestPlatform.Extensions.BlameDataCollector/BlameCollector.cs
+++ b/src/Microsoft.TestPlatform.Extensions.BlameDataCollector/BlameCollector.cs
@@ -356,7 +356,7 @@ private void ValidateAndAddCrashProcessDumpParameters(XmlElement collectDumpNode
&& !string.Equals(attribute.Value, Constants.FalseConfigurationValue, StringComparison.OrdinalIgnoreCase))
|| !bool.TryParse(attribute.Value, out _collectDumpAlways))
{
- _logger.LogWarning(_context.SessionDataCollectionContext, FormatBlameParameterValueIncorrectMessage(attribute, new[] { Constants.TrueConfigurationValue, Constants.FalseConfigurationValue }));
+ _logger.LogWarning(_context.SessionDataCollectionContext, FormatBlameParameterValueIncorrectMessage(attribute, [Constants.TrueConfigurationValue, Constants.FalseConfigurationValue]));
}
break;
diff --git a/src/Microsoft.TestPlatform.Extensions.BlameDataCollector/NetClientCrashDumper.cs b/src/Microsoft.TestPlatform.Extensions.BlameDataCollector/NetClientCrashDumper.cs
index 333a123a21..f705eadf19 100644
--- a/src/Microsoft.TestPlatform.Extensions.BlameDataCollector/NetClientCrashDumper.cs
+++ b/src/Microsoft.TestPlatform.Extensions.BlameDataCollector/NetClientCrashDumper.cs
@@ -35,7 +35,7 @@ public IEnumerable GetDumpFiles(bool _)
{
return _fileHelper.DirectoryExists(_outputDirectory)
? _fileHelper.GetFiles(_outputDirectory, "*_crashdump*.dmp", SearchOption.AllDirectories)
- : Array.Empty();
+ : [];
}
public void WaitForDumpToFinish()
diff --git a/src/Microsoft.TestPlatform.Extensions.BlameDataCollector/ProcDumpDumper.cs b/src/Microsoft.TestPlatform.Extensions.BlameDataCollector/ProcDumpDumper.cs
index a4130d6d2c..1c6e39a935 100644
--- a/src/Microsoft.TestPlatform.Extensions.BlameDataCollector/ProcDumpDumper.cs
+++ b/src/Microsoft.TestPlatform.Extensions.BlameDataCollector/ProcDumpDumper.cs
@@ -241,7 +241,7 @@ public IEnumerable GetDumpFiles(bool processCrashed)
{
var allDumps = _fileHelper.DirectoryExists(_outputDirectory)
? _fileHelper.GetFiles(_outputDirectory, "*_crashdump*.dmp", SearchOption.AllDirectories)
- : Array.Empty();
+ : [];
// We are always collecting dump on exit even when collectAlways option is false, to make sure we collect
// dump for Environment.FailFast. So there always can be a dump if the process already exited. In most cases
diff --git a/src/Microsoft.TestPlatform.Extensions.BlameDataCollector/ProcessDumpUtility.cs b/src/Microsoft.TestPlatform.Extensions.BlameDataCollector/ProcessDumpUtility.cs
index fc42574303..e5eb1be159 100644
--- a/src/Microsoft.TestPlatform.Extensions.BlameDataCollector/ProcessDumpUtility.cs
+++ b/src/Microsoft.TestPlatform.Extensions.BlameDataCollector/ProcessDumpUtility.cs
@@ -60,7 +60,7 @@ public IEnumerable GetDumpFiles(bool warnOnNoDumpFiles, bool processCras
IEnumerable hangDumps = _fileHelper.DirectoryExists(_hangDumpDirectory)
? _fileHelper.GetFiles(_hangDumpDirectory, "*_hangdump*.dmp", SearchOption.TopDirectoryOnly)
- : Array.Empty();
+ : [];
var foundDumps = new List();
foreach (var dumpPath in crashDumps.Concat(hangDumps))
diff --git a/src/Microsoft.TestPlatform.Extensions.TrxLogger/TrxLogger.cs b/src/Microsoft.TestPlatform.Extensions.TrxLogger/TrxLogger.cs
index bcef64a85f..2b37511660 100644
--- a/src/Microsoft.TestPlatform.Extensions.TrxLogger/TrxLogger.cs
+++ b/src/Microsoft.TestPlatform.Extensions.TrxLogger/TrxLogger.cs
@@ -342,11 +342,11 @@ internal void TestRunCompleteHandler(object? sender, TestRunCompleteEventArgs e)
helper.SaveIEnumerable(_entries.Values, rootElement, "TestEntries", ".", "TestEntry", parameters);
// Save default categories
- List categories = new()
- {
+ List categories =
+ [
TestListCategory.UncategorizedResults,
TestListCategory.AllResults
- };
+ ];
helper.SaveList(categories, rootElement, "TestLists", ".", "TestList", parameters);
// Save summary
@@ -357,7 +357,7 @@ internal void TestRunCompleteHandler(object? sender, TestRunCompleteEventArgs e)
TestResultOutcome = ChangeTestOutcomeIfNecessary(TestResultOutcome);
- List errorMessages = new();
+ List errorMessages = [];
List collectorEntries = _converter.ToCollectionEntries(e.AttachmentSets, LoggerTestRun, _testResultsDirPath);
IList resultFiles = _converter.ToResultFiles(e.AttachmentSets, LoggerTestRun, _testResultsDirPath, errorMessages);
diff --git a/src/Microsoft.TestPlatform.Extensions.TrxLogger/Utility/Converter.cs b/src/Microsoft.TestPlatform.Extensions.TrxLogger/Utility/Converter.cs
index bddab2bb64..3a8a7b69c1 100644
--- a/src/Microsoft.TestPlatform.Extensions.TrxLogger/Utility/Converter.cs
+++ b/src/Microsoft.TestPlatform.Extensions.TrxLogger/Utility/Converter.cs
@@ -278,10 +278,10 @@ public static List GetCustomPropertyValueFromTestCase(TestCase testCase,
if (customProperty != null)
{
var cateogryValues = (string[]?)testCase.GetPropertyValue(customProperty);
- return cateogryValues != null ? cateogryValues.ToList() : Enumerable.Empty().ToList();
+ return cateogryValues != null ? cateogryValues.ToList() : [];
}
- return Enumerable.Empty().ToList();
+ return [];
}
///
diff --git a/src/Microsoft.TestPlatform.Extensions.TrxLogger/Utility/TrxFileHelper.cs b/src/Microsoft.TestPlatform.Extensions.TrxLogger/Utility/TrxFileHelper.cs
index 58b2f6df05..8104df9806 100644
--- a/src/Microsoft.TestPlatform.Extensions.TrxLogger/Utility/TrxFileHelper.cs
+++ b/src/Microsoft.TestPlatform.Extensions.TrxLogger/Utility/TrxFileHelper.cs
@@ -183,7 +183,7 @@ public static string MakePathRelative(string path, string basePath)
path = Path.GetFullPath(path);
basePath = Path.GetFullPath(basePath);
- char[] delimiters = new char[] { Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar };
+ char[] delimiters = [Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar];
basePath = basePath.TrimEnd(delimiters);
path = path.TrimEnd(delimiters);
diff --git a/src/Microsoft.TestPlatform.Extensions.TrxLogger/XML/XmlPersistence.cs b/src/Microsoft.TestPlatform.Extensions.TrxLogger/XML/XmlPersistence.cs
index 8808c57314..1bae61bb92 100644
--- a/src/Microsoft.TestPlatform.Extensions.TrxLogger/XML/XmlPersistence.cs
+++ b/src/Microsoft.TestPlatform.Extensions.TrxLogger/XML/XmlPersistence.cs
@@ -706,7 +706,7 @@ private static string ReplaceInvalidCharacterWithUniCodeEscapeSequence(Match mat
}
else
{
- string[] parts = location.Split(new char[] { '/' }, 2);
+ string[] parts = location.Split(['/'], 2);
string firstPart = parts[0];
XmlNode? firstChild = LocationToXmlNode(xml, firstPart);
@@ -805,7 +805,7 @@ private string ProcessXPathQuery(string queryIn)
}
// fix the empty namespaces to a temp prefix, so xpath query can understand them
- string[] parts = queryIn.Split(new char[] { '/' }, StringSplitOptions.None);
+ string[] parts = queryIn.Split(['/'], StringSplitOptions.None);
StringBuilder query = new();
diff --git a/src/Microsoft.TestPlatform.ObjectModel/DataCollector/Common/RequestId.cs b/src/Microsoft.TestPlatform.ObjectModel/DataCollector/Common/RequestId.cs
index 583f2882c8..0f882551bd 100644
--- a/src/Microsoft.TestPlatform.ObjectModel/DataCollector/Common/RequestId.cs
+++ b/src/Microsoft.TestPlatform.ObjectModel/DataCollector/Common/RequestId.cs
@@ -133,7 +133,7 @@ public int CompareTo(object? obj)
RequestId? other = obj as RequestId;
return other == null
- ? throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, Resources.Resources.Common_ObjectMustBeOfType, new object[] { typeof(RequestId).Name }), nameof(obj))
+ ? throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, Resources.Resources.Common_ObjectMustBeOfType, [typeof(RequestId).Name]), nameof(obj))
: Id.CompareTo(other.Id);
}
diff --git a/src/Microsoft.TestPlatform.ObjectModel/DataCollector/TransferInformation/FileTransferInformation.cs b/src/Microsoft.TestPlatform.ObjectModel/DataCollector/TransferInformation/FileTransferInformation.cs
index 9f691969a4..45aed5c42c 100644
--- a/src/Microsoft.TestPlatform.ObjectModel/DataCollector/TransferInformation/FileTransferInformation.cs
+++ b/src/Microsoft.TestPlatform.ObjectModel/DataCollector/TransferInformation/FileTransferInformation.cs
@@ -60,7 +60,7 @@ public FileTransferInformation(DataCollectionContext context, string path, bool
// Make sure the file exists.
if (!_fileHelper.Exists(path))
{
- throw new FileNotFoundException(string.Format(CultureInfo.CurrentCulture, Resources.Resources.Common_FileNotExist, new object[] { path }), path);
+ throw new FileNotFoundException(string.Format(CultureInfo.CurrentCulture, Resources.Resources.Common_FileNotExist, [path]), path);
}
// Make sure the path we have is a full path (not relative).
diff --git a/src/Microsoft.TestPlatform.ObjectModel/Navigation/DiaSession.cs b/src/Microsoft.TestPlatform.ObjectModel/Navigation/DiaSession.cs
index d247c22514..1130173962 100644
--- a/src/Microsoft.TestPlatform.ObjectModel/Navigation/DiaSession.cs
+++ b/src/Microsoft.TestPlatform.ObjectModel/Navigation/DiaSession.cs
@@ -20,7 +20,7 @@ public class DiaSession : INavigationSession
///
/// Characters that should be stripped off the end of test names.
///
- private static readonly char[] TestNameStripChars = { '(', ')', ' ' };
+ private static readonly char[] TestNameStripChars = ['(', ')', ' '];
///
/// The symbol reader.
diff --git a/src/Microsoft.TestPlatform.ObjectModel/Nuget.Frameworks/DefaultFrameworkMappings.cs b/src/Microsoft.TestPlatform.ObjectModel/Nuget.Frameworks/DefaultFrameworkMappings.cs
index b1492de902..cc943d021a 100644
--- a/src/Microsoft.TestPlatform.ObjectModel/Nuget.Frameworks/DefaultFrameworkMappings.cs
+++ b/src/Microsoft.TestPlatform.ObjectModel/Nuget.Frameworks/DefaultFrameworkMappings.cs
@@ -11,7 +11,8 @@ internal sealed class DefaultFrameworkMappings : IFrameworkMappings
{
private static Lazy[]> IdentifierSynonymsLazy = new(() =>
{
- return new[]{
+ return
+ [
// .NET
new KeyValuePair("NETFramework", FrameworkConstants.FrameworkIdentifiers.Net),
new KeyValuePair(".NET", FrameworkConstants.FrameworkIdentifiers.Net),
@@ -31,8 +32,8 @@ internal sealed class DefaultFrameworkMappings : IFrameworkMappings
new KeyValuePair("XamarinPlayStationThree", FrameworkConstants.FrameworkIdentifiers.XamarinPlayStation3),
new KeyValuePair("Xamarin.PlayStationFour", FrameworkConstants.FrameworkIdentifiers.XamarinPlayStation4),
new KeyValuePair("XamarinPlayStationFour", FrameworkConstants.FrameworkIdentifiers.XamarinPlayStation4),
- new KeyValuePair("XamarinPlayStationVita", FrameworkConstants.FrameworkIdentifiers.XamarinPlayStationVita),
- };
+ new KeyValuePair("XamarinPlayStationVita", FrameworkConstants.FrameworkIdentifiers.XamarinPlayStationVita)
+ ];
});
public IEnumerable> IdentifierSynonyms
@@ -45,8 +46,8 @@ public IEnumerable> IdentifierSynonyms
private static readonly Lazy[]> IdentifierShortNamesLazy = new(() =>
{
- return new[]
- {
+ return
+ [
new KeyValuePair(FrameworkConstants.FrameworkIdentifiers.NetCoreApp, "netcoreapp"),
new KeyValuePair(FrameworkConstants.FrameworkIdentifiers.NetStandardApp, "netstandardapp"),
new KeyValuePair(FrameworkConstants.FrameworkIdentifiers.NetStandard, "netstandard"),
@@ -79,8 +80,8 @@ public IEnumerable> IdentifierSynonyms
new KeyValuePair(FrameworkConstants.FrameworkIdentifiers.WinRT, "winrt"), // legacy
new KeyValuePair(FrameworkConstants.FrameworkIdentifiers.UAP, "uap"),
new KeyValuePair(FrameworkConstants.FrameworkIdentifiers.Tizen, "tizen"),
- new KeyValuePair(FrameworkConstants.FrameworkIdentifiers.NanoFramework, "netnano"),
- };
+ new KeyValuePair(FrameworkConstants.FrameworkIdentifiers.NanoFramework, "netnano")
+ ];
});
public IEnumerable> IdentifierShortNames
@@ -93,14 +94,14 @@ public IEnumerable> IdentifierShortNames
private static readonly Lazy ProfileShortNamesLazy = new(() =>
{
- return new[]
- {
+ return
+ [
new FrameworkSpecificMapping(FrameworkConstants.FrameworkIdentifiers.Net, "Client", "Client"),
new FrameworkSpecificMapping(FrameworkConstants.FrameworkIdentifiers.Net, "CF", "CompactFramework"),
new FrameworkSpecificMapping(FrameworkConstants.FrameworkIdentifiers.Net, "Full", string.Empty),
new FrameworkSpecificMapping(FrameworkConstants.FrameworkIdentifiers.Silverlight, "WP", "WindowsPhone"),
- new FrameworkSpecificMapping(FrameworkConstants.FrameworkIdentifiers.Silverlight, "WP71", "WindowsPhone71"),
- };
+ new FrameworkSpecificMapping(FrameworkConstants.FrameworkIdentifiers.Silverlight, "WP71", "WindowsPhone71")
+ ];
});
public IEnumerable ProfileShortNames
@@ -113,8 +114,8 @@ public IEnumerable ProfileShortNames
private static readonly Lazy[]> EquivalentFrameworksLazy = new(() =>
{
- return new[]
- {
+ return
+ [
// UAP 0.0 <-> UAP 10.0
new KeyValuePair(
new NuGetFramework(FrameworkConstants.FrameworkIdentifiers.UAP, FrameworkConstants.EmptyVersion),
@@ -219,8 +220,8 @@ public IEnumerable ProfileShortNames
// dnxcore50 <-> aspnetcore50
new KeyValuePair(
FrameworkConstants.CommonFrameworks.DnxCore50,
- FrameworkConstants.CommonFrameworks.AspNetCore50),
- };
+ FrameworkConstants.CommonFrameworks.AspNetCore50)
+ ];
});
public IEnumerable> EquivalentFrameworks
@@ -233,14 +234,14 @@ public IEnumerable> EquivalentFrame
private static readonly Lazy EquivalentProfilesLazy = new(() =>
{
- return new[]
- {
+ return
+ [
// The client profile, for the purposes of NuGet, is the same as the full framework
new FrameworkSpecificMapping(FrameworkConstants.FrameworkIdentifiers.Net, "Client", string.Empty),
new FrameworkSpecificMapping(FrameworkConstants.FrameworkIdentifiers.Net, "Full", string.Empty),
new FrameworkSpecificMapping(FrameworkConstants.FrameworkIdentifiers.Silverlight, "WindowsPhone71", "WindowsPhone"),
- new FrameworkSpecificMapping(FrameworkConstants.FrameworkIdentifiers.WindowsPhone, "WindowsPhone71", "WindowsPhone"),
- };
+ new FrameworkSpecificMapping(FrameworkConstants.FrameworkIdentifiers.WindowsPhone, "WindowsPhone71", "WindowsPhone")
+ ];
});
public IEnumerable EquivalentProfiles
@@ -253,8 +254,8 @@ public IEnumerable EquivalentProfiles
private static readonly Lazy[]> SubSetFrameworksLazy = new(() =>
{
- return new[]
- {
+ return
+ [
// .NET is a subset of DNX
new KeyValuePair(
FrameworkConstants.FrameworkIdentifiers.Net,
@@ -269,7 +270,7 @@ public IEnumerable EquivalentProfiles
new KeyValuePair(
FrameworkConstants.FrameworkIdentifiers.NetStandard,
FrameworkConstants.FrameworkIdentifiers.NetStandardApp)
- };
+ ];
});
public IEnumerable> SubSetFrameworks
@@ -553,13 +554,13 @@ private static IEnumerable CreateGenerationAndS
private static readonly Lazy NonPackageBasedFrameworkPrecedenceLazy = new(() =>
{
- return new[]
- {
+ return
+ [
FrameworkConstants.FrameworkIdentifiers.Net,
FrameworkConstants.FrameworkIdentifiers.NetCore,
FrameworkConstants.FrameworkIdentifiers.Windows,
FrameworkConstants.FrameworkIdentifiers.WindowsPhoneApp
- };
+ ];
});
public IEnumerable NonPackageBasedFrameworkPrecedence
@@ -572,13 +573,13 @@ public IEnumerable NonPackageBasedFrameworkPrecedence
private static readonly Lazy PackageBasedFrameworkPrecedenceLazy = new(() =>
{
- return new[]
- {
+ return
+ [
FrameworkConstants.FrameworkIdentifiers.NetCoreApp,
FrameworkConstants.FrameworkIdentifiers.NetStandardApp,
FrameworkConstants.FrameworkIdentifiers.NetStandard,
FrameworkConstants.FrameworkIdentifiers.NetPlatform
- };
+ ];
});
public IEnumerable PackageBasedFrameworkPrecedence
@@ -591,8 +592,8 @@ public IEnumerable PackageBasedFrameworkPrecedence
private static readonly Lazy EquivalentFrameworkPrecedenceLazy = new(() =>
{
- return new[]
- {
+ return
+ [
FrameworkConstants.FrameworkIdentifiers.Windows,
FrameworkConstants.FrameworkIdentifiers.NetCore,
FrameworkConstants.FrameworkIdentifiers.WinRT,
@@ -605,7 +606,7 @@ public IEnumerable PackageBasedFrameworkPrecedence
FrameworkConstants.FrameworkIdentifiers.Dnx,
FrameworkConstants.FrameworkIdentifiers.AspNet
- };
+ ];
});
public IEnumerable EquivalentFrameworkPrecedence
@@ -618,10 +619,10 @@ public IEnumerable EquivalentFrameworkPrecedence
private static readonly Lazy[]> ShortNameReplacementsLazy = new(() =>
{
- return new[]
- {
+ return
+ [
new KeyValuePair(FrameworkConstants.CommonFrameworks.DotNet50, FrameworkConstants.CommonFrameworks.DotNet)
- };
+ ];
});
public IEnumerable> ShortNameReplacements
@@ -634,10 +635,10 @@ public IEnumerable> ShortNameReplac
private static readonly Lazy[]> FullNameReplacementsLazy = new(() =>
{
- return new[]
- {
+ return
+ [
new KeyValuePair(FrameworkConstants.CommonFrameworks.DotNet, FrameworkConstants.CommonFrameworks.DotNet50)
- };
+ ];
});
public IEnumerable> FullNameReplacements
diff --git a/src/Microsoft.TestPlatform.ObjectModel/Nuget.Frameworks/DefaultPortableFrameworkMappings.cs b/src/Microsoft.TestPlatform.ObjectModel/Nuget.Frameworks/DefaultPortableFrameworkMappings.cs
index d36320d326..bcb22c4a3e 100644
--- a/src/Microsoft.TestPlatform.ObjectModel/Nuget.Frameworks/DefaultPortableFrameworkMappings.cs
+++ b/src/Microsoft.TestPlatform.ObjectModel/Nuget.Frameworks/DefaultPortableFrameworkMappings.cs
@@ -32,8 +32,8 @@ internal class DefaultPortableFrameworkMappings : IPortableFrameworkMappings
var wpa81 = FrameworkConstants.CommonFrameworks.WPA81;
- return new[]
- {
+ return
+ [
// v4.6
CreateProfileFrameworks(31, win81, wp81),
CreateProfileFrameworks(32, win81, wpa81),
@@ -82,8 +82,8 @@ internal class DefaultPortableFrameworkMappings : IPortableFrameworkMappings
CreateProfileFrameworks(255, net45, sl5, win8, wpa81),
CreateProfileFrameworks(328, net4, sl5, win8, wpa81, wp8),
CreateProfileFrameworks(336, net403, sl5, win8, wpa81, wp8),
- CreateProfileFrameworks(344, net45, sl5, win8, wpa81, wp8),
- };
+ CreateProfileFrameworks(344, net45, sl5, win8, wpa81, wp8)
+ ];
});
public IEnumerable> ProfileFrameworks
@@ -101,9 +101,9 @@ private static KeyValuePair CreateProfileFrameworks(int p
// profiles that also support monotouch1+monoandroid1
private static readonly int[] ProfilesWithOptionalFrameworks =
- {
- 5, 6, 7, 14, 19, 24, 37, 42, 44, 47, 49, 78, 92, 102, 111, 136, 147, 151, 158, 225, 255, 259, 328, 336, 344
- };
+ [
+ 5, 6, 7, 14, 19, 24, 37, 42, 44, 47, 49, 78, 92, 102, 111, 136, 147, 151, 158, 225, 255, 259, 328, 336, 344
+ ];
private static readonly Lazy>> ProfileOptionalFrameworksLazy = new(() =>
{
@@ -135,8 +135,8 @@ public IEnumerable> ProfileOptionalFramework
private static readonly Lazy[]> CompatibilityMappingsLazy = new(() =>
{
- return new[]
- {
+ return
+ [
CreateStandardMapping(7, FrameworkConstants.CommonFrameworks.NetStandard11),
CreateStandardMapping(31, FrameworkConstants.CommonFrameworks.NetStandard10),
CreateStandardMapping(32, FrameworkConstants.CommonFrameworks.NetStandard12),
@@ -148,7 +148,7 @@ public IEnumerable> ProfileOptionalFramework
CreateStandardMapping(151, FrameworkConstants.CommonFrameworks.NetStandard12),
CreateStandardMapping(157, FrameworkConstants.CommonFrameworks.NetStandard10),
CreateStandardMapping(259, FrameworkConstants.CommonFrameworks.NetStandard10)
- };
+ ];
});
public IEnumerable> CompatibilityMappings
diff --git a/src/Microsoft.TestPlatform.ObjectModel/Nuget.Frameworks/FrameworkNameProvider.cs b/src/Microsoft.TestPlatform.ObjectModel/Nuget.Frameworks/FrameworkNameProvider.cs
index 4c810b6564..1a52d91003 100644
--- a/src/Microsoft.TestPlatform.ObjectModel/Nuget.Frameworks/FrameworkNameProvider.cs
+++ b/src/Microsoft.TestPlatform.ObjectModel/Nuget.Frameworks/FrameworkNameProvider.cs
@@ -341,7 +341,7 @@ private HashSet RemoveDuplicateFramework(IEnumerable RemoveDuplicateFramework(IEnumerable
- /// Get all equivalent frameworks including the given framework
- ///
+ ///
+ /// Get all equivalent frameworks including the given framework
+ ///
private HashSet GetAllEquivalentFrameworks(NuGetFramework framework)
{
- // Loop through the frameworks, all frameworks that are not in results yet
- // will be added to toProcess to get the equivalent frameworks
+ // Loop through the frameworks, all frameworks that are not in results yet
+ // will be added to toProcess to get the equivalent frameworks
var toProcess = new Stack();
var results = new HashSet();
@@ -486,7 +486,7 @@ public bool TryGetPortableFrameworks(string shortPortableProfiles, [NotNullWhen(
throw new ArgumentNullException(nameof(shortPortableProfiles));
}
- var shortNames = shortPortableProfiles.Split(new char[] { '+' }, StringSplitOptions.RemoveEmptyEntries);
+ var shortNames = shortPortableProfiles.Split(['+'], StringSplitOptions.RemoveEmptyEntries);
var result = new List();
foreach (var name in shortNames)
@@ -545,7 +545,7 @@ public bool TryGetPortableFrameworks(string profile, bool includeOptional, [NotN
return true;
}
- frameworks = Enumerable.Empty();
+ frameworks = [];
return false;
}
diff --git a/src/Microsoft.TestPlatform.ObjectModel/Nuget.Frameworks/FrameworkReducer.cs b/src/Microsoft.TestPlatform.ObjectModel/Nuget.Frameworks/FrameworkReducer.cs
index 097ee2f7ac..9c2ab2fd57 100644
--- a/src/Microsoft.TestPlatform.ObjectModel/Nuget.Frameworks/FrameworkReducer.cs
+++ b/src/Microsoft.TestPlatform.ObjectModel/Nuget.Frameworks/FrameworkReducer.cs
@@ -442,7 +442,7 @@ private IEnumerable ExplodePortableFramework(NuGetFramework pcl,
if (!_mappings.TryGetPortableFrameworks(pcl.Profile, includeOptional, out IEnumerable? frameworks))
{
Debug.Fail("Unable to get portable frameworks from: " + pcl.ToString());
- frameworks = Enumerable.Empty();
+ frameworks = [];
}
return frameworks;
diff --git a/src/Microsoft.TestPlatform.ObjectModel/Nuget.Frameworks/NuGetFrameworkFactory.cs b/src/Microsoft.TestPlatform.ObjectModel/Nuget.Frameworks/NuGetFrameworkFactory.cs
index 6d5329f20d..019fde8102 100644
--- a/src/Microsoft.TestPlatform.ObjectModel/Nuget.Frameworks/NuGetFrameworkFactory.cs
+++ b/src/Microsoft.TestPlatform.ObjectModel/Nuget.Frameworks/NuGetFrameworkFactory.cs
@@ -136,7 +136,7 @@ internal static NuGetFramework ParseComponents(string targetFrameworkMoniker, st
return result;
}
- private static readonly char[] CommaSeparator = new char[] { ',' };
+ private static readonly char[] CommaSeparator = [','];
private static string[] GetParts(string targetPlatformMoniker)
{
diff --git a/src/Microsoft.TestPlatform.ObjectModel/TestCase.cs b/src/Microsoft.TestPlatform.ObjectModel/TestCase.cs
index d949ede703..b9c260fb9f 100644
--- a/src/Microsoft.TestPlatform.ObjectModel/TestCase.cs
+++ b/src/Microsoft.TestPlatform.ObjectModel/TestCase.cs
@@ -339,7 +339,7 @@ public static class TestCaseProperties
public static readonly TestProperty LineNumber = TestProperty.Register("TestCase.LineNumber", LineNumberLabel, typeof(int), TestPropertyAttributes.Hidden, typeof(TestCase));
internal static TestProperty[] Properties { get; } =
- {
+ [
CodeFilePath,
DisplayName,
ExecutorUri,
@@ -347,7 +347,7 @@ public static class TestCaseProperties
Id,
LineNumber,
Source
- };
+ ];
private static bool ValidateName(object? value)
{
diff --git a/src/Microsoft.TestPlatform.ObjectModel/TestProperty/CustomKeyValueConverter.cs b/src/Microsoft.TestPlatform.ObjectModel/TestProperty/CustomKeyValueConverter.cs
index b1baf611a5..75f4742a45 100644
--- a/src/Microsoft.TestPlatform.ObjectModel/TestProperty/CustomKeyValueConverter.cs
+++ b/src/Microsoft.TestPlatform.ObjectModel/TestProperty/CustomKeyValueConverter.cs
@@ -45,7 +45,7 @@ public override bool CanConvertFrom(ITypeDescriptorContext? context, Type source
using var stream = new MemoryStream(Encoding.Unicode.GetBytes(data));
// Converting Json data to array of KeyValuePairs with duplicate keys.
var listOfTraitObjects = _serializer.ReadObject(stream) as TraitObject[];
- return listOfTraitObjects?.Select(trait => new KeyValuePair(trait.Key, trait.Value)).ToArray() ?? new KeyValuePair[0];
+ return listOfTraitObjects?.Select(trait => new KeyValuePair(trait.Key, trait.Value)).ToArray() ?? [];
}
return null;
diff --git a/src/Microsoft.TestPlatform.ObjectModel/TestResult.cs b/src/Microsoft.TestPlatform.ObjectModel/TestResult.cs
index 35838f1b31..7e9c33c528 100644
--- a/src/Microsoft.TestPlatform.ObjectModel/TestResult.cs
+++ b/src/Microsoft.TestPlatform.ObjectModel/TestResult.cs
@@ -320,7 +320,7 @@ public static class TestResultProperties
public static readonly TestProperty ErrorStackTrace = TestProperty.Register("TestResult.ErrorStackTrace", Resources.Resources.TestResultPropertyErrorStackTraceLabel, typeof(string), typeof(TestResult));
#endif
internal static TestProperty[] Properties { get; } =
- {
+ [
ComputerName,
DisplayName,
Duration,
@@ -329,7 +329,7 @@ public static class TestResultProperties
ErrorStackTrace,
Outcome,
StartTime
- };
+ ];
private static bool ValidateOutcome(object? value)
{
diff --git a/src/Microsoft.TestPlatform.ObjectModel/Utilities/AssemblyLoadWorker.cs b/src/Microsoft.TestPlatform.ObjectModel/Utilities/AssemblyLoadWorker.cs
index 545e3bcfad..aefba93a27 100644
--- a/src/Microsoft.TestPlatform.ObjectModel/Utilities/AssemblyLoadWorker.cs
+++ b/src/Microsoft.TestPlatform.ObjectModel/Utilities/AssemblyLoadWorker.cs
@@ -96,7 +96,7 @@ internal static string GetTargetFrameworkStringFromAssembly(Assembly assembly)
AssemblyName[] assemblies = a.GetReferencedAssemblies();
return assemblies == null || assemblies.Length == 0
- ? (new string[0])
+ ? ([])
: (from assembly in assemblies
select assembly.FullName).ToArray();
}
diff --git a/src/Microsoft.TestPlatform.ObjectModel/Utilities/FilterHelper.cs b/src/Microsoft.TestPlatform.ObjectModel/Utilities/FilterHelper.cs
index 7056264d71..eda82c44ca 100644
--- a/src/Microsoft.TestPlatform.ObjectModel/Utilities/FilterHelper.cs
+++ b/src/Microsoft.TestPlatform.ObjectModel/Utilities/FilterHelper.cs
@@ -11,7 +11,7 @@ namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.Utilities;
public static class FilterHelper
{
public const char EscapeCharacter = '\\';
- private static readonly char[] SpecialCharacters = { '\\', '(', ')', '&', '|', '=', '!', '~' };
+ private static readonly char[] SpecialCharacters = ['\\', '(', ')', '&', '|', '=', '!', '~'];
private static readonly HashSet SpecialCharactersSet = new(SpecialCharacters);
///
diff --git a/src/Microsoft.TestPlatform.Utilities/CodeCoverageDataAttachmentsHandler.cs b/src/Microsoft.TestPlatform.Utilities/CodeCoverageDataAttachmentsHandler.cs
index be2a1030f3..2a8241906c 100644
--- a/src/Microsoft.TestPlatform.Utilities/CodeCoverageDataAttachmentsHandler.cs
+++ b/src/Microsoft.TestPlatform.Utilities/CodeCoverageDataAttachmentsHandler.cs
@@ -129,7 +129,7 @@ public async Task> ProcessAttachmentSetsAsync(XmlElem
TPDebug.Assert(s_mergeOperationEnumValues != null);
- var task = (Task)s_mergeMethodInfo.Invoke(s_classInstance, new object[] { files[0], files, s_mergeOperationEnumValues.GetValue(0)!, true, cancellationToken })!;
+ var task = (Task)s_mergeMethodInfo.Invoke(s_classInstance, [files[0], files, s_mergeOperationEnumValues.GetValue(0)!, true, cancellationToken])!;
await task.ConfigureAwait(false);
if (task.GetType().GetProperty("Result")!.GetValue(task, null) is not IList mergedResults)
@@ -176,6 +176,6 @@ private static void LoadCodeCoverageAssembly()
var types = s_codeCoverageAssembly.GetTypes();
var mergeOperationEnum = Array.Find(types, d => d.Name == CoverageMergeOperationName)!;
s_mergeOperationEnumValues = Enum.GetValues(mergeOperationEnum);
- s_mergeMethodInfo = classType.GetMethod(MergeMethodName, new[] { typeof(string), typeof(IList), mergeOperationEnum, typeof(bool), typeof(CancellationToken) })!;
+ s_mergeMethodInfo = classType.GetMethod(MergeMethodName, [typeof(string), typeof(IList), mergeOperationEnum, typeof(bool), typeof(CancellationToken)])!;
}
}
diff --git a/src/Microsoft.TestPlatform.Utilities/InferRunSettingsHelper.cs b/src/Microsoft.TestPlatform.Utilities/InferRunSettingsHelper.cs
index 2488ff2d4d..8d28e6c5dc 100644
--- a/src/Microsoft.TestPlatform.Utilities/InferRunSettingsHelper.cs
+++ b/src/Microsoft.TestPlatform.Utilities/InferRunSettingsHelper.cs
@@ -55,7 +55,11 @@ public class InferRunSettingsHelper
private const string LegacyElementsString = "Elements";
private const string DeploymentAttributesString = "DeploymentAttributes";
private const string ExecutionAttributesString = "ExecutionAttributes";
- private static readonly List ExecutionNodesPaths = new() { @"/RunSettings/LegacySettings/Execution/TestTypeSpecific/UnitTestRunConfig/AssemblyResolution", @"/RunSettings/LegacySettings/Execution/Timeouts", @"/RunSettings/LegacySettings/Execution/Hosts" };
+ private static readonly List ExecutionNodesPaths =
+ [
+ @"/RunSettings/LegacySettings/Execution/TestTypeSpecific/UnitTestRunConfig/AssemblyResolution",
+ @"/RunSettings/LegacySettings/Execution/Timeouts", @"/RunSettings/LegacySettings/Execution/Hosts"
+ ];
///
/// Make runsettings compatible with testhost of version 15.0.0-preview
diff --git a/src/Microsoft.TestPlatform.VsTestConsole.TranslationLayer/VsTestConsoleWrapper.cs b/src/Microsoft.TestPlatform.VsTestConsole.TranslationLayer/VsTestConsoleWrapper.cs
index ea17ec6555..e3b99521c7 100644
--- a/src/Microsoft.TestPlatform.VsTestConsole.TranslationLayer/VsTestConsoleWrapper.cs
+++ b/src/Microsoft.TestPlatform.VsTestConsole.TranslationLayer/VsTestConsoleWrapper.cs
@@ -1155,7 +1155,7 @@ public Task ProcessTestRunAttachmentsAsync(
bool collectMetrics,
ITestRunAttachmentsProcessingEventsHandler testSessionEventsHandler,
CancellationToken cancellationToken)
- => ProcessTestRunAttachmentsAsync(attachments, Enumerable.Empty(), processingSettings, isLastBatch, collectMetrics, testSessionEventsHandler, cancellationToken);
+ => ProcessTestRunAttachmentsAsync(attachments, [], processingSettings, isLastBatch, collectMetrics, testSessionEventsHandler, cancellationToken);
#endregion
diff --git a/src/testhost.x86/AppDomainEngineInvoker.cs b/src/testhost.x86/AppDomainEngineInvoker.cs
index 0401e6bc32..344790949b 100644
--- a/src/testhost.x86/AppDomainEngineInvoker.cs
+++ b/src/testhost.x86/AppDomainEngineInvoker.cs
@@ -106,7 +106,7 @@ private static IEngineInvoker CreateInvokerInAppDomain(AppDomain appDomain)
false,
BindingFlags.Default,
null,
- new object?[] { CultureInfo.DefaultThreadCurrentUICulture?.Name, Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) },
+ [CultureInfo.DefaultThreadCurrentUICulture?.Name, Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)],
null,
null);
@@ -247,7 +247,7 @@ public CustomAssemblySetup(string uiCulture, string testPlatformPath)
CultureInfo.DefaultThreadCurrentUICulture = CultureInfo.CreateSpecificCulture(uiCulture);
}
- _resolverPaths = new string[] { testPlatformPath, Path.Combine(testPlatformPath, "Extensions") };
+ _resolverPaths = [testPlatformPath, Path.Combine(testPlatformPath, "Extensions")];
_resolvedAssemblies = new Dictionary();
AppDomain.CurrentDomain.AssemblyResolve += CurrentDomain_AssemblyResolve;
}
diff --git a/src/testhost.x86/UnitTestClient.cs b/src/testhost.x86/UnitTestClient.cs
index b28b0f4ce8..de0f39cfa6 100644
--- a/src/testhost.x86/UnitTestClient.cs
+++ b/src/testhost.x86/UnitTestClient.cs
@@ -55,6 +55,6 @@ internal static string[] SplitArguments(string commandLine)
parmChars[index] = '\n';
}
- return (new string(parmChars)).Split(new[] { '\n' });
+ return (new string(parmChars)).Split(['\n']);
}
}
diff --git a/src/vstest.console/CommandLine/Executor.cs b/src/vstest.console/CommandLine/Executor.cs
index beb8185b71..951a4166e1 100644
--- a/src/vstest.console/CommandLine/Executor.cs
+++ b/src/vstest.console/CommandLine/Executor.cs
@@ -141,7 +141,7 @@ internal int Execute(params string[]? args)
if (args == null || args.Length == 0 || args.Any(StringUtils.IsNullOrWhiteSpace))
{
Output.Error(true, CommandLineResources.NoArgumentsProvided);
- args = new string[] { HelpArgumentProcessor.CommandName };
+ args = [HelpArgumentProcessor.CommandName];
exitCode = 1;
}
diff --git a/src/vstest.console/Internal/FilePatternParser.cs b/src/vstest.console/Internal/FilePatternParser.cs
index 918d7a3805..804739ca7e 100644
--- a/src/vstest.console/Internal/FilePatternParser.cs
+++ b/src/vstest.console/Internal/FilePatternParser.cs
@@ -27,7 +27,7 @@ public class FilePatternParser
{
private readonly Matcher _matcher;
private readonly IFileHelper _fileHelper;
- private readonly char[] _wildCardCharacters = { '*' };
+ private readonly char[] _wildCardCharacters = ['*'];
public FilePatternParser()
: this(new Matcher(), new FileHelper())
diff --git a/src/vstest.console/Processors/CollectArgumentProcessor.cs b/src/vstest.console/Processors/CollectArgumentProcessor.cs
index 2a6ea0761f..c050e85f22 100644
--- a/src/vstest.console/Processors/CollectArgumentProcessor.cs
+++ b/src/vstest.console/Processors/CollectArgumentProcessor.cs
@@ -241,7 +241,7 @@ private static bool DoesDataCollectorSettingsExist(string friendlyName,
internal static void AddDataCollectorToRunSettings(string arguments, IRunSettingsProvider runSettingsManager, IFileHelper fileHelper)
{
- AddDataCollectorToRunSettings(new string[] { arguments }, runSettingsManager, fileHelper, string.Empty);
+ AddDataCollectorToRunSettings([arguments], runSettingsManager, fileHelper, string.Empty);
}
internal static void AddDataCollectorToRunSettings(string[] arguments, IRunSettingsProvider runSettingsManager, IFileHelper fileHelper, string exceptionMessage)
diff --git a/src/vstest.console/Processors/EnableCodeCoverageArgumentProcessor.cs b/src/vstest.console/Processors/EnableCodeCoverageArgumentProcessor.cs
index 783e2d967c..21b04d3976 100644
--- a/src/vstest.console/Processors/EnableCodeCoverageArgumentProcessor.cs
+++ b/src/vstest.console/Processors/EnableCodeCoverageArgumentProcessor.cs
@@ -77,7 +77,8 @@ internal class EnableCodeCoverageArgumentExecutor : IArgumentExecutor
internal const string FriendlyName = "Code Coverage";
private static readonly string XPathSeperator = "/";
- private static readonly string[] NodeNames = new string[] { Constants.RunSettingsName, Constants.DataCollectionRunSettingsName, Constants.DataCollectorsSettingName, Constants.DataCollectorSettingName };
+ private static readonly string[] NodeNames = [Constants.RunSettingsName, Constants.DataCollectionRunSettingsName, Constants.DataCollectorsSettingName, Constants.DataCollectorSettingName
+ ];
#region Default CodeCoverage Settings String
@@ -258,7 +259,7 @@ private static string GetMissingNodesTextIfAny(string existingPath, string fullp
{
var xmlText = "{0}";
var nonExistingPath = fullpath.Substring(existingPath.Length);
- var requiredNodeNames = nonExistingPath.Split(new char[] { '/' }, StringSplitOptions.RemoveEmptyEntries);
+ var requiredNodeNames = nonExistingPath.Split(['/'], StringSplitOptions.RemoveEmptyEntries);
var format = "<{0}>{1}{0}>";
foreach (var nodeName in requiredNodeNames)
diff --git a/src/vstest.console/Processors/TestAdapterLoadingStrategyArgumentProcessor.cs b/src/vstest.console/Processors/TestAdapterLoadingStrategyArgumentProcessor.cs
index 92b4a73e74..5fcb2d2b99 100644
--- a/src/vstest.console/Processors/TestAdapterLoadingStrategyArgumentProcessor.cs
+++ b/src/vstest.console/Processors/TestAdapterLoadingStrategyArgumentProcessor.cs
@@ -195,7 +195,7 @@ private void ForceIsolation()
private void ValidateTestAdapterPaths(TestAdapterLoadingStrategy strategy)
{
- var testAdapterPaths = _commandLineOptions.TestAdapterPath ?? new string[0];
+ var testAdapterPaths = _commandLineOptions.TestAdapterPath ?? [];
if (!_commandLineOptions.TestAdapterPathsSet)
{
testAdapterPaths = TestAdapterPathArgumentExecutor.SplitPaths(_runSettingsManager.QueryRunSettingsNode(TestAdapterPathArgumentExecutor.RunSettingsPath)).Union(testAdapterPaths).Distinct().ToArray();
diff --git a/src/vstest.console/Processors/TestAdapterPathArgumentProcessor.cs b/src/vstest.console/Processors/TestAdapterPathArgumentProcessor.cs
index 2c1ab3f7b0..701d1b37ce 100644
--- a/src/vstest.console/Processors/TestAdapterPathArgumentProcessor.cs
+++ b/src/vstest.console/Processors/TestAdapterPathArgumentProcessor.cs
@@ -96,7 +96,7 @@ internal class TestAdapterPathArgumentExecutor : IArgumentExecutor
///
/// Separators for multiple paths in argument.
///
- internal readonly static char[] ArgumentSeparators = new[] { ';' };
+ internal readonly static char[] ArgumentSeparators = [';'];
public const string RunSettingsPath = "RunConfiguration.TestAdaptersPaths";
@@ -132,7 +132,7 @@ public void Initialize(string? argument)
// VSTS task add double quotes around TestAdapterpath. For example if user has given TestAdapter path C:\temp,
// Then VSTS task will add TestAdapterPath as "/TestAdapterPath:\"C:\Temp\"".
// Remove leading and trailing ' " ' chars...
- argument = argument.Trim().Trim(new char[] { '\"' });
+ argument = argument.Trim().Trim(['\"']);
// Get test adapter paths from RunSettings.
var testAdapterPathsInRunSettings = _runSettingsManager.QueryRunSettingsNode(RunSettingsPath);
@@ -167,6 +167,6 @@ public ArgumentProcessorResult Execute()
/// Paths.
internal static string[] SplitPaths(string? paths)
{
- return paths.IsNullOrWhiteSpace() ? new string[0] : paths.Split(ArgumentSeparators, StringSplitOptions.RemoveEmptyEntries);
+ return paths.IsNullOrWhiteSpace() ? [] : paths.Split(ArgumentSeparators, StringSplitOptions.RemoveEmptyEntries);
}
}
diff --git a/src/vstest.console/Processors/Utilities/ArgumentProcessorUtilities.cs b/src/vstest.console/Processors/Utilities/ArgumentProcessorUtilities.cs
index a5744648cd..99f9130d39 100644
--- a/src/vstest.console/Processors/Utilities/ArgumentProcessorUtilities.cs
+++ b/src/vstest.console/Processors/Utilities/ArgumentProcessorUtilities.cs
@@ -8,8 +8,8 @@ namespace Microsoft.VisualStudio.TestPlatform.CommandLine.Processors.Utilities;
internal class ArgumentProcessorUtilities
{
- public static readonly char[] SemiColonArgumentSeparator = { ';' };
- public static readonly char[] EqualNameValueSeparator = { '=' };
+ public static readonly char[] SemiColonArgumentSeparator = [';'];
+ public static readonly char[] EqualNameValueSeparator = ['='];
///
/// Get argument list from raw argument using argument separator.
diff --git a/test/DataCollectors/Microsoft.TestPlatform.Extensions.EventLogCollector.UnitTests/EventLogDataCollectorTests.cs b/test/DataCollectors/Microsoft.TestPlatform.Extensions.EventLogCollector.UnitTests/EventLogDataCollectorTests.cs
index abf09de509..43923342e1 100644
--- a/test/DataCollectors/Microsoft.TestPlatform.Extensions.EventLogCollector.UnitTests/EventLogDataCollectorTests.cs
+++ b/test/DataCollectors/Microsoft.TestPlatform.Extensions.EventLogCollector.UnitTests/EventLogDataCollectorTests.cs
@@ -95,11 +95,11 @@ public void InitializeShouldThrowExceptionIfLoggerIsNull()
[TestMethod]
public void InitializeShouldInitializeDefaultEventLogNames()
{
- List eventLogNames = new()
- {
+ List eventLogNames =
+ [
"System",
"Application"
- };
+ ];
_eventLogDataCollector.Initialize(null, _mockDataCollectionEvents.Object, _mockDataCollectionSink, _mockDataCollectionLogger.Object, _dataCollectionEnvironmentContext);
@@ -113,11 +113,11 @@ public void InitializeShouldInitializeCustomEventLogNamesIfSpecifiedInConfigurat
string configurationString =
@"";
- List eventLogNames = new()
- {
+ List eventLogNames =
+ [
"MyEventName",
"MyEventName2"
- };
+ ];
XmlDocument expectedXmlDoc = new();
expectedXmlDoc.LoadXml(configurationString);
@@ -131,12 +131,12 @@ public void InitializeShouldInitializeCustomEventLogNamesIfSpecifiedInConfigurat
[TestMethod]
public void InitializeShouldInitializeDefaultLogEntryTypes()
{
- List entryTypes = new()
- {
+ List entryTypes =
+ [
EventLogEntryType.Error,
EventLogEntryType.Warning,
EventLogEntryType.FailureAudit
- };
+ ];
_eventLogDataCollector.Initialize(null, _mockDataCollectionEvents.Object, _mockDataCollectionSink, _mockDataCollectionLogger.Object, _dataCollectionEnvironmentContext);
@@ -150,10 +150,7 @@ public void InitializeShouldInitializeEntryTypesIfSpecifiedInConfiguration()
string configurationString =
@"";
- List entryTypes = new()
- {
- EventLogEntryType.Error
- };
+ List entryTypes = [EventLogEntryType.Error];
XmlDocument expectedXmlDoc = new();
expectedXmlDoc.LoadXml(configurationString);
@@ -169,10 +166,7 @@ public void InitializeShouldInitializeEventSourcesIfSpecifiedInConfiguration()
string configurationString =
@"";
- List eventSources = new()
- {
- "MyEventSource"
- };
+ List eventSources = ["MyEventSource"];
XmlDocument expectedXmlDoc = new();
expectedXmlDoc.LoadXml(configurationString);
diff --git a/test/Intent/Runner.cs b/test/Intent/Runner.cs
index 6edf62eb0f..cbe7706cba 100644
--- a/test/Intent/Runner.cs
+++ b/test/Intent/Runner.cs
@@ -62,7 +62,7 @@ public static void Run(IEnumerable paths, IRunLogger logger)
// Declaring type cannot be really null for types you define in C#
// without doing any reflection magic.
var instance = Activator.CreateInstance(method.DeclaringType!);
- var testResult = method.Invoke(instance, Array.Empty