MVC Inspection cannot resolve views / partial views / actions / controllers etc.
It seems like R# cannot resolve any MVC locations within my project, flagging any references as errors (e.g. cannot resolve view 'viewname' etc.)
I am using R# 2017.3.1 on VS 2015.
I have an MVC subfolder within my project, with Controllers / Models / Views Subfolders.
I'm also using MvcCodeRouting - not sure if that could impact.
It seems like R# doesn't know where to look for any MVC assets... is there something I need to do to tell it "MVC" is in this folder "Controllers are in this folder" etc...?
Thanks for your help.
Dan.
Please sign in to leave a comment.
Ok... just a bit more info...
Within my controller 'APPRootNamespace.MVC.Controllers.Personal.TimesheetController' I have an ActionResult method that returns:
'return View("TimesheetBase", model);'
The TimeSheetBase view is within 'APPRootNamespace.MVC.Views.Personal.Timesheet'
When I tell R# to 'Create Razor View' it gets placed within 'APPRootNamespace.MVC.Views.Timesheet'
This seems to me that R# MVC Inspection is not compatible with MvcCodeRouting based on Namespaces...
Can anyone confirm this - is there a workaround, or am I best just disabling ASP.NET MVC inspection for now?
Hello Dan!
Sorry for delay in responding.
ReSharper doesn't work with routing in general as it's a static code analyzer, it cannot run the code.
As a workaround you may try JetBrains.Annotations and adding AspMvcViewLocation, AspMvcPartialViewLocation attributes to your code.
Thank you.
Thanks for your response.
Are you able to point me to anywhere documenting with examples how I would do this to solve this particular issue - a quick search for AspMvcPartialViewLocation attribute did not pull anything up...
Hello Dan!
Then, you need to add some of these assembly level attributes (usually in your AssemblyInfo.cs, but it can be anywhere):
You can add more than one of each type, and you'd use them like this:
And so on, for views, partial views, masters and for when you're in an area. The replacement values are:
ReSharper will use these path format strings to look for the different views.