MvcHelper Directive produces uncompilable code
See original GitHub issueThere is a test template with Generator: MvcHelper
directive is this repository:
https://github.com/RazorGenerator/RazorGenerator/blob/master/RazorGenerator.Core.Test/TestFiles/Input/MvcHelperTest.cshtml
There also is a generated file from this template with RazorGenerator v1
here:
https://github.com/RazorGenerator/RazorGenerator/blob/master/RazorGenerator.Core.Test/TestFiles/Output_v1/MvcHelperTest.txt
We can see that in this file we have a static class with a static extension method, which is compilable and fine.
But in a generated file for RazorGenerator v2
or v3
we have nonstatic file with a static extension method:
https://github.com/RazorGenerator/RazorGenerator/blob/master/RazorGenerator.Core.Test/TestFiles/Output_v2/MvcHelperTest.txt#L37
Unfourtunatedly this code can’t be compiled in C#:
Error CS1106: Extension method must be defined in a non-generic static class
Static changed to nonstatic in v2
via this commit: https://github.com/RazorGenerator/RazorGenerator/commit/7052aaae4b580d0e5518a3fe1b85423d2448f094#diff-97f8c72576b159fc6053d5bfc84f6d9e
Can you fix it somehow? I can’t regenerate some files in my solution anymore with this new version of RazorGenerator 😦
Issue Analytics
- State:
- Created 5 years ago
- Comments:7 (4 by maintainers)
Top GitHub Comments
@timramone, I’m actively involved in maintaining this project after being added to the project team by @pranavkm a few weeks ago, and I’m currently working through other issues with RazorGenerator at present but I’ll take a look at this when I get a chance.
I note that ASP.NET Core dropped support for
@helper
syntax in Razor pages, so your question might be moot if you’re targeting the latest version of ASP.NET (not to say this isn’t a bug, of course).Unfortunately the breaking change was in MVC 4. All that RazorGenerator (primarily) does is provide a way to use MVC’s runtime capabilities at build time.