Why did the namespace for view files chage?

Jan 30, 2015 at 1:47 AM
I just upgraded from 1.6.4 to 1.7.0 and noticed that now RazorGenerator is using a different namespace for the generated files. Previously it would generate the files using the namespace of when there file lived, like this:
namespace Merchant.Website.Views.Shared
    public partial class Layout : IocWebViewPage<dynamic>
while now it looks like this:
namespace ASP
    public partial class _Views_Shared__Layout_cshtml : IocWebViewPage<dynamic>
Jan 30, 2015 at 2:02 AM
It looks like that came from this commit, to fix this issue.

It says:

To switch back to the shortened names we used to generate, you'll need to use a directive.
@* GeneratePrettyNames : true *@
Jan 30, 2015 at 3:10 AM
Do we need to update the MVC library to use these new files, or will the existing code still work?
Jan 30, 2015 at 3:18 AM
Existing code should work with the file format we generate. In fact these names match the format Mvc generates view files with.
Jan 30, 2015 at 3:46 AM
Awesome, thanks!
Jan 30, 2015 at 5:46 PM
I've just updated to 1.7.0 either, and have the same problem. I'm using Template generator, and when I add GeneratePrettyNames directive, nothing is changed:
@* Generator: Template TypeVisibility: Internal *@
@* GeneratePrettyNames : true *@
@inherits RazorPage 
Here is the generated code:
namespace ASP
    [System.CodeDom.Compiler.GeneratedCodeAttribute("RazorGenerator", "")]
    internal partial class _Batches_Dashboard_BatchDetailsPage_cshtml : RazorPage 
Jan 30, 2015 at 7:20 PM
Try it all on one line, e.g.
@* Generator: Template GeneratePrettyNames : true *@
Feb 2, 2015 at 1:11 PM
Yep, it works. Thank you a lot, David!
Feb 4, 2015 at 8:59 PM
I had the same problem in which namespaces changed on me. The change broke my unit tests' compilation, among other things.

In addition, the underscore behavior seems to have changed somewhere along the way. I'm unsure if this changed in the most recent update or a previous one. Some of my views were named with underscores (like "_History"), but the new version does not preserve the underscore. I buckled and just removed all underscores from my view names. This meant I had to go hunt down those runtime path calculations (such as Url.Action).

I don't intend to be needlessly critical (this technology is a godsend), but I hope future updates cause less impact. I had to update every view with the "@* GeneratePrettyNames : true *@" directive, and update nearly every page to remove underscores out of relevant links. That cost me about an hour, and comes with dangers of some runtime surprises. In addition, I don't know if there is a way to use an old version of an extension, so as far as I can tell, I was essentially forced to solve this problem. But still, I reiterate that I give Razor Generator three or four thumbs up!
Feb 4, 2015 at 9:39 PM
I agree, this was too breaking a change, and it was probably ill advised. :(

FWIW, there is another flag for the underscore, so if you try @* GeneratePrettyNames : true TrimLeadingUnderscores : true *@, you get back to the previous behavior. And note that you don't need to change every file if you use a razorgenerator.directives file. See https://razorgenerator.codeplex.com/ for details.
Feb 5, 2015 at 10:03 PM
Edited Feb 5, 2015 at 10:04 PM
This is broken, how to I get version 1.6.4? I don't see anything on the downloads page.
Feb 5, 2015 at 11:22 PM
@jonfaust: reading the thread might actually help ;)