2 votes

PropSense

Not using strongly-typed models for your Umbraco views / templates / macros but still need Intellisense? If so, then just copy those templates in your App_Code directory and right-click-"Run Custom Tool" on UmbracoData.tt from within Visual Studio.

This will generate a set of classes under the namespace DotSee.PropSense with constants that correspond to document property aliases.

Here's an example of such a generated class for the document type alias "dContentSliderItem":

public static class Psn_dContentSliderItem
    {
        public const string TypeName = "dContentSliderItem";
        public const string internalLink = "internalLink";
        public const string externalLink = "externalLink";
        public const string content = "content";
        public const string buttonText = "buttonText";
        public const string image = "image";
        public const string imagePosition = "imagePosition";
    }

All classes get the prefix "Psn_" for easy Intellisense and their properties correspond to document property aliases (compositions included). So, next time you need to do something like:

someNode.GetPropertyValue("internalLink")

you can instead do:

someNode.GetPropertyValue(Psn_dContentSliderItem.internalLink)

Yes, it's longer and it doesn't exactly respect conventions (if the alias starts with a lowercase letter, then the property will also start with lowercase) but it gives you intellisense, and that's what you need to save time spent on typos and misspellings.

As you can see, there's also the TypeName property which gives you the document type alias in case you need it somewhere.

Please remember to re-run this whenever you make changes to document properties.

Other notes

Although this is under my account, it was originally developed by George J. Capnias and is posted here with his permission. Idea, some alterations and some testing were mine. Thanks!

Package owner

Sotiris Filippidis

Sotiris Filippidis

Sotiris has 1501 karma points

Package Compatibility

This package is compatible with the following versions as reported by community members who have downloaded this package:
Untested or doesn't work on Umbraco Cloud
Version 8.18.x (untested)

You must login before you can report on package compatibility.

Previously reported to work on versions: 7.4.x

Package Information

  • Package owner: Sotiris Filippidis
  • Created: 11/06/2016
  • Current version 1.0
  • .NET version 4.5
  • License MIT
  • Downloads on Our: 708

External resources