Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

invalid sync sibling (few troubles) #88

Open
lsoft opened this issue Oct 11, 2024 · 0 comments
Open

invalid sync sibling (few troubles) #88

lsoft opened this issue Oct 11, 2024 · 0 comments

Comments

@lsoft
Copy link

lsoft commented Oct 11, 2024

Consider the method:

[Zomp.SyncMethodGenerator.CreateSyncVersion]
public async Task<bool> TestMethodAsync()
{
    var testInt = 1;

    if (testInt is 2)
    {
        await Task.Delay(1);
        return false;
    }

    if (testInt is not 2)
    {
        await Task.Delay(1);
        return true;
    }

    var testEnum = MyEnum.None;

    if (testEnum is MyEnum.None)
    {
        await Task.Delay(1);
        return true;
    }

    if (testEnum is not MyEnum.None)
    {
        await Task.Delay(1);
        return false;
    }

    return true;
}

the generator produces the following:

public bool TestMethod()
{
    var testInt = 1;

    if (testInt is int) //ERROR
    {
        global::System.Threading.Thread.Sleep(1);
        return false;
    }

    if (testInt is not int) //ERROR
    {
        global::System.Threading.Thread.Sleep(1);
        return true;
    }

    var testEnum = global::ConsoleApp181.Class1.MyEnum.None;

    if (testEnum is global::ConsoleApp181.Class1.MyEnum.None)
    {
        global::System.Threading.Thread.Sleep(1);
        return true;
    }

    if (testEnum is not global::ConsoleApp181.Class1.MyEnum) //ERROR
    {
        global::System.Threading.Thread.Sleep(1);
        return false;
    }

    return true;
}

There are few problems with enum values and constant int values.

        public enum MyEnum
        {
            None = 0,
            Yes = 1
        }
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

No branches or pull requests

1 participant