Lack of intellisense for strongly typed model in razor mode

Ok, since for a couple of weeks I lost the intellisense on the model in my views.

I'm pretty sure this is not a problem with the code, because it works for another developer on the same project.

Suppose this class:

namespace Project.UI.ViewModels
{
   public class TestViewModel
   {
      public int PropertyA { get; set; }

      public string PropertyB { get; set; }
   }
}

      

And this look:

@model Project.UI.ViewModels.TestViewModel

<div>
   @Model.PropertyA
</div>

      

When I type @Model.

in my mind I expect intellisense to show me PropertyA

and PropertyB

. Nothing happens.

However, if I type @Html.

, I have a list of methods for the HtmlHelper.

If I type @Model.Foo

, resharper prompts me to create a property Foo

on TestViewModel

.

I'm guessing there is some kind of Visual Studio module not working as expected to handle intellisense in razor views, but I can't see what.

I am working with Visual Studio 2013 , MVC5 , Resharper 8.2 .

Edit

I've had this behavior since two months. So I closed and reopened the project, closed and reopened Visual Studio, and have since rebooted my computer.

I wasn't worried about it because I didn't do a lot of UI ...

I'm not sure, but I think it is because I installed VS2013. I'm pretty sure it worked with VS2012.

+3


source to share


4 answers


I ran into this issue before and the "Inconsistent line endings" was fixed in the solution.



Copying pasting pieces of code from other sources can lead to this, and if Visual doesn't indicate it, the best solution is probably to retype the contents of the file in a new file.

+1


source


The same bug is present in VS2017 as well. Removing the component cache seems to help. Close Visual Studio, go to folder

C: \ Users \ your.name.here \ AppData \ Local \ Microsoft \ VisualStudio \ version.goes.here \ ComponentModelCache



and delete the files in that folder. After that restart VS and it will also ask you to fix the "inconsistent line endings" as per @ Grzesiek's answer, and the component model files are recreated when VS is restarted. After that, everything should work again.

+1


source


go to tools and then change intellisense settings in your desired laguage options in text editor option

0


source


There is a bug in VS 2015 as well. When you make drastic changes to the model, Razor intellisense can still remember the old model.

@model MyForm.Models.SomeModelIChangedAround

      

Restarting VS 2015 fixes it.

0


source







All Articles