-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Closed
Description
Description
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