Feb 4, 2014 at 10:45 PM
Edited Feb 4, 2014 at 10:48 PM
Let me start by saying this is an amazing project which allows my codebase to be much cleaner by separating appropriate views into different assemblies. Great job!
I've come across the following problem quite a bit because we have a large codebase with many namespaces. I have a class in my project in the following namespace, like so:
public class Helper
Consider the following code in a Razor page inside a Views folder that includes this namespace:
And the generated file looks like this:
#line 2 "..\..\Views\WebPage1.cshtml"
using Views.MyHelpers; // this line errors, it can't find Views.MyHelpers
This causes a compiler error because the using statement is inside the namespace, and as such it is actually looking in Scratch3.Views.MyHelpers, which doesn't exist and the compiler errors out.
An article about how "using" statements are treated when inside namespaces:
Moving the using statement outside the namespace makes it compile, but of course now I'm hand modifying a generated file. You can easily reproduce this with one view and one helper class in an MVC project, with the appropriate namespaces.
Can the generator put the usings outside the namespace? How can we fix this behavior? Thanks!