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

AppBuilderUseExtensions.Use has to be explicitly called in VB. #84

Closed
jkang027 opened this issue Jul 6, 2017 · 1 comment
Closed

AppBuilderUseExtensions.Use has to be explicitly called in VB. #84

jkang027 opened this issue Jul 6, 2017 · 1 comment
Milestone

Comments

@jkang027
Copy link

jkang027 commented Jul 6, 2017

AppBuilderUseExtensions.Use extension method cannot be used in VB (except by calling it explicitly) because its name conflicts with an instance method ( IAppBuilder.Use ) that accepts any number of object parameters and, thus, will always take precedence.

Probably due to the fact that lambda expressions can be implicitly converted to delegates in VB. This code works for C#.

app.Use(async (context, next) =>
{
    using (AsyncScopedLifestyle.BeginScope(container))
    {
        await next();
    }
});

But the VB equivalent does not. Instead of calling the extension method, it calls the instance method.

app.Use(Async Function(context, [next]) As Task
                  Using AsyncScopedLifestyle.BeginScope(container)
                      Await [next]()
                  End Using
              End Function)

The extension has to be called explicitly in VB.

AppBuilderUseExtensions.Use(app, Async Function(context, [next]) As Task
                                     Using AsyncScopedLifestyle.BeginScope(container)
                                         Await [next]()
                                     End Using
                                 End Function)
@Tratcher Tratcher added this to the Backlog milestone Jul 13, 2017
@analogrelay
Copy link

This is unfortunate but I don't know that there's a clear way to fix it. Happy to consider a contribution if someone has a non-breaking way to do this!

@ghost ghost locked as resolved and limited conversation to collaborators Jan 6, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants