Is it even possible to return bespoke functions from a method within .net2?
Absolutely, but you need to return a specific delegate type.
The simplest thing is probably to declare your own generic delegates, e.g.
public delegate TResult ProjectFunc<T, TResult>(T arg)
And then:
public ProjectFunc<object, object> FunctionBuilder(object o)
Then if/when your project moves to .NET 3.5, you can just remove ProjectFunc
and use Func
instead. We've taken this exact approach in Noda Time (which actually now uses .NET 3.5 anyway) and it's worked fine.