ArgumentNullException in SearchMarshaller.cs


Searching for SearchEnvironment.Default.BeginSearch("Scherotter"), I get a parse error at
Line 39.
Inspecting the values, the WebResult.DateTime is null and that would cause the following code to throw an ArgumentNullException
result.Date = DateTime.Parse(webResult.DateTime);
It would be better to use a Nullable Date (Date?) value for SearchResult.Date and check for a null or empty string:
You can use an extension method like the one below to make the code easier to follow:
public static class Parsers
    public static DateTime? ParseDate(this XContainer parent, string name)
        var element = parent.Element(name);
        if (element == null)
            return new DateTime?();
        var text = element.Value;
        if (string.IsNullOrEmpty(text))
            return new DateTime?();
        return DateTime.Parse(element.Value, CultureInfo.InvariantCulture);
Closed Feb 28, 2010 at 5:25 PM by mscherotter


wrote Feb 28, 2010 at 5:25 PM

Resolved with changeset 56174.

wrote Feb 13, 2013 at 1:16 AM

wrote May 15, 2013 at 12:02 AM