I’m in the starting phase of a new project, and as always there are a few tricks to bring with me from my previous project… When developing with PageTypeBuilder, a good practice is to create an abstract class BasePage, inheriting from TypedPageData, and let all page types in my solution inherit from BasePage. This lets me add certain features to all the page types in my solution, and one of the first tricks is this little thing:
using System.Diagnostics;
using PageTypeBuilder;
namespace MakingWaves.MyNewProjectButIAmNotDisclosingTheCustomerNameHere.Model
{
[DebuggerDisplay("PageType: {MyPageType}, PageName: {PageName}")]
public abstract class BasePage : TypedPageData
{
public string MyPageType
{
get
{
// GetType() returns something like the following: "Castle.Proxies.PageTypeNameProxy"
return GetType().ToString().Replace("Castle.Proxies.", string.Empty).Replace("Proxy", string.Empty);
}
}
}
}
The DebuggerDisplayAttribute is a standard .Net feature that I know many of my fellow developers are unaware of. The DebuggerDisplayAttribute lets you format what is shown in the debugger, and you can include any public property (simply by matching on the name). Using this wisely makes all the difference when you’re debugging. When debugging an EPiServer solution, you’ll often come across a list of pages, and the trick above turns this

into this

…and I’m sure you’ll agree that this simple change makes debugging a site much easier!
Like this:
Like Loading...
Agree, very useful, we have done a few of these out-of-the-box in CMS vNext.