-
-
Notifications
You must be signed in to change notification settings - Fork 760
Explicit interface inheritance #633
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
Conversation
…mplateInformation object
…ods by it's interfaces
Looks good - one question came up as I was looking at the code: what happens if there are different, possibly conflicting attributes on the interface -- for Header, Auth, or any of the others. Which one wins and is it clear? |
@onovotny I'm not sure how refit currently handles these cases, but I'd say the result here depends on the current behavior of the library, that is: If the first case is true (it should be) then it should be fine, otherwise if you'd like refit to throw when more than one attribute of that kind is present, I guess that's something that isn't strickly related to this PR in particular, and should be fixed for the library as a whole (maybe with a dedicated PR?). 8000 EDIT: double checked, the current behavior seems to be the expected one. With this code: [Headers("User-Agent: AAA")]
public interface IAmInterfaceA
{
[Get("/get?result=Ping")]
Task<string> Ping();
}
[Headers("User-Agent: BBB")]
public interface IAmInterfaceB
{
[Get("/get?result=Pong")]
Task<string> Pong();
}
[Headers("User-Agent: CCC")]
public interface IAmInterfaceC : IAmInterfaceB, IAmInterfaceA
{
[Get("/get?result=Pang")]
[Headers("User-Agent: PANG")]
Task<string> Pang();
[Get("/get?result=Foo")]
Task<string> Foo();
} Calling |
Hey @onovotny - not sure if you saw my updated reply (I've edited my comment with more info after I first replied to you), the attributes handling seems to be working fine and as expected (see my code snippet above). Please let me know if there's anything else you need or if this PR is good to go for you, I'm looking forward for finally being able to use this in my project 😄 |
As this is new behavior (Refit didn't have any inheritance before), that seems okay. Please update the main docs (the readme) showing this new behavior and explaining what happens if there's multiple conflicting attributes and then this can be merged. |
This continues the work from @Iss0 in #523 on the interface inheritance for Refit services.
In particular, here I've updated the stub generator as @onovotny asked, so that Refit now does explicit interface inheritance in order to properly handle cases where multiple interfaces declare methods with the same name but different return values.