Basically, what you're asking for is to execute some code that creates the interface at compile time.
Your options are:
- Use something like T4. You can use that to generate C# code based on some input at compile time.
- Use F# type providers. That's basically exactly what you want: it can execute code at compile time and generate the interface right when you write the code that calls
GetProxyFor()
. But there is nothing like that in C#, so it would require you to switch to F# (at least for the part of your code that usesGetProxyFor()
). - Think about the underlying problem behind this question (which you didn't tell us) and solve it in another way.