Skip to content

Start using parameter defined for ToString #118306

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

StephenMolloy
Copy link
Member

Historically, this adapter struct took an IFormatProvider agrument for it's ToString() method... and never used it. This makes the compiler unhappy now. So to keep the API (partly for binary compat, and partly to not bump heads with Object.ToString()), lets start using the format provider as one might expect. And then pass a null value in the one place that we call this ToString overload so the existing behavior is maintained.

Fixes #76012

@Copilot Copilot AI review requested due to automatic review settings August 2, 2025 22:31
Copy link
Contributor

@Copilot 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

This PR fixes an issue where a ToString(IFormatProvider) method in the DateTimeOffsetAdapter struct was accepting but ignoring its format provider parameter, causing compiler warnings. The fix implements proper usage of the format provider parameter while maintaining existing behavior by passing null at the call site.

Key Changes

  • Updates the ToString(IFormatProvider?) method to actually use the format provider when formatting the UtcDateTime
  • Changes the call site to pass null instead of CultureInfo.InvariantCulture to preserve existing behavior
  • Removes compiler warning suppressions that are no longer needed

…tem/Runtime/Serialization/DateTimeOffsetAdapter.cs
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.

DateTimeOffsetAdapter::ToString unused parameter
3 participants