The Q2 2013 Release of JustCode is here! As always, there are a host of new features, performance improvements, and all around awesome sauce included in this release.
The biggest rock in this release is the ability to decompile and debug dependent assemblies right in Visual Studio. For more information, please see this detailed blog post.
In addition to the rich insert and surround templating features for C#, VB.NET, HTML, CSS, LESS, and JavaScript, JustCode now provides file templates as well. To help with the file templates, we’ve introduced two additional macros:
There are several ways to expand a File Template:
An example of a file template that I use for Test Driven Development is shown in Listing 1.
$NEW_FILE$using System;
using NUnit.Framework;
using Telerik.JustMock;
using Telerik.JustMock.Helpers;
namespace $1=SUGGEST_NAMESPACE()$
{[TestFixture]public class $2=GET_FILE_NAME()${[Test]public void Should$3$(){|}}}
Listing 1 – NUnit Test Fixture File Template
In addition to the two new macros introduced for File Templates, we’ve introduced two additional template macros in this release:
To get the name of the encasing type, simply add the macro as shown in Listing 2.
$1=GET_TYPE_NAME()$
One example of where getting the current member is valuable is in WPF applications where you need to add a call to NotifyPropertyChanged in your setters, and a sample template for this use case is shown in Listing 3.
NotifyPropertyChanged("$1=GET_MEMBER_NAME()$");
Listing 3 – Adding call to NotifyPropertyChanged
There are four main improvements to the JustCode test runner:
Figure 1 – New Test Runner enhancements
JustCode provides a quick fix to correct the namespace of an object based on the default namespace and the folder path of the files location in the project. If you don’t want to include a folder into the namespace, you can set the folder to be ignored in the namespace configuration. To set this flag, open the properties windows for the folder, and change the “Do Not Contribure to Namespace” setting to “True”. This dialog is shown in Figure 2.
Figure 2 – Choosing a folder’s impact on namespace configuration
A highly requested feature in the feedback forum (located here) was to convert instantiation of an object using property names to one using the object initializer format (and vice versa). Looking at the code in Listing 4, this is a class that initializes the FirstName, LastName, and Age properties after the initial call to “new”.
var foo = new foo();
foo.FirstName = "Bob";
foo.LastName = "Smith";
foo.Age = 42;
Listing 4 – Object Initialization using property statements.
By opening the refactoring menu in JustCode (as in Figure 3), you can see the new menu item “To Object Initializer”.
Figure 3 – Refactor Menu
Executing this refactoring will then produce the code in Listing 5. The reverse refactoring “To Assignment Statements” can be used on statements using Object Initializers.
var foo = new foo()
{FirstName = "Bob",
LastName = "Smith",
Age = 42};
Listing 5 – Converted to Object Initialization
This isn’t even all of the new features in JustCode Q2 2013! To see the complete list, please see the What’s New Page. Better yet, download the latest version and give it a spin!
Philip Japikse is an international speaker, a Microsoft MVP, ASPInsider, INETA Community Champion, MCSD, CSM/ CSP, and a passionate member of the developer community. Phil has been working with .Net since the first betas, developing software for over 20 years, and heavily involved in the agile community since 2005. Phil also hosts the Hallway Conversations podcast (www.hallwayconversations.com) and serves as the Lead Director for the Cincinnati .Net User’s Group (http://www.cinnug.org). You can follow Phil on twitter via www.twitter.com/skimedic, or read his personal blog at www.skimedic.com/blog.