style: use range operators and is-null pattern in new PR files - #9737
Conversation
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>
There was a problem hiding this comment.
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 inMSTestTestNodeConverter.cs(IDE0057 preference). - Replaced
== nullwithis nullinTestMethodRunner.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
There was a problem hiding this comment.
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.
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.Substringcalls 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—== nullreplaced withis null.Multi-TFM
A full
build.cmdsucceeded with 0 warnings / 0 errors across every target framework (net462, net472, net48, net8.0, net9.0, uap10.0, …). Range indexing onstringis lowered by the C# compiler toSubstring, so it works on all TFMs without any polyfill.Testing
is nullare semantically equivalent to the originals.