1- using System ;
2- using System . Linq ;
3- using System . Reflection ;
1+ using System . Reflection ;
42using System . Threading . Tasks ;
5- using BenchmarkDotNet . Engines ;
63using BenchmarkDotNet . Extensions ;
7- using BenchmarkDotNet . Helpers ;
84using BenchmarkDotNet . Running ;
95
106namespace BenchmarkDotNet . Code
@@ -30,14 +26,6 @@ internal abstract class DeclarationsProvider
3026
3127 public string IterationCleanupMethodName => Descriptor . IterationCleanupMethod ? . Name ?? EmptyAction ;
3228
33- public abstract string ReturnsDefinition { get ; }
34-
35- protected virtual Type WorkloadMethodReturnType => Descriptor . WorkloadMethod . ReturnType ;
36-
37- public virtual string WorkloadMethodReturnTypeName => WorkloadMethodReturnType . GetCorrectCSharpTypeName ( ) ;
38-
39- public virtual string WorkloadMethodReturnTypeModifiers => null ;
40-
4129 public virtual string GetWorkloadMethodCall ( string passArguments ) => $ "{ Descriptor . WorkloadMethod . Name } ({ passArguments } )";
4230
4331 private string GetMethodName ( MethodInfo method )
@@ -60,55 +48,14 @@ private string GetMethodName(MethodInfo method)
6048 }
6149 }
6250
63- internal class VoidDeclarationsProvider : DeclarationsProvider
64- {
65- public VoidDeclarationsProvider ( Descriptor descriptor ) : base ( descriptor ) { }
66-
67- public override string ReturnsDefinition => "RETURNS_VOID" ;
68- }
69-
70- internal class NonVoidDeclarationsProvider : DeclarationsProvider
71- {
72- public NonVoidDeclarationsProvider ( Descriptor descriptor ) : base ( descriptor ) { }
73-
74- public override string ReturnsDefinition => "RETURNS_NON_VOID" ;
75- }
76-
77- internal class ByRefDeclarationsProvider : NonVoidDeclarationsProvider
78- {
79- public ByRefDeclarationsProvider ( Descriptor descriptor ) : base ( descriptor ) { }
80-
81- public override string WorkloadMethodReturnTypeName => base . WorkloadMethodReturnTypeName . Replace ( "&" , string . Empty ) ;
82-
83- public override string ReturnsDefinition => "RETURNS_BYREF" ;
84-
85- public override string WorkloadMethodReturnTypeModifiers => "ref" ;
86- }
87-
88- internal class ByReadOnlyRefDeclarationsProvider : ByRefDeclarationsProvider
51+ internal class SyncDeclarationsProvider : DeclarationsProvider
8952 {
90- public ByReadOnlyRefDeclarationsProvider ( Descriptor descriptor ) : base ( descriptor ) { }
91-
92- public override string WorkloadMethodReturnTypeModifiers => "ref readonly" ;
53+ public SyncDeclarationsProvider ( Descriptor descriptor ) : base ( descriptor ) { }
9354 }
9455
95- internal class TaskDeclarationsProvider : VoidDeclarationsProvider
56+ internal class AsyncDeclarationsProvider : DeclarationsProvider
9657 {
97- public TaskDeclarationsProvider ( Descriptor descriptor ) : base ( descriptor ) { }
98-
99- public override string GetWorkloadMethodCall ( string passArguments ) => $ "BenchmarkDotNet.Helpers.AwaitHelper.GetResult({ Descriptor . WorkloadMethod . Name } ({ passArguments } ))";
100-
101- protected override Type WorkloadMethodReturnType => typeof ( void ) ;
102- }
103-
104- /// <summary>
105- /// declarations provider for <see cref="Task{TResult}" /> and <see cref="ValueTask{TResult}" />
106- /// </summary>
107- internal class GenericTaskDeclarationsProvider : NonVoidDeclarationsProvider
108- {
109- public GenericTaskDeclarationsProvider ( Descriptor descriptor ) : base ( descriptor ) { }
110-
111- protected override Type WorkloadMethodReturnType => Descriptor . WorkloadMethod . ReturnType . GetTypeInfo ( ) . GetGenericArguments ( ) . Single ( ) ;
58+ public AsyncDeclarationsProvider ( Descriptor descriptor ) : base ( descriptor ) { }
11259
11360 public override string GetWorkloadMethodCall ( string passArguments ) => $ "BenchmarkDotNet.Helpers.AwaitHelper.GetResult({ Descriptor . WorkloadMethod . Name } ({ passArguments } ))";
11461 }
0 commit comments