Metalama icon indicating copy to clipboard operation
Metalama copied to clipboard

Suggestion: optional warning when `Invoke` is called `IMethod` without `With`

Open tg73 opened this issue 9 months ago • 1 comments

I suggest that calling Invoke on an IMethod directly, without using With( InvokerOptions ) should report a diagnostic warning. This is in the spirit of more modern C# globalization warnings such as CA1307 ("Specify StringComparison for clarity"). Direct calls without using With have the default context-dependent behaviour which may not be the developer's intent. Using With makes the developer's intent clear. The warning could be suppressed if desired, or indeed it could be severity None by default, increased to Warning according to user preference.

Differing opinions welcome.

tg73 avatar Sep 15 '23 13:09 tg73

Hello @tg73, thank you for submitting this issue. We will try to get back to you as soon as possible. Note to the PostSharp team, this ticket is being tracked in our dashboard under ID TP-33796.

PostSharpBot avatar Sep 15 '23 13:09 PostSharpBot