-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Description
Description
When updating to .NET 6.0, we encountered issues with DateTimes within events containing an incorrect year. It appears that the optimization in pull request #52092 changed the behavior so that it's no longer decoded from a FileTime and is instead decoded using the full tick value.
Reproduction Steps
Write an event using WriteEventCore like the example below
[Event(1)]
public unsafe void DateTimeEvent(DateTime dateTime)
{
if (this.IsEnabled())
{
var fileTimeVal = dateTime.Year < 1601 ? 0 : dateTime.ToFileTimeUtc();
EventSource.EventData* descrs = stackalloc EventSource.EventData[1];
descrs[0].DataPointer = (IntPtr)(&fileTimeVal);
descrs[0].Size = sizeof(long);
WriteEventCore(1, 1, descrs);
}
}
Expected behavior
EventWrittenEventArgs payload from an EventTraceListener contains the DateTime matching the input.
Actual behavior
EventWrittenEventArgs payload from an EventTraceListener contains the DateTime, but the year is off by 1600 as it appears to be decoding from ticks rather than file time ticks.
Other information
This appears to be a breaking change from NetCore3.1 and Net 5.0 so seeking guidance on whether this is an expected change in behavior or if this is a bug. Thanks!