diff options
author | Sung Yoon Whang <suwhang@microsoft.com> | 2019-06-28 17:06:19 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-06-28 17:06:19 -0700 |
commit | 5ce8eaf4d4acad83f8e38095651ff765d339aab2 (patch) | |
tree | 3d274e37bdd787fc8df692ab127c590f3a69aac5 /tests | |
parent | 59e7be03ddb77e36b8e36574682d23cb6dc38f5c (diff) | |
download | coreclr-5ce8eaf4d4acad83f8e38095651ff765d339aab2.tar.gz coreclr-5ce8eaf4d4acad83f8e38095651ff765d339aab2.tar.bz2 coreclr-5ce8eaf4d4acad83f8e38095651ff765d339aab2.zip |
Stop using reflection on pollingcounter tests (#25489)
Diffstat (limited to 'tests')
-rw-r--r-- | tests/src/tracing/eventcounter/incrementingpollingcounter.cs | 23 | ||||
-rw-r--r-- | tests/src/tracing/eventcounter/pollingcounter.cs | 27 |
2 files changed, 10 insertions, 40 deletions
diff --git a/tests/src/tracing/eventcounter/incrementingpollingcounter.cs b/tests/src/tracing/eventcounter/incrementingpollingcounter.cs index d838087ec5..f61c985cb1 100644 --- a/tests/src/tracing/eventcounter/incrementingpollingcounter.cs +++ b/tests/src/tracing/eventcounter/incrementingpollingcounter.cs @@ -10,7 +10,6 @@ using System.Diagnostics.Tracing; using System; using System.Collections.Generic; using System.Threading; -using System.Reflection; namespace BasicEventSourceTests { @@ -19,11 +18,11 @@ namespace BasicEventSourceTests [EventSource(Name = "SimpleEventSource")] private sealed class SimpleEventSource : EventSource { - private object _mockedCounter; + private IncrementingPollingCounter _mockedCounter; - public SimpleEventSource(Func<double> getMockedCount, Type IncrementingPollingCounterType) + public SimpleEventSource(Func<double> getMockedCount) { - _mockedCounter = Activator.CreateInstance(IncrementingPollingCounterType, "failureCount", this, getMockedCount); + _mockedCounter = new IncrementingPollingCounter("failureCount", this, getMockedCount); } } @@ -103,21 +102,7 @@ namespace BasicEventSourceTests // Create an EventListener. using (SimpleEventListener myListener = new SimpleEventListener("SimpleEventSource", EventLevel.Verbose)) { - // Reflect over System.Private.CoreLib and get the IncrementingPollingCounter type. - Assembly SPC = typeof(System.Diagnostics.Tracing.EventSource).Assembly; - if(SPC == null) - { - Console.WriteLine("Failed to get System.Private.CoreLib assembly."); - return 1; - } - Type IncrementingPollingCounterType = SPC.GetType("System.Diagnostics.Tracing.IncrementingPollingCounter"); - if(IncrementingPollingCounterType == null) - { - Console.WriteLine("Failed to get System.Diagnostics.Tracing.IncrementingPollingCounterType type."); - return 1; - } - - SimpleEventSource eventSource = new SimpleEventSource(getMockedCount, IncrementingPollingCounterType); + SimpleEventSource eventSource = new SimpleEventSource(getMockedCount); // Want to sleep for 5000 ms to get some counters piling up. Thread.Sleep(5000); diff --git a/tests/src/tracing/eventcounter/pollingcounter.cs b/tests/src/tracing/eventcounter/pollingcounter.cs index de50ff49a1..f6c261a1ec 100644 --- a/tests/src/tracing/eventcounter/pollingcounter.cs +++ b/tests/src/tracing/eventcounter/pollingcounter.cs @@ -10,7 +10,6 @@ using System.Diagnostics.Tracing; using System; using System.Collections.Generic; using System.Threading; -using System.Reflection; namespace BasicEventSourceTests { @@ -19,13 +18,13 @@ namespace BasicEventSourceTests [EventSource(Name = "SimpleEventSource")] private sealed class SimpleEventSource : EventSource { - private object _failureCounter; - private object _successCounter; + private PollingCounter _failureCounter; + private PollingCounter _successCounter; - public SimpleEventSource(Func<double> getMockedCount, Func<double> getSuccessCount, Type PollingCounterType) + public SimpleEventSource(Func<double> getMockedCount, Func<double> getSuccessCount) { - _failureCounter = Activator.CreateInstance(PollingCounterType, "failureCount", this, getSuccessCount); - _successCounter = Activator.CreateInstance(PollingCounterType, "successCount", this, getMockedCount); + _failureCounter = new PollingCounter("failureCount", this, getSuccessCount); + _successCounter = new PollingCounter("successCount", this, getMockedCount); } } @@ -157,21 +156,7 @@ namespace BasicEventSourceTests // Create an EventListener. using (SimpleEventListener myListener = new SimpleEventListener("SimpleEventSource", EventLevel.Verbose)) { - // Reflect over System.Private.CoreLib and get the PollingCounter type. - Assembly SPC = typeof(System.Diagnostics.Tracing.EventSource).Assembly; - if(SPC == null) - { - Console.WriteLine("Failed to get System.Private.CoreLib assembly."); - return 1; - } - Type PollingCounterType = SPC.GetType("System.Diagnostics.Tracing.PollingCounter"); - if(PollingCounterType == null) - { - Console.WriteLine("Failed to get System.Diagnostics.Tracing.PollingCounter type."); - return 1; - } - - SimpleEventSource eventSource = new SimpleEventSource(getMockedCount, getSuccessCount, PollingCounterType); + SimpleEventSource eventSource = new SimpleEventSource(getMockedCount, getSuccessCount); // Want to sleep for 5000 ms to get some counters piling up. Thread.Sleep(5000); |