Skip to content

Fix culture-dependent date formatting and cross-platform line endings in OpenAPI document generation#5

Draft
Copilot wants to merge 2 commits intomainfrom
copilot/fix-acceptance-tests-culture-issues
Draft

Fix culture-dependent date formatting and cross-platform line endings in OpenAPI document generation#5
Copilot wants to merge 2 commits intomainfrom
copilot/fix-acceptance-tests-culture-issues

Conversation

Copy link
Copy Markdown

Copilot AI commented Feb 28, 2026

Fix culture-dependent date formatting and cross-platform line endings in OpenAPI document generation

  • You've read the Contributor Guide and Code of Conduct.
  • You've included unit or integration tests for your change, where applicable.
  • You've included inline docs for your change, where applicable.
  • There's an open issue for the PR that you are making. If you'd like to propose a new feature or change, please open an issue to discuss the change or find an existing issue.

Use CultureInfo.InvariantCulture and explicit \n line endings so OpenAPI documents are identical regardless of locale or OS.

Description

OpenAPI acceptance tests fail on non-en-US machines (e.g. Dutch locale) because deprecation/sunset dates are formatted via CultureInfo.CurrentCulture with {1:d}, producing locale-specific output (1/1/2026 vs 1-1-2026). Additionally, StringBuilder.AppendLine() emits \r\n on Windows and \n on Linux, causing cross-platform mismatches against the expected JSON fixture.

  • OpenApiDocumentDescriptionOptions.csCultureInfo.CurrentCultureCultureInfo.InvariantCulture in DefaultDeprecationNotice and DefaultSunsetNotice
  • ApiExplorerTransformer.cs — Replace AppendLine() with explicit Append('\n') in Markdown generation for deterministic output
  • OpenApiDocumentDescriptionOptionsTest.cs — Update expected dates to invariant format (02/08/2026)
  • Content/v1.json — Update dates and \r\n\n to match corrected output
// Before: output varies by locale
return string.Format( CultureInfo.CurrentCulture, deprecatedNoticeFormat, participle, when );

// After: deterministic across all locales
return string.Format( CultureInfo.InvariantCulture, deprecatedNoticeFormat, participle, when );

💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Use CultureInfo.InvariantCulture instead of CultureInfo.CurrentCulture in
DefaultDeprecationNotice and DefaultSunsetNotice to ensure consistent date
formatting across all locales (e.g., 01/01/2026 instead of culture-specific
1/1/2026 or 1-1-2026).

Replace StringBuilder.AppendLine() with explicit '\n' line endings in
ApiExplorerTransformer to produce consistent Markdown output regardless of
the operating system (Environment.NewLine varies between platforms).

Update expected test values and Content/v1.json to match the invariant
culture date format and consistent line endings.

Co-authored-by: sander1095 <7312681+sander1095@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix culture issues in AcceptanceTests Fix culture-dependent date formatting and cross-platform line endings in OpenAPI document generation Feb 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants