Thanks for Quora + Reflector + MSDN, I’ve figured out how to expose extension methods from F#
- Create a public module within a namespace
- Add the extension method as a function
- Decorate both the module and the function(s) with the ExtensionMethodAttribute
namespace Castle.MonoRail [<System.Runtime.CompilerServices.ExtensionAttribute>] module public ExtensionMethods = open Castle.MonoRail.Routing open Castle.MonoRail.Hosting.Mvc [<System.Runtime.CompilerServices.ExtensionAttribute>] let Match(router:Router, path:string) = router.Match(path, MonoRailHandlerMediator())
Mauricio Scheffer says:
Excellent, I just had to write some extension methods and used this as reference. The only downside to this is that it doesn’t support overloads. But if you use a type instead of a module and static members instead of let bindings, you can have overloaded extensions.
July 26, 2011, 8:10 amhammett says:
I’ve used [CompiledName] to support overloads..
July 26, 2011, 2:50 pm