11using BenchmarkDotNet . Configs ;
2- using BenchmarkDotNet . Loggers ;
32using BenchmarkDotNet . Running ;
43using BenchmarkDotNet . TestAdapter . Remoting ;
54using Microsoft . VisualStudio . TestPlatform . ObjectModel ;
65using System ;
76using System . Collections . Generic ;
8- using System . Collections . Immutable ;
97using System . Linq ;
10- using System . Reflection ;
118using System . Threading ;
129
1310namespace BenchmarkDotNet . TestAdapter
@@ -17,9 +14,6 @@ namespace BenchmarkDotNet.TestAdapter
1714 /// </summary>
1815 internal class BenchmarkExecutor
1916 {
20- // Gets FieldInfo of ImmutableConfig's loggers.
21- private static readonly FieldInfo ? loggersField = typeof ( ImmutableConfig ) . GetField ( "loggers" , BindingFlags . Instance | BindingFlags . NonPublic ) ;
22-
2317 private readonly CancellationTokenSource cts = new ( ) ;
2418
2519 /// <summary>
@@ -70,21 +64,10 @@ public void RunBenchmarks(string assemblyPath, TestExecutionRecorderWrapper reco
7064
7165 // Modify all the benchmarks so that the event process and logger is added.
7266 benchmarks = benchmarks
73- . Select ( b =>
74- {
75- ImmutableConfig config = b . Config . AddEventProcessor ( eventProcessor ) . AddLogger ( logger ) . CreateImmutableConfig ( ) ;
76-
77- // Remove console logger from ImmutableCofig to fix duplicated console logs are outputted issue.
78- if ( loggersField != null && loggersField . DeclaringType == typeof ( ImmutableHashSet ) )
79- {
80- var loggers = config . GetLoggers ( )
81- . Where ( x => x is not ConsoleLogger )
82- . ToImmutableHashSet ( ) ;
83- loggersField . SetValue ( config , loggers ) ;
84- }
85-
86- return new BenchmarkRunInfo ( b . BenchmarksCases , b . Type , config ) ;
87- } )
67+ . Select ( b => new BenchmarkRunInfo (
68+ b . BenchmarksCases ,
69+ b . Type ,
70+ b . Config . AddEventProcessor ( eventProcessor ) . AddLogger ( logger ) . CreateImmutableConfig ( ) ) )
8871 . ToArray ( ) ;
8972
9073 // Run all the benchmarks, and ensure that any tests that don't have a result yet are sent.
0 commit comments