OmarElabd / ObjectExporter

Object Exporter lets you export out an object while debugging in Visual Studio, the object can be serialized in either C#, JSON or XML.
GNU General Public License v3.0
264 stars 82 forks source link

Not handling nullable DataTime correctly #27

Closed robertbrooker closed 9 years ago

robertbrooker commented 9 years ago

DateTime looks good:

public class ObjectWithDate
{
    public DateTime ADateTime { get; set; }
}

        var objectWithDate = new ObjectWithDate
        {
            ADateTime = new DateTime(2015, 5, 29, 11, 45, 0),
        };

The export yields this (except the month issue, it looks good): var objectWithDate = new MyNameSpace.ObjectWithDate { ADateTime = new DateTime(2015, 5, 5, 29, 11, 45, 0) };

However if I change the type to nullable like so:

public class ObjectWithDate
{
    public DateTime? ADateTime { get; set; }
}

I get this:

var objectWithDate = new MyNameSpace.ObjectWithDate { new System.DateTime? { Date = new DateTime(2015, 5, 5, 29, 0, 0, 0), Day = 29, DayOfWeek = Friday, DayOfYear = 149, Hour = 11, Kind = Unspecified, Millisecond = 0, Minute = 45, Month = 5, Second = 0, Ticks = 635684967000000000, TimeOfDay = new TimeSpan(0, 11, 45, 0, 0), Year = 2015 } };

Otherwise this is a great tool, keep up the good work. Cheers, Rob

OmarElabd commented 9 years ago

Hey Rob, this is actually fixed in the Github code but it hasn't been released on the vs gallery yet. See issue #21. I'll make a release sometime this weekend with the new code.

robertbrooker commented 9 years ago

OK, awesome, look forward to it.