Plans to support VBHTML

Oct 23, 2011 at 3:15 AM

Hey guys,

This project is really great!  Are there any plans to support .vbhtml files in the RazorGenerator Extension?  Or, could I implement that myself easily?  It would be great if I could use C#, but I'm limited to VB.


Oct 23, 2011 at 4:14 AM

We just haven't done that, but it should be possible to make it work, given that Razor supports both. If you have time to make the change in the sources, feel free to send a pull request :)

Oct 25, 2011 at 1:30 AM


After a little effort I've got the VB code generation working for .vbhtml files with the RazorGenerator tool.  I've created a RazorGenerator.Core.Test.VB, which mirrors RazorGenerator.Core.Test, but it is a VB project.  How does the contrib process work? 

I've had a some issues getting the unit tests to work.  It seems like the RazorGenerator.Core.Test project's tests didn't all run with the source I pulled down.

I have a few questions about the source.

Could you explain why there are so many Transformer classes?  I noticed that in several places it was replacing segments of code, or adding statements in C# (I had to incorporate VB in these areas).  Was the MvcCSharpRazorCodeGenerator / MvcCSharpRazorCodeParser not completely adequate?



P.S. Do you know of any functions that would allow us to format the output file to contain the correct spacing and line feeds?

Oct 25, 2011 at 3:19 AM


The contrib process is the standard Codeplex workflow: fork, push your change and send pull request (see Make sure you use the same brace style and spacing as the rest of the code for consistency :)

I'll let Pranav comment on Transformer classes, as he did most of that.

Look at CodeGeneratorOptions to see how the generated spacing/tabs can be affected.


Oct 25, 2011 at 4:38 PM

Mvc is not the only type of precompilation the generator offers - there's a few more. We were using MvcHost, WebPageHost to begin with, but we realized there was just a lot of code being replicated, some of it had unnecessary cruft\incorrect for some forms of output and overall it was a bit hard to follow a common pattern for modifying portions of the generated output whilst using them. The problem with using a custom host and then using transformers made most of this simpler. However, as you noticed, because Mvc has a strong dependency on its host, we had to copy some code over to make it work.

Could you list out the tests you were having trouble running?

Oct 25, 2011 at 10:52 PM

Pranav / David

Thanks for the info!  That gives me some more perspective.  I did see some copied areas (MvcCodeGenerator).

Is the intent to generate code that that will produce identical IL to what Razor templates use in a standard ASP.Net application using Razor?  Or, are custom transformations also supported / included? 

The tests I had trouble with were TemplateWithBaseTypeTest and TemplateTest.  I shelved my changes and re-ran them just to be sure, and those were the two that errored.

I found the code where the CodeGeneratorOptions are used and set a few (IntentString, BlankLinesBetweenMembers, etc.), but the code formatting for these generated.vb files still seems to be off (extra lines, incorrect spacing). 

Any thoughts on a library I could use to format them?  Ideally, I'd like to invoke Visual Studio's FormatDocument on the generated vb file when it completes, but it seems like it may be impossible.  I can get rid of the extra spacing using a Regex replace in a Transformer, but I'd like to avoid writing potentially buggy code to adjust the tabbing and such.



Aug 3, 2012 at 12:32 AM


How is this progressing ? Anything you could share?