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

Failure when controller contains several action methods with the same name #164

Open
gmoneh opened this issue Jul 13, 2021 · 4 comments
Open

Comments

@gmoneh
Copy link
Contributor

gmoneh commented Jul 13, 2021

If a controller contains several action methods with the same name, the generated code contains ambiguous definitions:

Example:

Have a controller that contains two EditOrderAddress action methods. The generated code is:

    [GeneratedCode("R4Mvc", "1.0")]
    static readonly ActionParamsClass_EditOrderAddress s_EditOrderAddressParams = new ActionParamsClass_EditOrderAddress();
    [GeneratedCode("R4Mvc", "1.0"), DebuggerNonUserCode]
    public ActionParamsClass_EditOrderAddress EditOrderAddressParams => s_EditOrderAddressParams;
    [GeneratedCode("R4Mvc", "1.0"), DebuggerNonUserCode]
    public class ActionParamsClass_EditOrderAddress
    {
        public readonly string model = "model";
    }

    [GeneratedCode("R4Mvc", "1.0")]
    static readonly ActionParamsClass_EditOrderAddress s_EditOrderAddressParams = new ActionParamsClass_EditOrderAddress();
    [GeneratedCode("R4Mvc", "1.0"), DebuggerNonUserCode]
    public ActionParamsClass_EditOrderAddress EditOrderAddressParams => s_EditOrderAddressParams;
    [GeneratedCode("R4Mvc", "1.0"), DebuggerNonUserCode]
    public class ActionParamsClass_EditOrderAddress
    {
        public readonly string oipID = "oipID";
        public readonly string addressType = "addressType";
        public readonly string address = "address";
        public readonly string setAsDefault = "setAsDefault";
        public readonly string saveToAddressBook = "saveToAddressBook";
    }

As you can see, the same identifiers are used twice, therefore causing a compile error on the project.

This issue is specific to version alpha 00395. In previous versions, this was not the case.

@mazycz
Copy link

mazycz commented Aug 5, 2021

Same for me, when code looks like this

[HttpGet]
public virtual IActionResult ActionName(string mdl)
{
// some code
}

[HttpPost]
public virtual IActionResult ActionName(string mdl2)
{
// some code
}

@dchaib
Copy link

dchaib commented Aug 9, 2021

I believe this has been caused by #139.

If you don't need this new feature, you can disable it in the settings, by setting GenerateParamsForActionMethods to false. It did the trick for me.

@mazycz
Copy link

mazycz commented Aug 9, 2021

It Works!
Thank you.

@MarkFl12
Copy link

MarkFl12 commented Mar 23, 2022

Just to confirm I'm still having this issue preventing me from using GenerateParamsForActionMethods in my project. Considering the Microsoft docs push you into naming your form submission POST controller action as an overload of the GET, this is rather a blocker to the feature being useful.

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

4 participants