I was recently working on CodeProvider for the F# language, which is a class that generates source code from given CodeDom code representation. I wanted to implement it, because ASP.NET 2.0 uses CodeDom to generate source (from ASPX files) that is together with manually written F# code behind files compiled into web application binaries. This means that with F# CodeProvider you can write ENTIRE web application in F# (including in-line code enclosed in <% ... source code ... %>).
I posted this to the internal discussion first, to get some feedback before I make it public. Also, thanks to everybody who helped me by answering my questions in the F# mailing list.
The code generator is currently very limited (see release notes in the download links), and I tested it only with ASP.NET (I think it currently works quite reasonable with ASP.NET). So if you find something that doesn't work (with ASP.NET) or if you know about any other good usage for CodeGenerator, please let me know! I'm going on holidays for the next week 8-), so I'll answer all the questions and suggestions later.CodeProvider & CodeCompiler
The CodeDom project contains two classes - CodeGenerator that generates F# source code from CodeDom and the CodeCompiler that executes "fsc.exe". To make this work you need to have path to "fsc.exe" in the system PATH variable (alternatively you can modify the path in "codecompiler.fs").ASP.NET 2.0 compilation in F#
I also created template project for Visual Studio, so it is possible create F# web sites really easilly. Just download and install the VSI template and than you can create new project in VS using File
-> Web Site
, select the Visual C#
language (I don't know how to create option for F# language) and then select the "F# WebSite
" template :-).
(It will only work if you add path to F# compiler (fsc.exe) to your environment PATH variable, because the CodeDom compiler doesn't know where you installed F#)Downloads