Skip to content

(maybe) await in catch/finally -- new language feature (test case available) #14

@goojal

Description

@goojal

When there is await in catch or finally clauses, in IL we can see compiler takes await out of catch clause and skips it if we never been in catch. And the flag is just a local variable so we don't see this block as a candidate of state controller block.
The reason we might not want to look for this pattern is the test shown below will result in exact same IL. So there is more than one way to generate same state machine.

        private static async Task AwaitInCatchV2()
        {
            int num = 0;
            try
            {
                Console.WriteLine("asd");
            }
            catch
            {
                num = 1;
            }
            if (num == 1)
            {
                await Task.Delay(5);
            }
        }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions