Skip to content

[code-simplifier] Remove redundant .ToString() in TimingInfo.ToString() #7955

@Evangelink

Description

@Evangelink

Code Simplification — 2026-04-30

This PR simplifies a minor inconsistency introduced as part of the file-split refactoring in #7940.

File Simplified

  • src/Platform/Microsoft.Testing.Platform/Messages/TimingProperties.cs — Removed redundant .ToString() call in TimingInfo.ToString()

Improvement Made

Removed redundant .ToString() call for consistency

StringBuilder.Append(Duration.ToString()) is functionally identical to StringBuilder.Append(Duration)StringBuilder.Append already calls ToString() internally. The surrounding Append calls in the same method (StartTime, EndTime) already follow the concise form without explicit .ToString():

// Before
builder.Append($", {nameof(Duration)} = ");
builder.Append(Duration.ToString());

// After
builder.Append($", {nameof(Duration)} = ");
builder.Append(Duration);

This makes all three Append calls in TimingInfo.ToString() consistent.

Changes Based On

Recent changes from:

Testing

  • ✅ Build succeeds (0 errors, 0 warnings)
  • ✅ No functional changes — behavior is identical

Automated by Code Simplifier Agent

Note

🔒 Integrity filter blocked 7 items

The following items were blocked because they don't meet the GitHub integrity level.

  • #7954 search_pull_requests: has lower integrity than agent requires. The agent cannot read data with integrity below "approved".
  • #7946 search_pull_requests: has lower integrity than agent requires. The agent cannot read data with integrity below "approved".
  • #7945 search_pull_requests: has lower integrity than agent requires. The agent cannot read data with integrity below "approved".
  • #7944 search_pull_requests: has lower integrity than agent requires. The agent cannot read data with integrity below "approved".
  • #7931 search_pull_requests: has lower integrity than agent requires. The agent cannot read data with integrity below "approved".
  • #7913 search_pull_requests: has lower integrity than agent requires. The agent cannot read data with integrity below "approved".
  • #7912 search_pull_requests: has lower integrity than agent requires. The agent cannot read data with integrity below "approved".

To allow these resources, lower min-integrity in your GitHub frontmatter:

tools:
  github:
    min-integrity: approved  # merged | approved | unapproved | none

Generated by Code Simplifier · ● 2.2M ·

  • expires on May 1, 2026, 11:30 AM UTC

Note

This was originally intended as a pull request, but the git push operation failed.

Workflow Run: View run details and download patch artifact

The patch file is available in the agent artifact in the workflow run linked above.

To create a pull request with the changes:

# Download the artifact from the workflow run
gh run download 25162414830 -n agent -D /tmp/agent-25162414830

# Create a new branch
git checkout -b simplify/timing-tostring-redundant-056b7c1c103ef825

# Apply the patch (--3way handles cross-repo patches where files may already exist)
git am --3way /tmp/agent-25162414830/aw-simplify-timing-tostring-redundant.patch

# Push the branch to origin
git push origin simplify/timing-tostring-redundant-056b7c1c103ef825

# Create the pull request
gh pr create --title '[code-simplifier] Remove redundant `.ToString()` in `TimingInfo.ToString()`' --base main --head simplify/timing-tostring-redundant-056b7c1c103ef825 --repo microsoft/testfx
Show patch (31 lines)
From 85b4c006d0317010d13ecd63d7ce67e36debe14e Mon Sep 17 00:00:00 2001
From: "github-actions[bot]" <github-actions[bot]@users.noreply.github.com>
Date: Thu, 30 Apr 2026 11:28:13 +0000
Subject: [PATCH] Remove redundant .ToString() in TimingInfo.Append call

StringBuilder.Append(Duration) is functionally identical to
StringBuilder.Append(Duration.ToString()) and consistent with
the other Append calls in the same method (StartTime, EndTime).

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
---
 .../Microsoft.Testing.Platform/Messages/TimingProperties.cs     | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/Platform/Microsoft.Testing.Platform/Messages/TimingProperties.cs b/src/Platform/Microsoft.Testing.Platform/Messages/TimingProperties.cs
index aa13072..1457c0e 100644
--- a/src/Platform/Microsoft.Testing.Platform/Messages/TimingProperties.cs
+++ b/src/Platform/Microsoft.Testing.Platform/Messages/TimingProperties.cs
@@ -46,7 +46,7 @@ public override string ToString()
         builder.Append($", {nameof(EndTime)} = ");
         builder.Append(EndTime);
         builder.Append($", {nameof(Duration)} = ");
-        builder.Append(Duration.ToString());
+        builder.Append(Duration);
         builder.Append(" }");
         return builder.ToString();
     }
-- 
2.53.0

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions