Skip to content

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

Closed

Description

@outofrange-consulting

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.

Activity

  1. changed the title [-][BUG] Summary of item[/-] [+][BUG] Multiple interfaces with same name but different namespace[/+] on Oct 25, 2021
  2. Almis90 commented on Oct 31, 2021

    @Almis90

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

  3. dtewinkel commented on Mar 12, 2023

    @dtewinkel
    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.

  4. added a commit that references this issue on Jul 20, 2023
    84d2089
  5. dtewinkel commented on Jul 20, 2023

    @dtewinkel
    Contributor

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

  6. added a commit that references this issue on Jun 10, 2024
    9c2caf3
  7. github-actions commented on Jun 24, 2024

    @github-actions

    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.

  8. locked as resolved and limited conversation to collaborators on Jun 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions