mtrutledge / generator-dnn

Yeoman generator to scaffold DNN / DotNetNuke Modules and Themes.
MIT License
17 stars 10 forks source link

Intellisense errors in views of newly generated module #45

Closed sholman closed 5 years ago

sholman commented 5 years ago

Describe the bug

Newly created projects show intellisense errors in views due to missing DotNetNuke.Web.Client reference and missing model declaration

To Reproduce

Steps to reproduce the behavior:

  1. Create new module using yo dnn
  2. Open project and browse to Views, Home. Index.html
  3. You will see red intellisense squiglies under a number of areas including the using statements, ViewBag, and @Dnn

Expected behavior

A new project should not show intellisense warnings

Screenshots

2018-07-28 13_39_51-expeed dnnmodules - microsoft visual studio

Errors

See Screnshot

Additional context

This can be resolved by adding DotNetNuke.Web.Client to the initial package list to be loaded as references and adding a blank Model declaration such as @inherits DotNetNuke.Web.Mvc.Framework.DnnWebViewPage as the DNNHelpers like @Dnn. and @Url. load from DotNetNuke.Web.Mvc.Framework.DnnWebViewPage

*Note: The blank model declaration of type string may cause other issues if you try to render a named view from the controller as it see's the view name as the model, so this may not be the most bulletproof resolution.

sholman commented 5 years ago

Adding this reference only solves part of the issue, as the intellisense on the @Dnn and @Url functions doesn't work without a model inheriting from DotNetNuke.Web.Mvc.Framework.DnnWebViewPage

SkyeHoefling commented 5 years ago

Every view should have the following command:

@inherits DotNetNuke.Web.Mvc.Framework.DnnWebViewPage

or

@inherits DotNetNuke.Web.Mvc.Framework.DnnWebViewPage<Model>

If it doesn't and it is part of the template either create an issue or create and issue and submit a PR. We are trying to fix them as we see them but there could be views missing the declaration in the template