@@ -219,19 +219,12 @@ public static bool IsAsyncDisposeImplementation([NotNullWhen(returnValue: true)]
219
219
method . IsImplementationOfInterfaceMethod ( null , iAsyncDisposable , "DisposeAsync" ) ;
220
220
}
221
221
222
- /// <summary>
223
- /// Checks the name of the method of an implicit interface implementation (so, as is) or an explicit interface implementation (which also contains the interface as a prefix).
224
- /// </summary>
225
- private static bool IsImplicitOrExplicitInterfaceImplementationName ( this IMethodSymbol method , string name , string interfacePrefix )
226
- => ( method . Name == name && method . MethodKind is MethodKind . Ordinary ) ||
227
- ( method . Name == $ "{ interfacePrefix } .{ name } " && method . MethodKind is MethodKind . ExplicitInterfaceImplementation ) ;
228
-
229
222
/// <summary>
230
223
/// Checks if the given method has the signature "void Dispose()".
231
224
/// </summary>
232
225
private static bool HasDisposeMethodSignature ( this IMethodSymbol method )
233
226
{
234
- return method . IsImplicitOrExplicitInterfaceImplementationName ( "Dispose" , "System.IDisposable" ) &&
227
+ return method . Name == "Dispose" && method . MethodKind == MethodKind . Ordinary &&
235
228
method . ReturnsVoid && method . Parameters . IsEmpty ;
236
229
}
237
230
@@ -250,7 +243,7 @@ public static bool HasDisposeSignatureByConvention(this IMethodSymbol method)
250
243
/// </summary>
251
244
public static bool HasDisposeBoolMethodSignature ( this IMethodSymbol method )
252
245
{
253
- if ( method . IsImplicitOrExplicitInterfaceImplementationName ( "Dispose" , "System.IDisposable" ) &&
246
+ if ( method . Name == "Dispose" && method . MethodKind == MethodKind . Ordinary &&
254
247
method . ReturnsVoid && method . Parameters . Length == 1 )
255
248
{
256
249
IParameterSymbol parameter = method . Parameters [ 0 ] ;
@@ -267,8 +260,7 @@ public static bool HasDisposeBoolMethodSignature(this IMethodSymbol method)
267
260
/// </summary>
268
261
private static bool HasDisposeCloseMethodSignature ( this IMethodSymbol method )
269
262
{
270
- return method . Name == "Close" &&
271
- method . MethodKind is MethodKind . Ordinary &&
263
+ return method . Name == "Close" && method . MethodKind == MethodKind . Ordinary &&
272
264
method . ReturnsVoid && method . Parameters . IsEmpty ;
273
265
}
274
266
@@ -286,7 +278,8 @@ private static bool HasDisposeAsyncMethodSignature(this IMethodSymbol method,
286
278
INamedTypeSymbol ? task ,
287
279
INamedTypeSymbol ? valueTask )
288
280
{
289
- return method . IsImplicitOrExplicitInterfaceImplementationName ( "DisposeAsync" , "System.IAsyncDisposable" ) &&
281
+ return method . Name == "DisposeAsync" &&
282
+ method . MethodKind == MethodKind . Ordinary &&
290
283
method . Parameters . IsEmpty &&
291
284
( SymbolEqualityComparer . Default . Equals ( method . ReturnType , task ) ||
292
285
SymbolEqualityComparer . Default . Equals ( method . ReturnType , valueTask ) ) ;
@@ -298,7 +291,7 @@ private static bool HasDisposeAsyncMethodSignature(this IMethodSymbol method,
298
291
private static bool HasOverriddenDisposeCoreAsyncMethodSignature ( this IMethodSymbol method , [ NotNullWhen ( returnValue : true ) ] INamedTypeSymbol ? task )
299
292
{
300
293
return method . Name == "DisposeCoreAsync" &&
301
- method . MethodKind is MethodKind . Ordinary &&
294
+ method . MethodKind == MethodKind . Ordinary &&
302
295
method . IsOverride &&
303
296
SymbolEqualityComparer . Default . Equals ( method . ReturnType , task ) &&
304
297
method . Parameters . Length == 1 &&
@@ -344,7 +337,7 @@ public static DisposeMethodKind GetDisposeMethodKind(
344
337
{
345
338
return DisposeMethodKind . DisposeBool ;
346
339
}
347
- else if ( method . HasDisposeAsyncMethodSignature ( task , valueTask ) )
340
+ else if ( method . IsAsyncDisposeImplementation ( iAsyncDisposable , valueTask ) || method . HasDisposeAsyncMethodSignature ( task , valueTask ) )
348
341
{
349
342
return DisposeMethodKind . DisposeAsync ;
350
343
}
0 commit comments