Resharper 6 - Code analysis for Razor does not work properly

It appears that the Resharper engine for code analysis is not aware of the Razor syntax.  Many things inside of a Razor block are improperly flagged as warnings.  For example a Razor block such as:

@Html.TextBoxFor(model => model.FarmCatalogName, new Dictionary<string, object> { { "data-bind", "value: FarmCatalogName" } })


In this block, Resharper will highlight "string" (in the generic type definition) as a warning, with the warning message:

"Validation (XTHML5): Element 'string' is not supported."

It is apparently validating against XHTML rather than C# rules.
8 comments
Comment actions Permalink

I agree with you that this is bad, but I'm interested in knowing more about this crazy witchcraft 'data-bind' stuff you have going on, is this an MVC functionality thing?  Or something you have invented, what does it do? ;)

0
Comment actions Permalink

On 07.07.2011 18:25, Tom Kludy wrote:

@Html.TextBoxFor(model =>  model.FarmCatalogName, new Dictionary<string, object>  { { "data-bind", "value: FarmCatalogName" } })


Tom, I can't repeat your issue. Can you send full page's souces? Also, _ViewStart.cshtml, if exists.

0
Comment actions Permalink

Hello Tom,

Could you please attach a small sample solution demonstrating this problem?
Thank you!

Andrey Serebryansky
Senior Support Engineer
JetBrains, Inc
http://www.jetbrains.com
"Develop with pleasure!"

It appears that the Resharper engine for code analysis is not aware of
the Razor syntax.  Many things inside of a Razor block are improperly
flagged as warnings.  For example a Razor block such as:

@Html.TextBoxFor(model => model.FarmCatalogName, new
Dictionary<string, object> { { "data-bind", "value: FarmCatalogName" }
})

In this block, Resharper will highlight "string" (in the generic type
definition) as a warning, with the warning message:

"Validation (XTHML5): Element 'string' is not supported."

It is apparently validating against XHTML rather than C# rules.

---
Original message URL:
http://devnet.jetbrains.net/message/5308629#5308629



0
Comment actions Permalink

I have project deadlines and cannot wait for Resharper 6 to be ready for real world use.  I uninstalled it.  Unfortunately it left my system broken >:(

Now, even though I have no Resharper installed, the Visual Studio editor refuses to recognize Razor syntax at all.  No syntax highlighting, no intellisense... nothing.  Now I must take a day to reinstall Visual Studio in an attempt to fix this.  Whatever Resharper did to my system appears to have broken Visual Studio itself.

As for demonstrating the problem, just create a view using Razor, then type.  I expect to hit "@" and be presented with Intellisense... nothing.  I type "@Html." and get no intellisense.  I hit Alt+Space... I get the html intellisense, not the C# intellisense.  I type anything inside of < > signs (a generic type) but within a Razor block.. the editor treats it as invalid HTML.

When I actually run the project, it works fine.  The Razor engine itself is working fine, but the editor is not working.  It is as if Resharper has broken VS's handling of .cshtml files and the editor is now treating them as .htm files.

0
Comment actions Permalink

The data-bind syntax is for knockout.js, which allows you to define a ViewModel on your client side and data-bind the properties to your view controls.  Check out knockoutjs.com

The generic syntax is required to attach the html property to the auto-generated ASP.NET control.

0
Comment actions Permalink

I cannot send the source as it is proprietary and is related to an as-yet-unreleased product.

0
Comment actions Permalink

Hello Tom,

We're sorry for the problems that you've experienced with ReSharper. We've
never seen such behavior before, so it would be great to find the root of
this problem. Could you please check if this also happens in a newly created
MVC 3 project? This would help us to find out if the problem is specific
to your solution. Thank you!

Andrey Serebryansky
Senior Support Engineer
JetBrains, Inc
http://www.jetbrains.com
"Develop with pleasure!"

I have project deadlines and cannot wait for Resharper 6 to be ready
for real world use.  I uninstalled it.  Unfortunately it left my
system broken >:(

Now, even though I have no Resharper installed, the Visual Studio
editor refuses to recognize Razor syntax at all.  No syntax
highlighting, no intellisense... nothing.  Now I must take a day to
reinstall Visual Studio in an attempt to fix this.  Whatever Resharper
did to my system appears to have broken Visual Studio itself.

As for demonstrating the problem, just create a view using Razor, then
type.  I expect to hit "@" and be presented with Intellisense...
nothing.  I type "@Html." and get no intellisense.  I hit Alt+Space...
I get the html intellisense, not the C# intellisense.  I type anything
inside of < > signs (a generic type) but within a Razor block.. the
editor treats it as invalid HTML.

When I actually run the project, it works fine.  The Razor engine
itself is working fine, but the editor is not working.  It is as if
Resharper has broken VS's handling of .cshtml files and the editor is
now treating them as .htm files.

---
Original message URL:
http://devnet.jetbrains.net/message/5308863#5308863



0
Comment actions Permalink

Another person on my team experienced the same issue as I did, also apparently due to installing Resharper 6.  However, after two days debugging the issue together and trying multiple machines, we finally found the culprit.  It is not related to Resharper.  It was coincidental that a change was made to a project file in source control at the same time that both of us upgraded to Resharper 6.  This change seemed innocent but breaks MVC support in Visual Studio, with or without Resharper installed.

The change that broke MVC switched the OutputPath from "bin" to "bin2\$(Configuration)".  The change was made because otherwise building both Debug and Release caused one configuration to overwrite the other one, and ASP.NET uses the "bin" path for its own purposes.  After experimentation we found that MVC breaks any time the OutputPath is more than one directory deep, and the top level directory is not "bin".  So "bin$(Configuration)" works, "bin\$(Configuration)" works, even "foo" works.  But "foo\bin" does not work because it is two levels deep and the top level is not "bin".

I apologize for assigning the blame for this issue to Resharper.  The cause was obscure and the timing was pure coincidence.  I am now using Resharper 6 again and hopefully will not experience any more strange issues!

0

Please sign in to leave a comment.