Replies: 4 comments 6 replies
-
..or IsHandled. But do we really want to hardcode this based on the name? There are more cases, like for example a temporary table should also passed by var. Just thinking at loud here; maybe an other way around is all event publisher with “OnBefore” in the name should pass all variables as var? |
Beta Was this translation helpful? Give feedback.
-
I agree that there are more cases where it's needed, but in my case, I usually discover such a problem during the code review. But I did not put much effort into the IsHandled checks. Maybe we can start with IsHandled (I think the name is now standardized), and if it's needed, it can be extended later to some other use cases (especially as IsHandled will be easy to implement, temporary records or temporary tables probably not so easy). |
Beta Was this translation helpful? Give feedback.
-
@f4n0 and @TKapitan , thank you for the idea and proving feedback here! I've created a new rule: LC0073 - Handled parameters in event signatures should be passed by var which is now available in the v0.31.3 (pre)release version of the LinterCop.
This made me confided to set the default severity to |
Beta Was this translation helpful? Give feedback.
-
Thanks @Arthurvdv. Would it be much effort to not show the warning for obsoleted events? I don't have an issue adding pragma, but I know that we have a few projects where we still have the events as obsoleted and not removed (events we had to obsolete to fix the IsHandled) |
Beta Was this translation helpful? Give feedback.
-
Happens a lot, even Microsoft has made a mistake like that.
if the Event signature, contains a parameter called "Handled" must be passed by var
Beta Was this translation helpful? Give feedback.
All reactions