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

VB -> C#: Problems with async functions #478

Closed
hez2010 opened this issue Jan 5, 2020 · 3 comments
Closed

VB -> C#: Problems with async functions #478

hez2010 opened this issue Jan 5, 2020 · 3 comments
Assignees
Labels
VB -> C# Specific to VB -> C# conversion

Comments

@hez2010
Copy link

hez2010 commented Jan 5, 2020

Input code

Namespace HLib.Tasks
    Friend Partial Module TaskExtensions
        <Extension()>
        Async Function [Then](Of T)(ByVal task As Task, ByVal f As Func(Of Task(Of T))) As Task(Of T)
            Await task
            Return Await f()
        End Function

        <Extension()>
        Async Function [Then](ByVal task As Task, ByVal f As Func(Of Task)) As Task
            Await task
            Await f()
        End Function

        <Extension()>
        Async Function [Then](Of T, U)(ByVal task As Task(Of T), ByVal f As Func(Of T, Task(Of U))) As Task(Of U)
            Return Await f(Await task)
        End Function

        <Extension()>
        Async Function [Then](Of T)(ByVal task As Task(Of T), ByVal f As Func(Of T, Task)) As Task
            Await f(Await task)
        End Function
    End Module
End Namespace

Erroneous output

namespace HLib.HLib.Tasks
{
    internal static partial class TaskExtensions
    {
        public async static Task<T> Then<T>(this Task task, Func<Task<T>> f)
        {
            await task;
            return await f();
        }

        public async static Task Then(this Task task, Func<Task> f)
        {
            await task;
            await f();
            return default(Task);
        }

        public async static Task<U> Then<T, U>(this Task<T> task, Func<T, Task<U>> f)
        {
            return await f(await task);
        }

        public async static Task Then<T>(this Task<T> task, Func<T, Task> f)
        {
            await f(await task);
            return default(Task);
        }
    }
}

Expected output

namespace HLib.Tasks
{
    internal static partial class TaskExtensions
    {
        public async static Task<T> Then<T>(this Task task, Func<Task<T>> f)
        {
            await task;
            return await f();
        }

        public async static Task Then(this Task task, Func<Task> f)
        {
            await task;
            await f();
        }

        public async static Task<U> Then<T, U>(this Task<T> task, Func<T, Task<U>> f)
        {
            return await f(await task);
        }

        public async static Task Then<T>(this Task<T> task, Func<T, Task> f)
        {
            await f(await task);
        }
    }
}

Details

  • Product in use: latest release
  • Version in use: latest release
@hez2010 hez2010 added the VB -> C# Specific to VB -> C# conversion label Jan 5, 2020
@GrahamTheCoder
Copy link
Member

GrahamTheCoder commented Jan 5, 2020

Great I think this is likely one of the issues mentioned in #316 which I didn't previously have a repro for, thanks!

Looks like the return default logic needs to work differently for async methods

@GrahamTheCoder
Copy link
Member

Just checked - this is still broken in latest master dadc812

@Saibamen
Copy link
Contributor

Fixed in release 8.0.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
VB -> C# Specific to VB -> C# conversion
Projects
None yet
Development

No branches or pull requests

3 participants