[Feature Request] Change Ref approach to expression-based
See original GitHub issueDescribe the solution you’d like
Akin to Hangfire and others, use LINQ expressions to let calls be made. This is more inline with how other .NET libraries work. We need to make sure status still work and we can extract return types in Task
vs non-Task
. This will also require updating docs and the blog post.
Also, as part of this effort, we need to modernize registration of activities and workflows. We probably need to:
- Make definitions the only collections on worker options instead of the “additional”
- Allow activities to also be registered by entire type/class that crawls looking for activity attributed
- Abstract activity definition a tad to accept a form with arg types, return type, and a
Func<object?, Task<object?[]?>>
invoker. Put anInvokeAsync
on it I guess. This is needed for dependency injection support. Would accept alternative activity class factory approach if we can think of it, though this is probably good enough. Can expose this all the way out to theAddActivity
overload in the worker options.
Issue Analytics
- State:
- Created 5 months ago
- Reactions:2
- Comments:5 (4 by maintainers)
Top Results From Across the Web
Expression-Based Access Control :: Spring Security
Expressions are evaluated with a "root object" as part of the evaluation context. Spring Security uses specific classes for web and method security ......
Read more >Managing feature requests: A comprehensive guide
Discuss feature requests with your teammates and relevant stakeholders (and ensure they understand how you're making decisions) · How to share feedback. ·...
Read more >How do I write a good feature request?
A feature request typically stems from a selfish need: Yes, something that you feel should change to benefit your usage of the site....
Read more >Rename 'Feature Request' to 'Feedback'
A feature request is a change request or new requirement, to your existing product. Something where a customer says, what she would like...
Read more >Showing the Feature Requests List
The following method can be used to display the Feature Requests page to your users. Once you display the page, the users can...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Ok, did some discussion with team. I am going to open a PR all-in on the expression approach (assuming I don’t hit snags with inference). We can evaluate that then. That means you actually can’t use the delegate/ref pattern if you wanted to (sorry!). So basically:
Becomes:
With the removal of the dependency, familiarity to .NET devs, and that we (really really) hate two ways of doing things, this just won out. But we’ll reevaluate during PR time if I hit any snags.
Ok, could use some more feedback here (x-posted to
#dotnet-sdk
on Slack). If I have:I need to evaluate that argument. From what I read, that means I have to use an approach like https://stackoverflow.com/a/60002882 (basically create a lambda out of each argument and compile at call time) which is really slow. Even
Compile(true)
available in all but our oldest supported version (framework 4.6) is slow. If you had passed:Then I could just use
ConstantExpression.Value
, but that is a non-obvious optimization to users to make sure they create their parameter outside the closure. And .NET can’t infer params for something like:Looking at hangfire and others, they have elaborate evaluators and will cache some known expression tree patterns resorting to
Compile()
as needed.Options (not all are mutually exclusive):
Thoughts? I didn’t put “allow expression trees and ref pattern” above because we just can’t reasonably have two approaches. I may do option 2 for now while implementing, but option 1 sure looks tempting and I am hoping I don’t have to maintain two approaches just so I can benchmark differences.