Skip to content

style: use range operators and is-null pattern in new PR files - #9737

Merged
Evangelink merged 1 commit into
mainfrom
dev/amauryleve/code-simplifier-range-null-patterns
Jul 8, 2026
Merged

style: use range operators and is-null pattern in new PR files#9737
Evangelink merged 1 commit into
mainfrom
dev/amauryleve/code-simplifier-range-null-patterns

Conversation

@Evangelink

Copy link
Copy Markdown
Member

Summary

Fixes #9734. Applies two .editorconfig-convention fixes to source files added in recent PRs.

Changes

  • src/Adapter/MSTest.TestAdapter/TestingPlatformAdapter/MSTestTestNodeConverter.cs — 3× String.Substring calls replaced with C# range operators (IDE0057 / csharp_style_prefer_range_operator):
    • managedType.Substring(0, lastIndexOfDot)managedType[..lastIndexOfDot]
    • managedType.Substring(lastIndexOfDot + 1)managedType[(lastIndexOfDot + 1)..]
    • fullyQualifiedName.Substring(0, lastDotIndexBeforeOpenBracket)fullyQualifiedName[..lastDotIndexBeforeOpenBracket]
  • src/Adapter/MSTestAdapter.PlatformServices/Execution/TestMethodRunner.DataSource.cs== null replaced with is null.

Multi-TFM

A full build.cmd succeeded with 0 warnings / 0 errors across every target framework (net462, net472, net48, net8.0, net9.0, uap10.0, …). Range indexing on string is lowered by the C# compiler to Substring, so it works on all TFMs without any polyfill.

Testing

  • ✅ Full repo build succeeds, all TFMs, 0 warnings / 0 errors.
  • No functional changes — range operators and is null are semantically equivalent to the originals.

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>
Copilot AI review requested due to automatic review settings July 8, 2026 14:27

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR aligns two recently added adapter source files with existing .editorconfig style conventions by adopting C# range operators for string slicing and the is null pattern for null checks.

Changes:

  • Replaced string.Substring(...) usages with range-operator slicing in MSTestTestNodeConverter.cs (IDE0057 preference).
  • Replaced == null with is null in TestMethodRunner.DataSource.cs.
Show a summary per file
File Description
src/Adapter/MSTest.TestAdapter/TestingPlatformAdapter/MSTestTestNodeConverter.cs Uses range operators ([..], [(i)..]) instead of Substring while preserving the existing index guards.
src/Adapter/MSTestAdapter.PlatformServices/Execution/TestMethodRunner.DataSource.cs Switches to is null for the dataRows null check to match repo conventions.

Review details

  • Files reviewed: 2/2 changed files
  • Comments generated: 0
  • Review effort level: Low

@Evangelink Evangelink added the state/needs-review Awaiting review from the team. label Jul 8, 2026
@Evangelink
Evangelink enabled auto-merge (squash) July 8, 2026 14:32

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note

🤖 Automated review by GitHub Copilot. Generated by the Expert Code Review workflow. To request a follow-up action, reply by tagging @copilot directly.

✅ 22/22 dimensions clean — no findings.

Both transformations are semantically equivalent to their originals (string[..n] lowers to Substring(0, n) by the compiler; is null uses pattern matching with no behavioral difference for reference types without custom ==). The changes align with the .editorconfig conventions (csharp_style_prefer_range_operator = true:warning, dotnet_style_prefer_is_null_check_over_reference_equality_method = true:warning) and require no polyfill on any target framework.

@Evangelink
Evangelink disabled auto-merge July 8, 2026 16:46
@Evangelink
Evangelink merged commit da2374a into main Jul 8, 2026
32 of 35 checks passed
@Evangelink
Evangelink deleted the dev/amauryleve/code-simplifier-range-null-patterns branch July 8, 2026 16:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

state/needs-review Awaiting review from the team.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

3 participants