Reft client from C# library project reports runtime error [... doesn't look like a Refit interface] in C# cells, while works for F#
Describe the bug
I have a C# class library project which uses Refit package to generate some web api client. When I was trying to reference that client in C# notebook I'm getting the error saying that client interface doesn't look like Refit interface. If I switch the language to F# I'm able to create the client object and perform API calls in notebook. Here is the repo with sample project and test notebook: https://github.com/konst-sh/Netinteractive_Reft_issue
Please complete the following:
Which version of .NET Interactive are you using? (In a notebook, run the #!about magic command. ):
Version: 1.0.556301+aa2c36d2531670229bd0ba9e7fa330e70cb5eb5d
Library version: 1.0.0-beta.24563.1+aa2c36d2531670229bd0ba9e7fa330e70cb5eb5d
Build date: 2024-11-14T11:26:58.6533506Z
- OS
- [+] Windows 11
- [ ] Windows 10
- [ ] macOS
- [ ] Linux (Please specify distro)
- [ ] iOS
- [ ] Android
- Browser
- [ ] Chrome
- [ ] Edge
- [ ] Firefox
- [ ] Safari
- Frontend
- [ ] Jupyter Notebook
- [ ] Jupyter Lab
- [ ] nteract
- [+] Visual Studio Code
- [ ] Visual Studio Code Insiders
- [ ] Visual Studio
- [ ] Other (please specify)
Screenshots
If applicable, add screenshots to help explain your problem.
This is more than likely an issue with how Refit generates code. I suspect it's not accounting for C# Script (where Roslyn source generators aren't supported), but I don't know enough about how it generates code to say for certain.
@jonsequitur but why it works in F# then? I assume that source generators only run at compile time and once dll is created it must be agnostic to it. We are in stupid situation when F# doesn't support Refit because of lack of source generation but F# script can execute refit - referencing dll, while C# script can't execute native dll compiled in C#
but why it works in F# then?
I don't know enough about the source generation implementations in Refit to answer that. Since F# doesn't support source generators, it could be that there's an alternative strategy in the implementation, which if this is the case would probably work for C# Script as well.
I'm guessing -- again, just an educated guess without more information about Refit and I only glanced at the code there for a few minutes -- but I'm guessing that the issue isn't that C# Script can't run the dll so much as that the Refit code doesn't account for the fact that in C# Script, there's no build process in place to trigger source generation. I'm sure this can be fixed but it would have to be fixed in the Refit code, possibly by detecting that C# Script or .NET Interactive is the driver and adjusting the strategy accordingly.