Skip to content

Conversation

@adamhathcock
Copy link
Contributor

First time to contribute here.

Looking at solving: #457

Might have issues as I couldn't compile all target frameworks on my mac.

@adamhathcock
Copy link
Contributor Author

Also probably solves: #471

@josephwoodward
Copy link
Contributor

Sorry for the late reply, thanks for this!

@josephwoodward
Copy link
Contributor

I'll fix the merge conflict then get it out in the next release.

@colinangusmackay
Copy link

Is there a time-frame for this to put pushed out to NuGet? The last package that I can see there was November 2018, and this was merged in to Master in June 2019.

@josephwoodward
Copy link
Contributor

Hi @colinangusmackay

There's currently a 4.0.0 beta that doesn't introduce any major breaking changes that will include this.

@alexnnenn
Copy link

I've just tried testing call of function Foo and got different behaviour in test, depending on what variant I use:

private static async Task Foo()
{
    await Task.Yield();
    throw new OperationCanceledException();
}

private static async Task ShoudlyVariant2(Type exceptionType)
{
    try
    {
        var exception = await Should.ThrowAsync(Foo, exceptionType);
        Console.WriteLine("ShoudlyV2: " + exception.GetType());
    }
    catch(ShouldAssertException s) when (s.Message.Contains("but did not"))
    {
        Console.WriteLine("Variant 2 did not got " + exceptionType.Name);
    }
}

// manual variant
try
{
    await Foo();
}
catch (Exception x)
{
    Console.WriteLine("Manual:" + x.GetType());
}

// Shoudly variant 1
var exceptionV1 = await Should.ThrowAsync<Exception>(Foo);
Console.WriteLine("ShoudlyV1: " + exceptionV1.GetType());

// Shoudly variant 2
await ShoudlyVariant2(typeof(Exception));
await ShoudlyVariant2(typeof(TaskCanceledException));
await ShoudlyVariant2(typeof(OperationCanceledException));

The output is:

Manual: System.OperationCanceledException
ShoudlyV1: System.Threading.Tasks.TaskCanceledException
Variant 2 did not got Exception
Variant 2 did not got TaskCanceledException
Variant 2 did not got OperationCanceledException

I've expected that It will be OperationCanceledException in all variants. It seems, that ThrowAsync still works wrong in case of canceled task.

I've used latest available release version 4.0.3.

@sungam3r
Copy link
Contributor

@alexnnenn Worth to open new issue. This one may be lost.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants