postsharp / Metalama

Metalama is a Roslyn-based meta-programming framework. Use this repo to report bugs or ask questions.
181 stars 6 forks source link

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

Open tg73 opened 1 year ago

tg73 commented 1 year ago

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.

PostSharpBot commented 1 year ago

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.