From: Brian Robbins Date: Tue, 28 Aug 2018 01:22:10 +0000 (-0700) Subject: Remove reflection from RuntimeEventSource test. (#19692) X-Git-Tag: accepted/tizen/unified/20190422.045933~1346 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=6975ff37ea866b4a9dc913f5d72d31b10fb40da9;p=platform%2Fupstream%2Fcoreclr.git Remove reflection from RuntimeEventSource test. (#19692) --- diff --git a/tests/src/tracing/runtimeeventsource/RuntimeEventSourceTest.cs b/tests/src/tracing/runtimeeventsource/RuntimeEventSourceTest.cs index a081d88..18b78f4f 100644 --- a/tests/src/tracing/runtimeeventsource/RuntimeEventSourceTest.cs +++ b/tests/src/tracing/runtimeeventsource/RuntimeEventSourceTest.cs @@ -1,5 +1,3 @@ -#define REFLECTION - using System; using System.IO; using System.Diagnostics.Tracing; @@ -7,10 +5,6 @@ using System.Runtime.CompilerServices; using System.Threading; using Tracing.Tests.Common; -#if REFLECTION -using System.Reflection; -#endif - namespace Tracing.Tests { public sealed class RuntimeEventSourceTest @@ -99,22 +93,11 @@ namespace Tracing.Tests protected override void OnEventWritten(EventWrittenEventArgs eventData) { - long osThreadId = -1; - DateTime timeStamp; -#if REFLECTION - PropertyInfo threadProperty = typeof(EventWrittenEventArgs).GetProperty("OSThreadId"); - MethodInfo threadMethod = threadProperty.GetGetMethod(); - osThreadId = (long)threadMethod.Invoke(eventData, null); - PropertyInfo timeStampProperty = typeof(EventWrittenEventArgs).GetProperty("TimeStamp"); - MethodInfo timeStampMethod = timeStampProperty.GetGetMethod(); - timeStamp = (DateTime)timeStampMethod.Invoke(eventData, null); -#endif - - Console.WriteLine($"[{m_name}] ThreadID = {osThreadId} ID = {eventData.EventId} Name = {eventData.EventName}"); - Console.WriteLine($"TimeStamp: {timeStamp.ToLocalTime()}"); + Console.WriteLine($"[{m_name}] ThreadID = {eventData.OSThreadId} ID = {eventData.EventId} Name = {eventData.EventName}"); + Console.WriteLine($"TimeStamp: {eventData.TimeStamp.ToLocalTime()}"); Console.WriteLine($"LocalTime: {DateTime.Now}"); - Console.WriteLine($"Difference: {DateTime.UtcNow - timeStamp}"); - Assert.True("timeStamp < DateTime.UtcNow", timeStamp < DateTime.UtcNow); + Console.WriteLine($"Difference: {DateTime.UtcNow - eventData.TimeStamp}"); + Assert.True("eventData.TimeStamp < DateTime.UtcNow", eventData.TimeStamp < DateTime.UtcNow); for (int i = 0; i < eventData.Payload.Count; i++) { string payloadString = eventData.Payload[i] != null ? eventData.Payload[i].ToString() : string.Empty; @@ -122,7 +105,6 @@ namespace Tracing.Tests } Console.WriteLine("\n"); - EventCount++; } }