@@ -83,7 +83,9 @@ public void TestSameAPI(Type syncInterface, Type asyncInterface)
83
83
}
84
84
85
85
var expected = new List < string > ( ) ;
86
- ParameterToken cancellationToken = new ParameterToken ( "cancellationToken" , typeof ( CancellationToken ) , ParameterAttributes . Optional ) ;
86
+ ParameterToken cancellationToken = new ParameterToken (
87
+ ( asyncInterface == typeof ( IRemoveByPatternAsync ) || asyncInterface == typeof ( ICacheClientAsync ) )
88
+ ? "token" : "cancellationToken" , typeof ( CancellationToken ) , ParameterAttributes . Optional ) ;
87
89
foreach ( var method in syncInterface . GetMethods ( BindingFlags . Public | BindingFlags . Instance | BindingFlags . DeclaredOnly ) )
88
90
{
89
91
AddExpected ( method ) ;
@@ -169,6 +171,18 @@ void AddFrom(Type syncInterface, string name, bool fromPropertyToMethod = false)
169
171
void AddFromTyped ( Type syncInterface , string name , params Type [ ] types )
170
172
=> AddExpected ( syncInterface . GetMethod ( name , types ) , false ) ;
171
173
174
+ Type AsyncType ( Type result )
175
+ {
176
+ bool useTask = asyncInterface == typeof ( ICacheClientAsync )
177
+ || asyncInterface == typeof ( IRemoveByPatternAsync )
178
+ || asyncInterface == typeof ( IEntityStoreAsync )
179
+ || asyncInterface == typeof ( IEntityStoreAsync < > ) ;
180
+
181
+ if ( result is null || result == typeof ( void ) )
182
+ return useTask ? typeof ( Task ) : typeof ( ValueTask ) ;
183
+
184
+ return ( useTask ? typeof ( Task < > ) : typeof ( ValueTask < > ) ) . MakeGenericType ( result ) ;
185
+ }
172
186
void AddExpected ( MethodInfo method , bool fromPropertyToMethod = false )
173
187
{
174
188
if ( method is null ) return ;
@@ -180,7 +194,7 @@ void AddExpected(MethodInfo method, bool fromPropertyToMethod = false)
180
194
Type returnType ;
181
195
if ( tok . ReturnType == typeof ( void ) )
182
196
{
183
- returnType = typeof ( ValueTask ) ;
197
+ returnType = AsyncType ( tok . ReturnType ) ;
184
198
}
185
199
else if ( tok . ReturnType == typeof ( IDisposable ) )
186
200
{
@@ -192,7 +206,7 @@ void AddExpected(MethodInfo method, bool fromPropertyToMethod = false)
192
206
}
193
207
else
194
208
{
195
- returnType = typeof ( ValueTask < > ) . MakeGenericType ( SwapForAsyncIfNeedeed ( tok . ReturnType ) ) ;
209
+ returnType = AsyncType ( SwapForAsyncIfNeedeed ( tok . ReturnType ) ) ;
196
210
}
197
211
string name = tok . Name + "Async" ;
198
212
bool addCancellation = true ;
@@ -793,7 +807,7 @@ public MethodToken(string name, Type returnType, ParameterToken[] parameters,
793
807
}
794
808
795
809
[ TestCase ( typeof ( ICacheClient ) , typeof ( ICacheClientAsync ) ) ]
796
- [ TestCase ( typeof ( ICacheClientExtended ) , typeof ( ICacheClientAsync ) ) ] // duplicate not an error; APIs are coalesced
810
+ [ TestCase ( typeof ( ICacheClientExtended ) , typeof ( ICacheClientAsync ) , typeof ( BasicRedisClientManager ) ) ] // duplicate not an error; APIs are coalesced
797
811
[ TestCase ( typeof ( IEntityStore ) , typeof ( IEntityStoreAsync ) ) ]
798
812
[ TestCase ( typeof ( IEntityStore < > ) , typeof ( IEntityStoreAsync < > ) ) ]
799
813
[ TestCase ( typeof ( IRedisClient ) , typeof ( IRedisClientAsync ) ) ]
@@ -825,9 +839,9 @@ public MethodToken(string name, Type returnType, ParameterToken[] parameters,
825
839
[ TestCase ( typeof ( IRedisTypedPipeline < > ) , typeof ( IRedisTypedPipelineAsync < > ) ) ]
826
840
[ TestCase ( typeof ( IRedisTypedQueueableOperation < > ) , typeof ( IRedisTypedQueueableOperationAsync < > ) ) ]
827
841
[ TestCase ( typeof ( IRedisTypedTransaction < > ) , typeof ( IRedisTypedTransactionAsync < > ) ) ]
828
- public void TestFullyImplemented ( Type syncInterface , Type asyncInterface )
842
+ public void TestFullyImplemented ( Type syncInterface , Type asyncInterface , params Type [ ] ignore )
829
843
{
830
- HashSet < Type > except = new HashSet < Type > ( ) ;
844
+ HashSet < Type > except = new HashSet < Type > ( ignore ?? Type . EmptyTypes ) ;
831
845
#if NET472 // only exists there!
832
846
if ( syncInterface == typeof ( IRedisClientsManager ) )
833
847
{
0 commit comments