You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
DateTime.Parse exception missing input value in .NET 8 #95331
When an incorrectly formatted string is provided to the DateTime.Parse method, a FormatException is thrown showing the invalid value, for example: "String '01/23/2023' was not recognized as a valid DateTime."
When switching to .NET 8, the exception message is missing the value between the two single quotes and so instead reads "String '' was not recognized as a valid DateTime."
Reproduction Steps
Create a .NET 7 console application
Add DateTime.Parse("01/23/2023", new CultureInfo("en-GB")); to Program.cs
Debug the application and note the exception thrown shows the input value
Change the project to .NET 8
Debug the application and note the exception is now missing the value passed in and instead shows an empty value between the two single quotes
Expected behavior
The message in the FormatException should read "String '01/23/2023' was not recognized as a valid DateTime."
Actual behavior
The message in the FormatException reads "String '' was not recognized as a valid DateTime."
Regression?
This is new behaviour in .NET 8
Known Workarounds
No response
Configuration
.NET 8
Windows 11 Business
x64
Other information
No response
Activity
ghost added
needs-area-labelAn area label is needed to ensure this gets routed to the appropriate area owners
Activity
stephentoub commentedon Nov 28, 2023
@tarekgh, yet another report. We should backport the fix, assuming this is indeed the same issue.
karakasa commentedon Nov 28, 2023
Probably fixed in #91303
tarekgh commentedon Nov 28, 2023
I'll take a look and will work on fixing and porting the fix to 8.0 servicing.
tarekgh commentedon Nov 28, 2023
#94837
#94907
#95428
tarekgh commentedon Nov 30, 2023
Fixed by the attached PR.