问题
I recently upgraded to using ReSharper 5 (currently in beta). I noticed that in ASP.Net MVC projects, ReSharper underlines in red all of the return statements inside a controller:
I personally find this pretty annoying because it looks like an error. Clicking on the underlined text doesn't offer any help (ie, a lightbulb). I don't see an option to change the styling of this text in Environment -> Fonts and Colors
, and so far it looks like the only way to disable it is to un-check the "Enable ASP.Net MVC References" in the ASP.Net -> Other
Re-Sharper options.
What's the point of this highlighting? Am I missing out on something special that ReSharper is offering me? Is there a way to remove the highlighting while still enabling MVC support in ReSharper?
回答1:
It's not red - it's brown. It matches color of string literals in standard VS color scheme.
To change it's color:
- Install ReSharper 6+
- Within Visual Studio navigate to
Tools
→Options
→Environment
→Fonts & Colors
- Scroll down to
ReSharper ASP.NET MVC *
and change theItem foreground
color (andItem background
if you'd like) to whatever color suits you best. In your specific case you'll want to change theItem foreground
ofReSharper ASP.NET MVC View
.
If at the third step you can't find the ReSharper items you should reset the Fonts & Colors
cache manually by deleting the HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\9.0\FontAndColors\Cache
key in the registry (You may have to delete the key located in ...\10.0\...
, too.)
回答2:
Resharper smartly identifies the real view/controller/actionmethod your referencing by magic string. Do a Find Usagages and you'll see you can navigate to the view or controller.
回答3:
The underline is used for two purposes:
- To indicate that the View/User control exists.
- You can navigate to it directly by clicking on it with the mouse button and hitting the Ctrl key (or F12 in VS Scheme Binding).
The idea here is to make you aware of missing views. It's only red (the text itself) when a View is missing and hitting Alt plus Enter, you'll get the Create from Usage possibility.
来源:https://stackoverflow.com/questions/2421701/whats-the-point-of-the-red-underline-highlighting-in-resharper-5-for-asp-net-mv