Skip to content

[code-simplifier] style: use range operators and is-null pattern in new PR files #9734

Description

@github-actions

Code Simplification — 2026-07-08

This PR applies two project-convention fixes to source files that were added in recent pull requests, aligning them with the coding standards enforced in .editorconfig.

Files Simplified

  • src/Adapter/MSTest.TestAdapter/TestingPlatformAdapter/MSTestTestNodeConverter.cs — 3× String.Substring calls replaced with C# range operators
  • src/Adapter/MSTestAdapter.PlatformServices/Execution/TestMethodRunner.DataSource.cs== null null-check replaced with the is null pattern

Improvements Made

  1. Range operators instead of Substring (MSTestTestNodeConverter.cs)

    • .editorconfig sets csharp_style_prefer_range_operator = true:warning (IDE0057)
    • Three call sites converted:
      • managedType.Substring(0, lastIndexOfDot)managedType[..lastIndexOfDot]
      • managedType.Substring(lastIndexOfDot + 1)managedType[(lastIndexOfDot + 1)..]
      • fullyQualifiedName.Substring(0, lastDotIndexBeforeOpenBracket)fullyQualifiedName[..lastDotIndexBeforeOpenBracket]
  2. is null / is not null null checks (TestMethodRunner.DataSource.cs)

    • Project convention: "Always use is null or is not null instead of == null or != null"
    • if (dataRows == null)if (dataRows is null)

Changes Based On

Recent changes from:

Testing

  • MSTest.TestAdapter project builds with 0 errors (net9.0)
  • MSTestAdapter.PlatformServices project builds with 0 errors (net9.0)
  • ✅ No functional changes — behavior is identical (range operators and is null are equivalent)

Review Focus

Please verify:

  • Simplifications match .editorconfig conventions (IDE0057 range operator, is-null pattern)
  • No unintended behavioral changes (these are purely syntactic)

🤖 Automated content by GitHub Copilot. Generated by the Code Simplifier workflow. · 260.7 AIC · ⌖ 17.7 AIC · ⊞ 9.3K · [◷]( · )

Add this agentic workflows to your repo

To install this agentic workflow, run

gh aw add githubnext/agentics/workflows/code-simplifier.md@main
  • expires on Jul 9, 2026, 1:56 PM UTC

Note

This was originally intended as a pull request, but GitHub Actions is not permitted to create or approve pull requests in this repository.
The changes have been pushed to branch code-simplifier/range-operators-null-patterns-7bc8cb645c330a4b.

Click here to create the pull request

To fix the permissions issue, go to SettingsActionsGeneral and enable Allow GitHub Actions to create and approve pull requests. See also: gh-aw FAQ

Show patch preview (62 of 62 lines)
From 01182c12bce657dca33d9433385105e734ec00b2 Mon Sep 17 00:00:00 2001
From: "github-actions[bot]" <github-actions[bot]@users.noreply.github.com>
Date: Wed, 8 Jul 2026 13:53:57 +0000
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 (added in #9706): replace Substring calls
  with range operators per csharp_style_prefer_range_operator = true
- TestMethodRunner.DataSource.cs (added in #9729): replace == null with
  is null per the project's 'always use is null / is not null' rule

No behavioral change; builds verified to succeed with 0 errors.

Co-authored-by: Copilot <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 32f825b..c407fb6 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
... (truncated)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions