I am creating my type in FSX and passing those types into the Razor templating engine with the open source RazorEngine project.
Hosting Razor outside of ASP.NET requires compiling the Razor templates. If I pass a model created in FSX into the template, will System.CodeDom be able to have access to that type created by FSI? The basic error that I get is “The type or namespace name ‘FSI_0004’ could not be found”.
Code that’s compiled using
System.CodeDomcannot generally have access to the code loaded in F# Interactive – the CodeDom essentially writes the C#/F# source code to disk and then invokes the command line compiler on the code (and the command line compiler cannot reference code loaded in F# Interactive).There may be a way to get it working though – You could use the F# CodeDom provider from PowerPack. You could modify it to generate the source code (as it currently does) and then send the generated code to F# Interactive (instead of invoking command line compiler). This way, the code compiled on-the-fly could see F# Interactive code.
There are some issues that need to be resolved
These all depend on your scenario – but I guess that it may be possible to get what you want (possibly with some workarounds).