Skip to content

DateOnly string interpolation causes OOM crash #66040

@tgrunshaw

Description

@tgrunshaw

Description

Using string interpolation with DateOnly causes the runtime to crash with invalid string formats, such as below:

var dateOnly = new DateOnly(2020, 05, 03);
var dateOnlyString = $"{dateOnly:yyyy:MM:dd}"; // We never proceed beyond this line

See an example: https://dotnetfiddle.net/jLN3uv

Reproduction Steps

var dateOnly = new DateOnly(2020, 05, 03);
var dateOnlyString = $"{dateOnly:yyyy:MM:dd}"; // We never proceed beyond this line

See an example: https://dotnetfiddle.net/jLN3uv

Expected behavior

Not have the runtime crash/stick/run out of memory.

Whether this should throw an exception like it does when .ToString() is used or whether it should behave like DateTime where it works correctly is a decision I'll leave to the .NET team.

Actual behavior

Out of memory failure or stuck with high GC when debugging.

Regression?

No response

Known Workarounds

No response

Configuration

No response

Other information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    untriagedNew issue has not been triaged by the area owner

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions