Skip to content

CDate(CStr(Nothing)) should not cause an exception #621

Open
@jrmoreno1

Description

@jrmoreno1

Just ran into this today, apparently it's a long standing bug: dotnet/roslyn#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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions