Skip to content

Efcore community fixes - #38715

Open
ilkertskn wants to merge 3 commits into
dotnet:mainfrom
ilkertskn:efcore-community-fixes
Open

Efcore community fixes#38715
ilkertskn wants to merge 3 commits into
dotnet:mainfrom
ilkertskn:efcore-community-fixes

Conversation

@ilkertskn

@ilkertskn ilkertskn commented Jul 29, 2026

Copy link
Copy Markdown
Contributor
  • I've read the guidelines for contributing and seen the walkthrough
  • I've posted a comment on an issue with a detailed description of how I am planning to contribute and got approval from a member of the team
  • The code builds and tests pass locally (also verified by our automated build checks)
  • Commit messages follow this format:
        Summary of the changes
        - Detail 1
        - Detail 2

        Fixes #bugnumber
  • Tests for the changes have been added (for bug fixes / features)
  • Code follows the same patterns and style as existing code in this repo

- DateOnly/DateTime/DateTimeOffset -> string converters formatted using the current culture but
  parsed using the invariant culture, so round-tripping corrupted values under cultures whose
  default calendar is not Gregorian (e.g. th-TH adds 543 years to the year)
- Pass CultureInfo.InvariantCulture when formatting, matching the parse side and the sibling
  TimeOnly/TimeSpan/number converters which already pin the invariant culture on both sides
- Add round-trip tests under a non-Gregorian culture
- The FormattableString overload called _stringBuilder.Append(value) and therefore never emitted
  the trailing new line documented by its summary, unlike the string overload which uses AppendLine
- Append the new line after the value, matching AppendLine(string)
- Add a test for the FormattableString overload (existing tests only pass interpolated string
  literals, which bind to the string overload)
…string indexer

- The this[string] setter set the complex collection value but then fell through to
  GetProperty(propertyName), which throws for a non-scalar property name, so setting a complex
  collection via the string indexer always threw (after mutating state)
- Return once the complex property has been handled, mirroring the getter
- Add a test in PropertyValuesTestBase, overridden for the in-memory provider which does not
  support complex collections
@ilkertskn
ilkertskn requested a review from a team as a code owner July 29, 2026 23:17
@ilkertskn

Copy link
Copy Markdown
Contributor Author

@dotnet-policy-service agree

@AndriySvyryd
AndriySvyryd requested a review from Copilot July 30, 2026 00:02
@AndriySvyryd AndriySvyryd self-assigned this Jul 30, 2026
@AndriySvyryd AndriySvyryd added this to the 12.0.0 milestone Jul 30, 2026

Copilot AI left a comment

Copy link
Copy Markdown

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 tightens culture-invariant round-tripping behavior for EF Core’s date/time string value converters and fixes/extends related infrastructure behavior with new regression tests.

Changes:

  • Ensure DateOnly, DateTime, and DateTimeOffset string conversions use CultureInfo.InvariantCulture during formatting to avoid non-Gregorian culture pitfalls (e.g., th-TH Buddhist calendar).
  • Fix PropertyValues string-indexer setting for complex collections by ensuring the complex-property branch exits early.
  • Correct IndentedStringBuilder.AppendLine(FormattableString) to actually append a newline, and add a regression test.

Reviewed changes

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

Show a summary per file
File Description
test/EFCore.Tests/Storage/ValueConversion/DateStringConverterCultureTest.cs Adds culture-specific regression coverage (Thai Buddhist calendar) for date/time string converter round-trips.
test/EFCore.Tests/Infrastructure/IndentedStringBuilderTest.cs Adds regression test ensuring AppendLine(FormattableString) appends a newline.
test/EFCore.Specification.Tests/PropertyValuesTestBase.cs Adds specification coverage for setting complex collections via the string indexer.
test/EFCore.InMemory.FunctionalTests/PropertyValuesInMemoryTest.cs Marks the new complex-collection indexer test as unsupported for InMemory (expects exception).
src/EFCore/Storage/ValueConversion/Internal/StringDateTimeOffsetConverter.cs Formats DateTimeOffset using invariant culture for stable serialization.
src/EFCore/Storage/ValueConversion/Internal/StringDateTimeConverter.cs Formats DateTime using invariant culture for stable serialization.
src/EFCore/Storage/ValueConversion/Internal/StringDateOnlyConverter.cs Formats DateOnly using invariant culture for stable serialization.
src/EFCore/Infrastructure/IndentedStringBuilder.cs Fixes AppendLine(FormattableString) to append a newline.
src/EFCore/ChangeTracking/Internal/ArrayPropertyValues.cs Prevents fall-through after handling complex properties in the string indexer setter.

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.

3 participants