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
| 01 | |
| 02 | namespace Castle.MonoRail |
| 03 | |
| 04 | [<System.Runtime.CompilerServices.ExtensionAttribute>] |
| 05 | module public ExtensionMethods = |
| 06 | |
| 07 | open Castle.MonoRail.Routing |
| 08 | open Castle.MonoRail.Hosting.Mvc |
| 09 | |
| 10 | [<System.Runtime.CompilerServices.ExtensionAttribute>] |
| 11 | let Match(router:Router, path:string) = |
| 12 | router.Match(path, MonoRailHandlerMediator()) |
| 13 | |
July 26th, 2011 at 8:10 am
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 26th, 2011 at 2:50 pm
I’ve used [CompiledName] to support overloads..