If you want to enforce things, use an interface. If you want to accept anything that fits use a delegate.
I'm not sure I understand your use case where you need to conflate the two. You want to enforce the contract but with arbitrary method names?
I suppose you could wire up something like this but it's a bit convoluted.
interface IFoo {
string F(String s);
}
class Bar {
public string B(String s){
return "";
}
}
// internal class, perhaps in your test framework
class BarContract : Bar, IFoo {
public string F(string s) => B(s);
}
I'm not sure I understand your use case where you need to conflate the two. You want to enforce the contract but with arbitrary method names?
I suppose you could wire up something like this but it's a bit convoluted.