@@ -83,7 +83,9 @@ public void TestSameAPI(Type syncInterface, Type asyncInterface)
8383 }
8484
8585 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 ) ;
8789 foreach ( var method in syncInterface . GetMethods ( BindingFlags . Public | BindingFlags . Instance | BindingFlags . DeclaredOnly ) )
8890 {
8991 AddExpected ( method ) ;
@@ -169,6 +171,18 @@ void AddFrom(Type syncInterface, string name, bool fromPropertyToMethod = false)
169171 void AddFromTyped ( Type syncInterface , string name , params Type [ ] types )
170172 => AddExpected ( syncInterface . GetMethod ( name , types ) , false ) ;
171173
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+ }
172186 void AddExpected ( MethodInfo method , bool fromPropertyToMethod = false )
173187 {
174188 if ( method is null ) return ;
@@ -180,7 +194,7 @@ void AddExpected(MethodInfo method, bool fromPropertyToMethod = false)
180194 Type returnType ;
181195 if ( tok . ReturnType == typeof ( void ) )
182196 {
183- returnType = typeof ( ValueTask ) ;
197+ returnType = AsyncType ( tok . ReturnType ) ;
184198 }
185199 else if ( tok . ReturnType == typeof ( IDisposable ) )
186200 {
@@ -192,7 +206,7 @@ void AddExpected(MethodInfo method, bool fromPropertyToMethod = false)
192206 }
193207 else
194208 {
195- returnType = typeof ( ValueTask < > ) . MakeGenericType ( SwapForAsyncIfNeedeed ( tok . ReturnType ) ) ;
209+ returnType = AsyncType ( SwapForAsyncIfNeedeed ( tok . ReturnType ) ) ;
196210 }
197211 string name = tok . Name + "Async" ;
198212 bool addCancellation = true ;
@@ -793,7 +807,7 @@ public MethodToken(string name, Type returnType, ParameterToken[] parameters,
793807 }
794808
795809 [ 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
797811 [ TestCase ( typeof ( IEntityStore ) , typeof ( IEntityStoreAsync ) ) ]
798812 [ TestCase ( typeof ( IEntityStore < > ) , typeof ( IEntityStoreAsync < > ) ) ]
799813 [ TestCase ( typeof ( IRedisClient ) , typeof ( IRedisClientAsync ) ) ]
@@ -825,9 +839,9 @@ public MethodToken(string name, Type returnType, ParameterToken[] parameters,
825839 [ TestCase ( typeof ( IRedisTypedPipeline < > ) , typeof ( IRedisTypedPipelineAsync < > ) ) ]
826840 [ TestCase ( typeof ( IRedisTypedQueueableOperation < > ) , typeof ( IRedisTypedQueueableOperationAsync < > ) ) ]
827841 [ TestCase ( typeof ( IRedisTypedTransaction < > ) , typeof ( IRedisTypedTransactionAsync < > ) ) ]
828- public void TestFullyImplemented ( Type syncInterface , Type asyncInterface )
842+ public void TestFullyImplemented ( Type syncInterface , Type asyncInterface , params Type [ ] ignore )
829843 {
830- HashSet < Type > except = new HashSet < Type > ( ) ;
844+ HashSet < Type > except = new HashSet < Type > ( ignore ?? Type . EmptyTypes ) ;
831845#if NET472 // only exists there!
832846 if ( syncInterface == typeof ( IRedisClientsManager ) )
833847 {
0 commit comments