Why is razor code in VS19 not highlighting in .cshtml file? - asp.net-mvc

I'm using Visual Studio 2019, v16.11.8 Preview 1.0 to work on MVC projects. At some point my razor code stopped appearing highlighted in .cshtml files, making HTML and C# difficult to tell apart. This is how the code looks now:
I've checked over the color settings for razor code by going to Tools -> Options -> Environment -> Fonts and Colors -> HTML Razor Code Background, but this and the other related settings looked fine. I've also tried restarting VS and the machine itself.
What is the cause of this and how can I fix it?

Found the issue. An experimental Razor editor is enabled by default in the preview. One of the known issues relates to the coloring.
To disable the experimental editor go to Tools > Options > Preview Features and scroll down to uncheck Enable Experimental Razor editor (requires restart). Click Ok and restart your VS.

Related

I can't make any Microsoft Windows Forms in Visual Studio 2019 C#

I'm using Visual Studio Community 2019 and coding in C#. If I create a Windows Forms App either on an existing solution or in a new one, it opens IntelliSense, loads the file and then this error message appears:
*"IntelliSense finished initializing, but an error ocurred when attempting to load the document"*
*"Error code: 0x80131500"*
Most of the tutorials I've found point to solutions with Unity, but I'm not working with it. I've tried restarting the export and import settings, running as administrator, starting the Windows Forms app in a separated solution, on a new one, using NET 5.0 and with NET 3.1, unchecking then rechecking the "Auto list members" and "Parameter information" boxes on Tools > Configuration > Text Editor > All Languages > General menu, then rebooting. But nothing has worked.
I've read that the .csproj file could be corrupted, but I don't know how to check or repair that.
Tools -> Import and Export settings -> Reset all settings -> General. Reset Visual Studio and try again. - Answered by Jonathan Monestel
Referring to \[Microsoft Community\]\[1\] and my own experience, this solution works perfectly:
Uncheck this Item from Tools -> Options -> Environment -> Preview Features -> Uncheck "Load projects faster"
That's all!

Preview the razor design without running the app

I am using Visual Studio 2019 to code Blazor. I find it really annoying that I have to run the app in order to see the screen design. Does anyone know if there's a WYSIWYG tool or feature, so that I can look at the screen design w/o running the app? Thanks!
So since there's known, I have been doing this way...and so far my productivity is higher than running the app. Since I am constructing smaller Razor components, I have been constructing the styling on Codeply and move the styling back to VS once it's confirmed working. Pretty similar to what Quango has suggested. Still wishing there's a WYSIWYG feature from VS.

Can I include the default editor inside a webview in VSCode?

In my project I created a Webview extension for Visual Studio Code. Inside the Webview I have a text editor (currently monaco editor) and a graphical Modeler.
Now I wondered if there is any way to replace the monaco editor inside my Webview with the standard editor of Visual Studio Code. This would be extremely helpful because I would not have to worry about connecting the custom text Editor to my LSP Extensions and also have 100% the same functionalities as in the rest of Visual Studio Code.
Do You know of any way in which I could achieve this goal?
Best Regards
Thomas
The feature request you are looking forward is https://github.com/microsoft/vscode/issues/93265
It is being implemented
In VS Code Help > Interactive Playground you can have an idea of what it will look like, even if it is not exposed through the API yet.
Meanwhile, vscode-python configures the Monaco Editor to look as much as possible to the native text editor.

Can ReSharper always jump to view's .cshtml in ASP.NET MVC project instead of asking me?

I'm talking about this menu, which appears when I press Ctrl+B:
In 99.99% I want to see a .cshtml, could it be made a default option (so that resharper would open the file without asking)?
I don't know if it comes with Visual Studio or ReSharper but there is a shortcut named Go to View.
CtrlM + CtrlG
Maybe not the answer you are looking for but it's quite useful.
So, the answer is: there is no such feature in ReSharper yet (I posted an issue and they added it to 8.1 backlog).

How to step into MVC4 source code without building assembly

Is there an easy way to step through the MVC 4 source from within my solution?
I found this question but the solution requires building the MVC 4 assembly from source. I would think a symbol look up from a server would be preferable but have not been able to make this happen.
Ideas?
Add the following symbol servers to your Visual Studio and you are good to go:
http://referencesource.microsoft.com/symbols
http://srv.symbolsource.org/pdb/Public
http://srv.symbolsource.org/pdb/MyGet
http://msdl.microsoft.com/download/symbols
Here's how mine look like:
Also you need to configure your debugger to use them:
Tools -> Options -> Debugger -> General.
Uncheck "Enable Just My Code (Managed only)"
Check "Enable .NET Framework source stepping"
Check "Enable source server support"
Uncheck "Require source files to exactly match the original version"
Oh and of course don't forget to revert those settings back when you no longer need to debug in .NET sources or otherwise debugging might become a painfully slow experience for you.

Resources