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] Multiple interfaces with same name but different namespace #1261

Closed
outofrange-consulting opened this issue Oct 25, 2021 · 4 comments · Fixed by #1712
Closed

[BUG] Multiple interfaces with same name but different namespace #1261

outofrange-consulting opened this issue Oct 25, 2021 · 4 comments · Fixed by #1712
Labels

Comments

@outofrange-consulting
Copy link

outofrange-consulting commented Oct 25, 2021

Describe the bug
When trying to generate clients from multiple interfaces with the same name, but different namespaces, there seems to be a limit at two interfaces before nothing is generated.

Steps To Reproduce

  1. Create a project named SampleClient
  2. Add an ISampleClient interface in the SampleClient.First namespace with a [Get("/")] Task<string> GetAsync() method
  3. Add an ISampleClient interface in the SampleClient.Second namespace with a [Get("/")] Task<HttpResponseMessage> GetAsync() method
  4. Add an ISampleClient interface in the SampleClient.Third namespace with a [Get("/")] Task<ApiResponse<string>> GetAsync() method
  5. Try to obtain clients for the three interfaces with RestService.For<T>()

Expected behavior
All three interfaces should generate a different client and work with RestService.For<T>()

Environment

  • OS: Windows 10 / Ubuntu 20.04
  • Device: NA
  • Version: 6.1.15
  • Working Version:

Additional context

  • An error "T doesn't look like a Refit interface. Make sure it has at least one method with a Refit HTTP method attribute and Refit is installed in the project." is thrown.
  • Debugging shows that after the third interface is added, clients in the Refit.Internal.Generated namespace are not generated anymore.
  • Everything works as expected when only two interfaces are present in the project.
@outofrange-consulting outofrange-consulting changed the title [BUG] Summary of item [BUG] Multiple interfaces with same name but different namespace Oct 25, 2021
@Almis90
Copy link

Almis90 commented Oct 31, 2021

Just noticed the same issue, is there any workaround for this? Except of renaming all the interfaces.

@dtewinkel
Copy link
Contributor

I am running into the same issue, after switching from RestEase, where this is no issue. I Want to switch to Refit to use System.Text.Json instead of Newtonsoft.Json, because now I have a mix of them both due to different dependencies.

So I have the same question as @Almis90; is there a way to work around this, except for renaming all my interfaces?

P.S. the message Visual studio gives is Warning CS8785 Generator 'InterfaceStubGeneratorV2' failed to generate source. It will not contribute to the output and compilation errors may occur as a result. Exception was of type 'ArgumentException' with message 'The hintName 'IShelly1.g.cs' of the added source file must be unique within a generator.

dtewinkel pushed a commit to dtewinkel/refit that referenced this issue Jul 20, 2023
@dtewinkel
Copy link
Contributor

I am trying to fix this and hope to have a PR soon.

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 Jun 24, 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.

3 participants