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

[Bug]: Parameter named ex causes compile error #1724

Closed
pro1dream opened this issue Jun 20, 2024 · 3 comments · Fixed by #1735
Closed

[Bug]: Parameter named ex causes compile error #1724

pro1dream opened this issue Jun 20, 2024 · 3 comments · Fixed by #1735
Assignees
Labels

Comments

@pro1dream
Copy link

pro1dream commented Jun 20, 2024

Describe the bug 🐞

When using a parameter named ex in a method of an interface used by refit, there's a name clash in the generated code that prevents compilation.

Step to reproduce

  • Create an interface with a method like so:
interface IMyClient 
{
    [Get("/")]
    Task MyMethodAsync(string ex);
}
  • Try to compile
  • You will get the following error:
error CS0136: A local or parameter named 'ex' cannot be declared in this scope because that name is used in an enclosing local scope to define a local or parameter

Reproduction repository

No response

Expected behavior

It should compile

Screenshots 🖼️

No response

IDE

Visual Studio 2022

Operating system

Windows

Version

10

Device

No response

Refit Version

7.1.0

Additional information ℹ️

No response

@pro1dream pro1dream added the bug label Jun 20, 2024
@ChrisPulman
Copy link
Member

Thank you for raising this, we will see if there's a way to avoid clashing with the Source Generated code.
I assume that you are only experiencing this issue with an exact matched parameter in your Source named "ex"

@ChrisPulman ChrisPulman self-assigned this Jun 20, 2024
@ChrisPulman
Copy link
Member

I you happen to have a repo that demonstrates the issue, this would be very useful too, thank you.

ChrisPulman added a commit that referenced this issue Jun 24, 2024
Common parameter name used in generated code
ChrisPulman added a commit that referenced this issue Jun 26, 2024
* Fix For #1724

Common parameter name used in generated code

* Use more standard name as other generated code
Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 11, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants