I tested this with the default out of the box implementation and GetViewPage retrieves the view from the file system without a problem.
I swapped out the RazorFormat's VirtualFileSource for the inmemory one:
Plugins.Add(new RazorFormat() {
VirtualFileSources = new InMemoryVirtualPathProvider(this),
});
In the service I'm writing a view if it doesn't exist:
var helloView = razor.GetViewPage(email.BlastId.ToString());
if (helloView==null)
{
((InMemoryVirtualPathProvider)razor.VirtualFileSources)
.WriteFile("~/views/"+email.BlastId + ".cshtml", email.Blast);
// .WriteFile(email.BlastId + ".cshtml", email.Blast); doesn't work
}
helloView = razor.GetViewPage(email.BlastId.ToString());
//helloView is always null
I've confirmed that the RazorFormat's VirtualFileSource has the file, the GetViewPage just doesn't retrieve it.
Screenshot of the file located in the VirtualFileSource: https://db.tt/8oirKd9Msi
Furthermore this returns true: razor.VirtualFileSources.FileExists("~/views/"+email.BlastId + ".cshtml")
I've tried it without the views folder/etc. It doesn't seem to make an impact.