R# “cannot resolve view” when changing the default location for views + custom ViewEngine for ASP.net MVC2

We have a project in ASP.net MVC2 were we have our own ViewEngine that overrides were views locations are and a few other things. Problem is that Resharper 5.1 is not picking up this, as expected. Is there anyone who knows of a way to extend R# to pick this up?
I don't want to disable R# to not try to resolve view globally or local with the R# comment. I want to full tooling support.

17 comments
Comment actions Permalink

Sorry, but ReSharper supports only default layout.
No plans, currently, to extend this support to custom layouts.

0
Comment actions Permalink

Thats too bad.
Do you know if the Spark engine has a solution for this?

It just feels very wrong to not get tooling support if one decides to not go with the Microsoft convention.

0
Comment actions Permalink

I agree with Einar. This bug causes us lots of false positives when using R# to check for solution errors.

I don't see why R# couldn't look for the view locations specified in ViewEngines added to the application. This functionality would be very helpful. I hope you change your mind about adding this support :)

0
Comment actions Permalink

Or even just make the view locations configurable per project in any way without it having to scan the code for it. I'd be happy to set that setting once.

0
Comment actions Permalink

I'd second that.  Was quite surprised that this is not supported as it is hardly an edge case.  I cannot imagine many projects can keep things managed with just the default locations.

It seems a strange stance that they would not support it, would see this as a bug within R#.  At least I'd put my vote if it were a feature request.  

Long time user.

0
Comment actions Permalink

I have to agree with everyone else. This is going to be a required feature.  If ReSharper gives us lots of false positives, then we lose a lot of benefit of using it.  If I manually have to filter out these kind of errors, it's going to create friction.  Removing friction is exactly what we use ReSharper for!

+1 vote as a feature.

0
Comment actions Permalink

Please reconsider, and fix this "cannot resolve view" bug (or add a new feature), at least for ReSharper 6, this is annoying us here as well.

Thanks,
Tormod

0
Comment actions Permalink

+1

I would second the reconsideration of this request as most of the web apps I work on with MVC and R# are using custom view engines and I'd like to use solution analysis more often.

Paul Shannon

0
Comment actions Permalink

Fo not supported, custom ViewEngines,  you can always diable ASP.NET MVC analysis, and use rest solution anadlyses without problems.

0
Comment actions Permalink

Thanks for your feedback.
There's a feature request at http://youtrack.jetbrains.net/issue/RSRP-190961 and you're welcome to vote for it. While we can't commit to implementing it very soon, we'd like to know how many users want this functionality



Kirill Falk
.NET Team QA Lead
twitter : masterqa
JetBrains, Inc
http://www.jetbrains.com
"Develop with pleasure!"
0
Comment actions Permalink

Hello,

That ticket (RSRP-190961: Support non-default ASP.NET MVC folder locations) is marked as fixed in 6.0. We're running 6.0 Full Edition (6.0.2202.688) with views in their own assembly separate from the web project; how do we configure ReSharper to recognize the custom view locations?

Jesse

0
Comment actions Permalink

On 30.06.2011 20:24, Jesse Plamondon-Willard wrote:

That ticket (http://youtrack.jetbrains.net/issue/RSRP-190961: Support non-default ASP.NET MVC folder locations) is marked as fixed in 6.0. We're running 6.0 Full Edition (6.0.2202.688) with views in their own assembly separate from the web project; how do we configure ReSharper to recognize the custom view locations?


Do you alter default view location by assigning of VirtualPathProviderViewEngine.ViewLocationFormats property?
Is it done in the same solution?

0
Comment actions Permalink

Yes, we override the view engines with a configured

RazorViewEngine
like this:
protected void Application_Start()
{
     // [...]
     this.RegisterViewEngine(
          "~/Views/Pages/{1}/{0}.cshtml",
          "~/Views/Pages/{0}.cshtml",
          "~/Views/Partial/{0}.cshtml"
     );
     // [...]
}
/// <summary>Register the view engine used to render MVC views.</summary>
private void RegisterViewEngine(params string[] pathFormats)
{
     ViewEngines.Engines.Clear();
     ViewEngines.Engines.Add(new RazorViewEngine
     {
          PartialViewLocationFormats = pathFormats,
          ViewLocationFormats = pathFormats
     });
}


We have our views in

Web.Views
, which are copied to
~/Views
in the
Web
project by an MSBuild task before compilation. This allows us to enforce segregation during development without reflecting on a compiled assembly at runtime. Unfortunately, this means the files are not part of the
Web
project before compilation, so they're not available to ReSharper at the location known to the
RazorViewEngine
.

Can ReSharper be configured to look for the views in the
Web.Views
assembly?
0
Comment actions Permalink

Currently, ReSharper can detect altering of default view locations only by direct assigning of ViewLocationFormats/ViewLocationFormats. So, if you inline your RegisterViewEngine method it may help.

0
Comment actions Permalink

Unfortunately, that had no effect.


The cause may be that the views are not included in the

Web
project file —
~/Views
is copied from the
Web.Views
project into
Web
just before compilation by an MSBuild task. The files exist at the location, but they're not included in the project file. For example, ReSharper also flags a full path:
ReSharper 6.0 fails on direct reference to copied view.png
0
Comment actions Permalink

We merged

Web.Views
back into
Web
for now, until we have time to reexamine that approach.

Thanks for the help, much appreciated.
0

Please sign in to leave a comment.