Proposed: a 'static' modifier on delegate argument declaration #7693
Replies: 3 comments 1 reply
-
You could use an analyzer to enforce that the delegate passed to a particular is a static lambda. I'm not sure I understand the use case of wanting to try to enforce that from the method. Why does it care what delegate was passed to it or how it was created? |
Beta Was this translation helpful? Give feedback.
-
As a consumer that has code with numerous calls to Execute(), each having different delegate arguments, I can avoid having to apply the static modifier to each delegate? |
Beta Was this translation helpful? Give feedback.
-
The intent of declaring the argument as 'static' is precisely the same as declaring each delegate passed to it as static. It's just another way of achieving the same objective, differing only in semantics, and that the former avoids pollution of calling code clarity. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I want to know how I can declare a method that requires
a delegate as an argument to be passed a static delegate,.
So, how I can require the Execute() member to be passed a static delegate, as is done in the above example?
For example, why should it not be possible for the called API to require its delegate argument to be static, perhaps by doing something akin to this:
Beta Was this translation helpful? Give feedback.
All reactions