Quantcast
Channel: RazorGenerator Issue Tracker Rss Feed
Viewing all articles
Browse latest Browse all 525

Commented Issue: EditorTemplates and DisplayTemplates are broken due to namespace mangling [133]

$
0
0
As addressed in the following discussions
* https://razorgenerator.codeplex.com/discussions/471355
* https://razorgenerator.codeplex.com/discussions/278608

RazorGenerator runs into issues with EditorTemplates and DisplayTemplates where users end up having to fully qualify types in the template files for it to work correctly. The problem is with the way RazorGenerator differs in the generation of names compared to the Asp.Net build provider.

For a file named at ~\Views\Shared\Boolean.cshtml, the build provider generates file names of the format
namespace ASP {
_Page_Views_Shared_Boolean_cshtml : WebViewPage<Boolean?>

}

versus RazorGenerator's output looks like
namespace Views.Shared
{
public class Boolean : WebViewPage<Boolean?>
}

which results in the cs compiler incorrectly inferring the templated Boolean type.


Comments: Sorry, I'm a bit confused. I thought I could use *either* the VSIX or the nuget. Is that right? Presumably if I use nuget I don't need VSIX. It certainly seems to be generating cs files for my views, and once I include the CodeGen folder in my project it's attempting to compile them. But I've still got the same problem with templates not compiling because it is assuming class names refer to compiled views with the same name. For instance, one error is: "'Paladin3.WebUI.Views.Shared.EditorTemplates.DateTime' does not contain a definition for 'Day' and no extension method 'Day' accepting a first argument of type 'Paladin3.WebUI.Views.Shared.EditorTemplates.DateTime' could be found (are you missing a using directive or an assembly reference?)" That view has been compiled with this signature: public partial class Date : Paladin3.WebUI.Infrastructure.PaladinWebViewPage<DateTime> when it should be: public partial class Date : Paladin3.WebUI.Infrastructure.PaladinWebViewPage<System.DateTime> (I have a DateTime template) I am still able to fix it by fully qualifying the model type in the view, but "System" is in the list of namespaces, so Resharper is actually prompting me to remove "System." from the model type. To confirm, this is using RazorGenerator.Mvc from nuget, version 2.2.1 Actually, I've run into a similar error that I can't resolve as easily. I have a partial called _UsersChooseFilterButton, and a class called UsersChooseFilterButton. A separate partial, _UsersChooseSelectionPanel, calls Html.Partial on _UsersChooseFilterButton with a new model of UsersChooseFilterButton and 5 parameters. But I'm getting compiled errors that my compiled view doesn't have a constructor that takes 5 parameters, because it's defaulting to the compiled view as the class instead.

Viewing all articles
Browse latest Browse all 525

Trending Articles