Skip to content

Remove redundant 'string.Format()' calls#9529

Merged
glen-84 merged 1 commit intomainfrom
gai/fix-redundant-string-format
Apr 10, 2026
Merged

Remove redundant 'string.Format()' calls#9529
glen-84 merged 1 commit intomainfrom
gai/fix-redundant-string-format

Conversation

@glen-84
Copy link
Copy Markdown
Member

@glen-84 glen-84 commented Apr 10, 2026

Summary of the changes (Less than 80 chars)

  • Remove redundant 'string.Format()' calls.

Copilot AI review requested due to automatic review settings April 10, 2026 15:52
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Removes redundant string.Format(...) usages in HotChocolate error construction by leveraging existing ErrorBuilder.SetMessage(format, args) overloads, and enforces this pattern via a ReSharper inspection severity.

Changes:

  • Replace SetMessage(string.Format(...)) with SetMessage(format, args) in core throwing helpers.
  • Replace SetMessage(string.Format(...)) with SetMessage(format, args) in ASP.NET Core pipeline error helper.
  • Configure ReSharper to treat redundant string.Format calls as errors via .editorconfig.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

File Description
src/HotChocolate/Core/src/Types/Utilities/ThrowHelper.cs Uses ErrorBuilder.SetMessage(format, arg) instead of pre-formatting the message.
src/HotChocolate/Core/src/Types/Execution/ThrowHelper.cs Same simplification for the OneOfFieldMustBeNonNull error.
src/HotChocolate/AspNetCore/src/AspNetCore.Pipeline/Utilities/ErrorHelper.cs Same simplification for the BatchSizeExceeded error.
.editorconfig Elevates ReSharper “redundant string.Format call” highlighting to error to prevent regressions.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@glen-84 glen-84 merged commit 1e24b63 into main Apr 10, 2026
133 checks passed
@glen-84 glen-84 deleted the gai/fix-redundant-string-format branch April 10, 2026 16:03
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 10, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 0.00%. Comparing base (404d7e9) to head (c6ea723).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@     Coverage Diff      @@
##   main   #9529   +/-   ##
============================
============================

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants