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.

Automatic cancellation support

See original GitHub issue

I have a lot of dependencies with (usually async) methods that accept a CancellationToken. When the token is cancelled, these methods throw an OperationCanceledException. This is the expected implicit behavior for these methods, but by default, fakes don’t throw anything when they receive a call with a cancelled token. So my thinking is that this behavior could be baked into FakeItEasy as a default rule. Currently I use a method like this:

private static void ConfigureCancellation(object obj)
{
    A.CallTo(obj)
        .WhenArgumentsMatch(args => args.OfType<CancellationToken>().Any(ct => ct.IsCancellationRequested))
        .Invokes(call => call.Arguments.OfType<CancellationToken>().FirstOrDefault(ct => ct.IsCancellationRequested).ThrowIfCancellationRequested());
}

It works fine, but I have to remember to call it on each fake.

Note that enabling this by default would, technically, be a breaking change, although probably not one that would affect many users.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:28 (28 by maintainers)

github_iconTop GitHub Comments

1reaction
adamralphcommented, Dec 1, 2016

I’m fine with it being part of 3.0.0.

There’s no firm definition of the phases, but the way I see it is:

  • alpha: anything may change before RTM and probably will.
  • beta: things may still change before RTM but they probably won’t.
  • RC: RTM quality. Will be the RTM if no bugs are found. The only changes before RTM will be bug fixes and they will generate a new RC each time.

I think beta is the “grey zone” and is the tough one to call. Alpha and RC are relatively easy. I think it’s reasonable to call beta if nothing more is planned to change at that time the beta is released, and this is what we did in this case.

1reaction
adamralphcommented, Nov 26, 2016

I’m fine with leaving it open if we still want to explore other ways of doing it.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Automatic cancellation Sample Clauses
Automatic cancellation. The Commitment of each Lender will be automatically cancelled at the close of business on the last day of the Availability...
Read more >
Auto Cancellation Rule FAQs
My reservation is cancelled due to the auto cancellation rule. However, I still need to travel. Will I be able to obtain the...
Read more >
How do I stop automatic payments from my bank account?
Further, cancelling your automatic payment does not cancel your contract with the company. If you want to cancel a contract for a service,...
Read more >
Automatic Cancellation
Automatic Cancellation. How is it possible that I return all of the equipment I purchased from Simplisafe, they credit me for that return, ......
Read more >
Travel: Auto Cancel Fact Sheet
Concur Travel's auto-cancel process supports agent-claimed trips. The auto-cancel robot will look for the presence of a standard remark in the ...
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