Skip to content

Commit

Permalink
Do not attempt to call GetSystemTimePreciseAsFileTime() on platforms …
Browse files Browse the repository at this point in the history
…other than Windows

Fixes #279
  • Loading branch information
karolz-ms committed Oct 24, 2018
1 parent 74b19f8 commit 89450b5
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ internal static class EventDataExtensions
[DllImport("Kernel32.dll", CallingConvention = CallingConvention.Winapi)]
private static extern void GetSystemTimePreciseAsFileTime(out long filetime);

private static bool hasPreciseTime = Environment.OSVersion.Version.Major >= 10 || (Environment.OSVersion.Version.Major == 6 && Environment.OSVersion.Version.Minor >= 2);
private static bool hasPreciseTime =
Environment.OSVersion.Platform == PlatformID.Win32NT &&
(Environment.OSVersion.Version.Major >= 10 || (Environment.OSVersion.Version.Major == 6 && Environment.OSVersion.Version.Minor >= 2));
#endif

public static EventData ToEventData(this EventWrittenEventArgs eventSourceEvent, IHealthReporter healthReporter, string context)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,12 @@ public void CapturesEventsFromEventSourceCreatedAfterInputCreated()
[Fact]
public void MeasuresEventTimeWithHighResolution()
{
if (Environment.OSVersion.Platform != PlatformID.Win32NT)
{
// We only use explicit high-precision timestamping on Windows, relying on .NET implementation defaults for other platforms
return;
}

var healthReporterMock = new Mock<IHealthReporter>();

// Ensure the EventSource is instantiated
Expand Down

0 comments on commit 89450b5

Please sign in to comment.