Razor visual studio IntelliSense not working for dynamic objects
Hi everyone,
I had some trouble with my visual studio 2013 professional edition last week which meant I had to reinstall the software. I have set everything back up and I have noticed that the IntelliSense is not working in my razor files for dynamic objects. I may be wrong but I could of swore this used to work prior to the reinstallation of VS.
Consider the following code
@inherits Umbraco.Web.Mvc.UmbracoTemplatePage
@{
//gets the home page using doc type alias (root node)
var siteRoot = Model.Content.AncestorOrSelf("homePage");
//gets the about us page using doc type alias
var portfolioPage = siteRoot.Descendant("portfolioPage");
//gets the gallery page using doc type alias
var galleryPage = siteRoot.Descendant("galleryPage");
var imagesToDisplay = portfolioPage.HasValue("imageAmount") ? portfolioPage.GetPropertyValue<int>("imageAmount") : 2;
}
<!-- .container -->
<div class="container">
<div class="post-heading-center">
<h2>@(portfolioPage.HasValue("heading") ? portfolioPage.GetPropertyValue("heading") : portfolioPage.Name)</h2>
</div>
<nav>
<a>All Work</a>
<!--get gallery albums-->
@foreach (var type in galleryPage.Children)
{
var galleryAlbum = Umbraco.Media(type.GetPropertyValue<int>("image"));
if (galleryAlbum.ChildrenAsList.Count() != 0)
{
<a href="#" data-filter="[email protected]">@type.Name</a>
}
}
</nav>
</div>
when using visual studio IntelliSense i get no options and a message informing me that its a dynamic expression and it will be resolved at runtime
I have resharpher ultimate installed and when i go to resharper > options and switch to the resharper IntelliSense i get the members from object and what looks like members that i have used elsewhere but resharper is not quite sure.
I know that the ChildrenAsList member (which is what i need) is available to the dynamic galleryAlbum object but why doesnt my IntelliSense tell me this.
The other thing that i have noticed is that my IntelliSense constantly stops working regardless if its in vs or resharper mode which also makes me believe something is screwed with this install. To fix i either have to close the code file or teh project itself. So with the above in mind i have the following questions
Is it standard behaviour for vs IntelliSense not to work with
dynamic objects in umbraco razor views?
Why do base object members show when using resharper IntelliSense and not when using VS IntelliSense?
Why does all IntelliSense constantly stop working?
If anyone has any info on the above then i would be really greatful. I have attempted to reset all user settings via the import and export wizzard but had no luck
I have never had intellisense for dynamic objects. Think about it this way, how is VS or Resharper supposed to infer the properties of an object that is essentially a ghost until it receives values? This is why I usually strongly type anything coming into the page, even CurrentPage to var currentPage = (IPublishedContent)CurrentPage. Just makes debugging a lot easier.
VS Intellisense, while a great tool, is hard to compare to a product that has focused on that functionality as one of it's major attributes that it can charge for.
3.Personally, I have ran into this issue a couple of times. Usually restarting VS or refreshing the Resharper cache fixes it for me.
Razor visual studio IntelliSense not working for dynamic objects
Hi everyone,
I had some trouble with my visual studio 2013 professional edition last week which meant I had to reinstall the software. I have set everything back up and I have noticed that the IntelliSense is not working in my razor files for dynamic objects. I may be wrong but I could of swore this used to work prior to the reinstallation of VS.
Consider the following code
when using visual studio IntelliSense i get no options and a message informing me that its a dynamic expression and it will be resolved at runtime
I have resharpher ultimate installed and when i go to resharper > options and switch to the resharper IntelliSense i get the members from object and what looks like members that i have used elsewhere but resharper is not quite sure.
I know that the ChildrenAsList member (which is what i need) is available to the dynamic galleryAlbum object but why doesnt my IntelliSense tell me this.
The other thing that i have noticed is that my IntelliSense constantly stops working regardless if its in vs or resharper mode which also makes me believe something is screwed with this install. To fix i either have to close the code file or teh project itself. So with the above in mind i have the following questions
If anyone has any info on the above then i would be really greatful. I have attempted to reset all user settings via the import and export wizzard but had no luck
I have never had intellisense for dynamic objects. Think about it this way, how is VS or Resharper supposed to infer the properties of an object that is essentially a ghost until it receives values? This is why I usually strongly type anything coming into the page, even CurrentPage to var currentPage = (IPublishedContent)CurrentPage. Just makes debugging a lot easier.
VS Intellisense, while a great tool, is hard to compare to a product that has focused on that functionality as one of it's major attributes that it can charge for.
3.Personally, I have ran into this issue a couple of times. Usually restarting VS or refreshing the Resharper cache fixes it for me.
Thanks Jason,
All that information is really useful. I'll mark as the solution 😄
is working on a reply...
This forum is in read-only mode while we transition to the new forum.
You can continue this topic on the new forum by tapping the "Continue discussion" link below.