Skip to content

Fix DateOnly and TimeOnly Formatting using interpolated strings - #64398

Merged
tarekgh merged 2 commits into
dotnet:mainfrom
tarekgh:FixDateAndTimeOnlyWithInterpolatedStringFormatting
Jan 28, 2022
Merged

Fix DateOnly and TimeOnly Formatting using interpolated strings#64398
tarekgh merged 2 commits into
dotnet:mainfrom
tarekgh:FixDateAndTimeOnlyWithInterpolatedStringFormatting

Conversation

@tarekgh

Copy link
Copy Markdown
Member

Fixes#64292

@ghost

Copy link
Copy Markdown

I couldn't figure out the best area label to add to this PR. If you have write-permissions please help me learn by adding exactly one area label.

@ghost

Copy link
Copy Markdown

Tagging subscribers to this area: @dotnet/area-system-runtime
See info in area-owners.md if you want to be subscribed.

Issue Details

Fixes #64292

Author:tarekgh
Assignees:tarekgh
Labels:

area-System.Runtime

Milestone:-

@tarekghtarekgh added this to the 7.0.0 milestone Jan 27, 2022

@stephentoubstephentoub left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks! It's interesting this doesn't cause any tests to fail. Are we missing direct tests of TryFormat?

@tarekgh

tarekgh commented Jan 27, 2022

Copy link
Copy Markdown
MemberAuthor

It's interesting this doesn't cause any tests to fail. Are we missing direct tests of TryFormat?

We were testing the positive cases only. I added the interpolated string tests which should catch the negative cases. If you think we should add specific negative tests for TryFormat, I can do that. We already testing the not enough destination buffer space here

Assert.False(dateOnly.TryFormat(buffer.Slice(0,3),outcharsWritten));
. and here
Assert.False(timeOnly.TryFormat(buffer.Slice(0,3),outcharsWritten));

@stephentoub

Copy link
Copy Markdown
Member

Thanks. Yes, I think we should have those tests for TryFormat. It'd be fine to do those instead of the interpolation ones.

Comment threadsrc/libraries/System.Runtime/tests/System/TimeOnlyTests.cs
@tarekgh

tarekgh commented Jan 28, 2022

Copy link
Copy Markdown
MemberAuthor

The failures in the CI are tracked by the issue #64389.

@tarekgh
tarekgh merged commit f8f486b into dotnet:mainJan 28, 2022
@tarekgh
tarekgh deleted the FixDateAndTimeOnlyWithInterpolatedStringFormatting branch January 28, 2022 02:16
@tarekgh

Copy link
Copy Markdown
MemberAuthor

/backport to release/6.0

@github-actions

Copy link
Copy Markdown
Contributor

Started backporting to release/6.0: https://github.com/dotnet/runtime/actions/runs/1762869247

@ghostghost locked as resolved and limited conversation to collaborators Feb 27, 2022
Sign up for freeto subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Invalid format specifier on DateOnly in string interpolation leads to infinite loop instead of FormatException

3 participants

@tarekgh@stephentoub@jeffhandley