-
-
Notifications
You must be signed in to change notification settings - Fork 746
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
How to create custom refit attributes? #793
Comments
I am also in a similar boat, and I attempted the same thing... and got that exception. I think this could be an easy fix. We have strict no "magic strings" policy so either we make every path as constants or we create a custom Get attribute, and the actual route is shared file between Server and Client, and we use ApiController enum to direct the controller we want to call.
This would have been a very simple fix since we already share the route (constants) on server and client, instead we are forced to maintain another set of constants. |
thanks for the idea @iashaik , but i don't really have a problem with the shared route constant like you do, i already figured that out using the repository and unit of work pattern. my problem is that am using routing by action name which means i have to include the action name every time above each method in the interface. so to make development easier what am trying to do is create a custom attribute and somehow use reflection if possible to get the method name from the interface which is in my case the same one as the action name since am using routing by action name, and then include it with the route constant, of course i couldn't do that because i'm stuck at the custom attribute part? but i am curious though as how you managed to create your own custom attribute without getting any exceptions? in end, i just wish if refit had an easy way of doing this:
instead of this:
|
This will need semantic analysis, cause it currently uses a SyntaxTree to read C# code, and the attribute names are hard-coded in InterfaceStubGenerator.cs. I'm going to set up a fork and start prototyping a Roslyn-based approach. |
Should be implemented in #1029 |
Please try v6.0-preview.84 and file bugs as you come across them. |
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. |
am trying to create a custom refit attribute like this:
but a warning appears in visual studio output window when building the project:
and the method fails to generate in RefitStubs.g.cs?
is it possible to create custom refit attributes?
The text was updated successfully, but these errors were encountered: