From aa4202e98100eca53f6d0a163a2545ec0eab82c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Amaury=20Lev=C3=A9?= Date: Wed, 8 Jul 2026 16:26:08 +0200 Subject: [PATCH] style: use range operators and is-null pattern in new PR files Apply two project-convention improvements to files added in recent PRs: - MSTestTestNodeConverter.cs: replace Substring calls with range operators per csharp_style_prefer_range_operator = true (IDE0057) - TestMethodRunner.DataSource.cs: replace == null with is null per the project's 'always use is null / is not null' rule Fixes #9734 Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> --- .../TestingPlatformAdapter/MSTestTestNodeConverter.cs | 6 +++--- .../Execution/TestMethodRunner.DataSource.cs | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Adapter/MSTest.TestAdapter/TestingPlatformAdapter/MSTestTestNodeConverter.cs b/src/Adapter/MSTest.TestAdapter/TestingPlatformAdapter/MSTestTestNodeConverter.cs index 32f825b045..c407fb6303 100644 --- a/src/Adapter/MSTest.TestAdapter/TestingPlatformAdapter/MSTestTestNodeConverter.cs +++ b/src/Adapter/MSTest.TestAdapter/TestingPlatformAdapter/MSTestTestNodeConverter.cs @@ -150,8 +150,8 @@ private static void AddTestMethodIdentifier(TestNode testNode, TestMethod testMe parameterTypes ??= []; int lastIndexOfDot = managedType.LastIndexOf('.'); - string @namespace = lastIndexOfDot == -1 ? string.Empty : managedType.Substring(0, lastIndexOfDot); - string typeName = lastIndexOfDot == -1 ? managedType : managedType.Substring(lastIndexOfDot + 1); + string @namespace = lastIndexOfDot == -1 ? string.Empty : managedType[..lastIndexOfDot]; + string typeName = lastIndexOfDot == -1 ? managedType : managedType[(lastIndexOfDot + 1)..]; // AssemblyFullName and ReturnTypeFullName are not carried by the neutral model today; kept empty to match // the current (bridge) behavior. Populating them is a follow-up enabled by this native path. @@ -305,7 +305,7 @@ private static bool TryParseFullyQualifiedType(string fullyQualifiedName, [NotNu return false; } - fullyQualifiedType = fullyQualifiedName.Substring(0, lastDotIndexBeforeOpenBracket); + fullyQualifiedType = fullyQualifiedName[..lastDotIndexBeforeOpenBracket]; return true; } } diff --git a/src/Adapter/MSTestAdapter.PlatformServices/Execution/TestMethodRunner.DataSource.cs b/src/Adapter/MSTestAdapter.PlatformServices/Execution/TestMethodRunner.DataSource.cs index 2c71dc5035..137aec3408 100644 --- a/src/Adapter/MSTestAdapter.PlatformServices/Execution/TestMethodRunner.DataSource.cs +++ b/src/Adapter/MSTestAdapter.PlatformServices/Execution/TestMethodRunner.DataSource.cs @@ -52,7 +52,7 @@ private async Task ExecuteTestFromDataSourceAttributeAsync(List resu try { IEnumerable? dataRows = PlatformServiceProvider.Instance.TestDataSource.GetData(_testMethodInfo, _testContext); - if (dataRows == null) + if (dataRows is null) { var inconclusiveResult = new TestResult {