CDate(CStr(Nothing)) should not cause an exception
- Dominant language
- No language data
- Stars
- 328
- Forks
- 71
- PR merge metrics
- No merged PRs in 30d
Description
Just ran into this today, apparently it's a long standing bug: https://github.com/dotnet/roslyn/issues/2780, although I disagree with the recommended behavior.
IMO the correct fix is for the call to Conversions::ToDate(string) to check to see if the string is null, and return DateTime.MinValue if so.
In my case, Option Strict was Off and the actual assignment that caused the problem was obj.d = if(function(a, b)) where sometimes the return value was nothing and sometimes it was a string that could be interpreted as a date. Obviously the better code would be DateTime.TryParse(function(a,b), obj.d), but it shouldn't break.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.