April 26, 2011

Grouping class and interface tabs

It is a common convention to have interface file names started with ‘I’ (like IService.cs) and implementation files named the same excluding the first ‘I’ (like Service.cs). Would be nice to have them on one tab. Below is a solution copied from the recent discussion on the Tabs Studio mail list.

It is easy to group such files, the problem is how the result looks like. For example, the best title grouping regex for this task I can think
of is:

(?<Ext>I(?<Name>.+?)\.cs)|(?<Name>(.*[/\\])?.+?)(?<Ext>\..+)

It nicely groups two files as “Service .cs IService.cs”, but when IService.cs is the single file in a tab it will be displayed as “ServiceIService.cs” (and IInterface1.cs will be displayed as “Interface1IInterface1.cs”):

Grouping class and interface tabs using only title grouping regex

To improve interface tab name representation I’ve created the additional ITransform add-in to transform interface titles after grouping. With this add-in for the IService.cs and Service.cs pair a grouped tab will be “Service .cs Interface” and a single interface tab will remain “IService.cs”:

Grouping class and interface tabs using title grouping regex and the ITransform add-in

ITransform still requires setting up the special interface grouping regex first. Add the following title grouping regex section:

I(?<Name>[A-Z].+?)\.(?<Ext>.+)

For example, if you use default title grouping settings, your combined title grouping regex will be: