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
[Bug]: IGitHubApi 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. #1920
Refit.RestService.For throws an error if the name of the file .csproj has special characters like -@.
To fix it just rename your .csproj file removing special characters (_ is supported)
Example: Refit-Test.csproj ~> RefitTest.csproj
This issue seems to arise because Refit's code generation depends on the project name, which may cause invalid namespaces or class names in generated code when special characters are present.
It would be helpful if Refit could:
Check and throw an error with a message about special characters on .csproj file.
OR
Sanitize the name of .csproj file for generating code
OR at least
Include a note in the documentation about valid .csproj naming conventions when using Refit.
I created this issue is so that people who are facing this very specific problem to find the solution here.
Step to reproduce
usingSystem;usingSystem.Threading.Tasks;usingRefit;namespaceRefitTest{publicclassMainClass{publicstaticasyncTaskMain(string[]args){vargitHubApi=RestService.For<IGitHubApi>("https://api.github.com");varuser=awaitgitHubApi.GetUser("ViniciusCestarii");Console.WriteLine(user);}}publicinterfaceIGitHubApi{[Headers("User-Agent: My Favorite User Agent!")][Get("/users/{user}")]Task<object>GetUser(stringuser);}}