diff --git a/src/Microsoft.Diagnostics.EventFlow.Inputs.EventSource/EventDataExtensions.cs b/src/Microsoft.Diagnostics.EventFlow.Inputs.EventSource/EventDataExtensions.cs index 7e5af844..035832fb 100644 --- a/src/Microsoft.Diagnostics.EventFlow.Inputs.EventSource/EventDataExtensions.cs +++ b/src/Microsoft.Diagnostics.EventFlow.Inputs.EventSource/EventDataExtensions.cs @@ -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) diff --git a/test/Microsoft.Diagnostics.EventFlow.Inputs.Tests/EventSourceInputTests.cs b/test/Microsoft.Diagnostics.EventFlow.Inputs.Tests/EventSourceInputTests.cs index ad72a60a..98244a0e 100644 --- a/test/Microsoft.Diagnostics.EventFlow.Inputs.Tests/EventSourceInputTests.cs +++ b/test/Microsoft.Diagnostics.EventFlow.Inputs.Tests/EventSourceInputTests.cs @@ -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(); // Ensure the EventSource is instantiated