Using Microsoft's UITypeEditors With The OOTB List<T> Editor
This post is a sequel to a previous post - The TFS Build Definition List<T> OOTB UITypeEditor.
In my previous post I showed how easy and cheep it is to use the TFS’s build definition OOTB “List<T>” editor.
We even saw that if we use enum’s or Boolean's the “List<T>” editor’s properties grid gives us drop-down editors for them, but what if we want to use more advanced editors; such as the “ServerFileBrowserEditor” to select a project from the source control or the “PlatformConfigurationListEditor” editor to choose in which configurations and platforms I want to compile the project or any other editor?
Well it seems to be extremely easy as well. All we need to do is take the same object we were using before:
1: using System.Collections.Generic;
2: using System.ComponentModel;
3: using System.Drawing.Design;
4: using BuildDemosC.Common.Enums;
5: using Microsoft.TeamFoundation.Build.Workflow.Activities;
6:
7: namespace BuildDemosC.CustomTypes
8: {
9: public class DevEnvCompilationItem
10: {
11: [Category("Properties")]
12: public string Project { get; set; }
13:
14: [DisplayName("Compiler Name")]
15: [Category("Properties")]
16: public DevEnvType CompilerName { get; set; }
17:
18: #region Methods
19:
20: public override string ToString()
21: {
22: return string.IsNullOrEmpty(Project) ? "New" : Project + "=>" + CompilerName;
23: }
24:
25: #endregion
26:
27: }
28: }
and add the “Editor” attribute with the editor we want to use over the property we want to use it with:
1: using System.Collections.Generic;
2: using System.ComponentModel;
3: using System.Drawing.Design;
4: using BuildDemosC.Common.Enums;
5: using Microsoft.TeamFoundation.Build.Workflow.Activities;
6:
7: namespace BuildDemosC.CustomTypes
8: {
9: public class DevEnvCompilationItem
10: {
11: [Editor("Microsoft.TeamFoundation.Build.Controls.ServerFileBrowserEditor, Microsoft.TeamFoundation.Build.Controls", typeof(UITypeEditor))]
12: [Category("Properties")]
13: public string Project { get; set; }
14:
15: [DisplayName("Compiler Name")]
16: [Category("Properties")]
17: public DevEnvType CompilerName { get; set; }
18:
19: #region Methods
20:
21: public override string ToString()
22: {
23: return string.IsNullOrEmpty(Project) ? "New" : Project + "=>" + CompilerName;
24: }
25:
26: #endregion
27:
28: }
29: }
After we check-in our changes, open a new instance of visual studio (So it will load the new dll files) and go to the build definition this is what will see when we came to edit our object list:

Easy, elegant, cheep! :)