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

"this" keyword required? #28

Open
jorgeyanesdiez opened this issue Jan 12, 2017 · 1 comment
Open

"this" keyword required? #28

jorgeyanesdiez opened this issue Jan 12, 2017 · 1 comment
Assignees
Milestone

Comments

@jorgeyanesdiez
Copy link

jorgeyanesdiez commented Jan 12, 2017

In the following scenario, keyword this is required; I assume this is because you have
two generic methods with both TController : Controller and TController : class.
This is annoying. Why do you need the TController: class version? Am I missing something?

using Microsoft.AspNetCore.Mvc;

namespace MyNamespace
{
    public class HomeController
        : Controller
    {
        public IActionResult Index()
        {
            return this.RedirectToAction<OtherController>(c => c.Index());
        }
    }
}

Additionally, it'd be great if your extension methods lived under another namespace, and not the official Microsoft.AspNetCore.Mvc, mainly for clarity and extensibility. For example, to fix the above I thought of making a wrapper class in my namespace so that only the methods with TController : Controller are "locatable" in my code, but since I obviously need the official Microsoft.AspNetCore.Mvc namespace, then I get method name clashes. What do you think?

@ivaylokenov ivaylokenov self-assigned this Jan 14, 2017
@ivaylokenov ivaylokenov added this to the Version 2.0.0 milestone Jan 14, 2017
@ivaylokenov
Copy link
Owner

ivaylokenov commented Jan 14, 2017

@jorgeyanesdiez Hi, the this keyword is required by the C# language when your extension method is called from the extended class itself. I do not know any options to remove it.

As for the namespace, I will think about it. Thank you for the suggestion! 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants