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

AsyncAwaitDecompiler not work for methods in struct. #1782

Closed
yyjdelete opened this issue Nov 4, 2019 · 0 comments

Comments

@yyjdelete
Copy link
Contributor

@yyjdelete yyjdelete commented Nov 4, 2019

Tested with master(6.0.0.5337-alpha1)/#1730

Not work for async Task and IAsyncEnumerable(#1730), but IEnumerable works well.

    public struct TestStruct
    {
        int i;
        public async IAsyncEnumerable<int> Test4(TestStruct xx)
        {
            xx.i++;
            i++;
            await Task.Yield();
            yield return this.i;
            yield return xx.i;
        }
        public async Task<int> Test(TestStruct xx)
        {
            xx.i++;
            i++;
            await Task.Yield();
            return this.i + xx.i;
        }
    }

Seems the only difference in IL is that the version for struct will add an ldobj between ldarg.0 and stfld, and the same logic should be used for AsyncAwaitDecompiler.

ldarg.0
+ldobj ConsoleApp1.TestStruct
stfld valuetype ConsoleApp1.TestStruct ConsoleApp1.TestStruct/'<Test>d__2'::'<>4__this'

} else if (value is LdObj ldobj && ldobj.Target.MatchLdThis()) {
// copy of 'this' in struct
fieldToParameterMap[(IField)storedField.MemberDefinition] = ((LdLoc)ldobj.Target).Variable;
} else {

@dgrunwald dgrunwald closed this in eaecedd Nov 5, 2019
fengjixuchui added a commit to fengjixuchui/ILSpy that referenced this issue Nov 6, 2019
Fix icsharpcode#1782: AsyncAwaitDecompiler for methods in struct
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.