You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[BUG] Multiple interfaces with same name but different namespace #1261
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
Create a project named SampleClient
Add an ISampleClient interface in the SampleClient.First namespace with a [Get("/")] Task<string> GetAsync() method
Add an ISampleClient interface in the SampleClient.Second namespace with a [Get("/")] Task<HttpResponseMessage> GetAsync() method
Add an ISampleClient interface in the SampleClient.Third namespace with a [Get("/")] Task<ApiResponse<string>> GetAsync() method
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.
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.
Activity
[-][BUG] Summary of item[/-][+][BUG] Multiple interfaces with same name but different namespace[/+]Almis90 commentedon Oct 31, 2021
Just noticed the same issue, is there any workaround for this? Except of renaming all the interfaces.
dtewinkel commentedon Mar 12, 2023
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.Fix reactiveui#1261
dtewinkel commentedon Jul 20, 2023
I am trying to fix this and hope to have a PR soon.
Ensure two interfaces with the same name do not cause compile errors (r…
github-actions commentedon Jun 24, 2024
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.