1
- using System ;
2
- using System . Linq ;
3
- using System . Reflection ;
1
+ using System . Reflection ;
4
2
using System . Threading . Tasks ;
5
- using BenchmarkDotNet . Engines ;
6
3
using BenchmarkDotNet . Extensions ;
7
- using BenchmarkDotNet . Helpers ;
8
4
using BenchmarkDotNet . Running ;
9
5
10
6
namespace BenchmarkDotNet . Code
@@ -30,14 +26,6 @@ internal abstract class DeclarationsProvider
30
26
31
27
public string IterationCleanupMethodName => Descriptor . IterationCleanupMethod ? . Name ?? EmptyAction ;
32
28
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
-
41
29
public virtual string GetWorkloadMethodCall ( string passArguments ) => $ "{ Descriptor . WorkloadMethod . Name } ({ passArguments } )";
42
30
43
31
private string GetMethodName ( MethodInfo method )
@@ -60,55 +48,14 @@ private string GetMethodName(MethodInfo method)
60
48
}
61
49
}
62
50
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
89
52
{
90
- public ByReadOnlyRefDeclarationsProvider ( Descriptor descriptor ) : base ( descriptor ) { }
91
-
92
- public override string WorkloadMethodReturnTypeModifiers => "ref readonly" ;
53
+ public SyncDeclarationsProvider ( Descriptor descriptor ) : base ( descriptor ) { }
93
54
}
94
55
95
- internal class TaskDeclarationsProvider : VoidDeclarationsProvider
56
+ internal class AsyncDeclarationsProvider : DeclarationsProvider
96
57
{
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 ) { }
112
59
113
60
public override string GetWorkloadMethodCall ( string passArguments ) => $ "BenchmarkDotNet.Helpers.AwaitHelper.GetResult({ Descriptor . WorkloadMethod . Name } ({ passArguments } ))";
114
61
}
0 commit comments