question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add `Action` based `Match` (or similarly named) method

See original GitHub issue

I am attempting to replace my custom T4 based union generator with dunet. Currently, my implementation generates an Either method which is functionally identical to the Match method generated by dunet, and a Do method, which is similar, but takes an Action for each union case, and does not return a value. Dunet does not appear to currently have such a method. The generated code should be identical to the current Match, except that it would return void rather than TMatchOutput, would take Action instead of Func delegates, and would not need to be generic on TMatchOutput, as there would be no output.

Issue Analytics

  • State:closed
  • Created a year ago
  • Reactions:1
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
TheJayManncommented, Oct 11, 2022

Looking at the generated code, it appears that it would work well enough. I noticed that a corresponding task version is not created. Although this is not a feature I am seeking currently, I believe it would make sense to implement for the sake of symmetry.

1reaction
TheJayManncommented, Oct 5, 2022

I’ve done similar in the past. For now, the way I decided to work around it is that I instead returned a different Action delegate for each match case, then invoked the action returned.

Anonymized example:

            union.Match<Action<Input>>(
                case1 => input => input.Value1 = case1.Value,
                case2 => input => input.Value2 = case2.Value,
                case3 => input => input.Value3 = case3.Value
            ).Invoke(input);
Read more comments on GitHub >

github_iconTop Results From Across the Web

How to name a method which may or may not perform an ...
The reason I am not using two separate methods ( shouldPerformAction() and performAction() ) is because both the condition and the action depend ......
Read more >
Creating agent skills to use for routing
A name; A way to add that skill to tickets; A set of agents who have that skill. Understanding how skills are used...
Read more >
Defining ASP.NET Core Controller action constraint to ...
The name of the method is different but they both will receive a single argument of type string. When the routing engine can't...
Read more >
Matching methods and techniques for rule packages
The matching can be performed using either an exact match or word match based algorithms. Exact match uses a case-sensitive algorithm that ...
Read more >
Matching methods for causal inference: A review and ...
Another effective strategy is to include a small set of covariates known to be related to the outcomes of interest, do the matching,...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found