I'm having a problem with the class and namespace names that are generated by RazorGenorator.MSBuild
With a razor file like this:
Namespace = Views.Accounts.Mobile
Class name = Index
Note that classical razor processing uses different choices:
Namespace = ASP
Class name = _Views_Accounts_Mobile__Index_cshtml
Is there any way run razorgenerator so that it names classes and namespaces the same way that
happens under MVC?
The difference I mention above causes trouble because of a nuance of
how C# handles namespaces. Specifically (TL;DR warning!!!) :
This line of C# code:
Var x = new Accounts.Auditor();
has the compiler looking for a class "Accounts.Auditor".
This class does in fact exist somewhere, at "global::Accounts.Auditor".
But, early in the search for Accounts.Auditor, the C# compiler finds "Views.Accounts".
Auditor does not exist in Views.Accounts, so one might think that C# would continue its
search and eventually find global::Accounts.Auditor".
That does not happen. What C# actually does is something like "I have
found 'Accounts', there is no Auditor here, so FAIL-AND-EXIT."
So, the compile fails.
There are several one-off ways I can solve this, but I'm porting about 1000 razor files
to use RazorGenerator.MSbuild. More than 100 of them have this problem, and it
would be expensive to edit and test my changes, or created dozens of razorgenerator.directives.