There have been questions about the IPolicyDefinition interface around the following parameters:
The main question I get is ‘What is the difference between TypeDefinition andDefinition and what should they be?’
Some developers will make these the same; that will work for some policies. For others, making them unique will provide more information to your audience.
There is a brief description of each:
- Type – this string is the type of the policy; intended to be a short name.
- TypeDescription – this string is a more verbose description; this is intended to be a longer description.
- Description – This is the description of a particular instance of the policy which is being created.
The Type and TypeDescription are fairly straight forward, so I will dig deeper into the Description value.
Let me first start by saying that you may create more than one instance of the same policy Type for a single team project. At first, this may not be clear – the reason for allowing this; for example, it would not make too much sense to add two policies which require workitems to be associated for a checkin. However, there are circumstances where this does make sense. Take the sample tabs policy I blogged about in the past. It is possible that you want to configure this policy numerous times; one instance could check for tabs in Visual Basic files (.vb, .vbproj, …); another could be added for C# files (.cs, .csproj).
Taking the above example, we would have two instances of this policy serialized on the server – one for VB and one for C#. When displaying these in the Source Control properties, we will need to differentiate the two – this is where the Description is used. The Description’s could then be:
- “Check for tabs in files: .vb, .vbproj”
- “Check for tabs in files: .cs, .csproj”
Another example may help clarify a need for this; take the tabs policy and update it so that it did not, by default, search for tabs, but instead, allowed the person configuring the policy to look for specific patterns in the code (expected patterns to find and patterns which should not exist in the code). Now, this policy could be setup to look for tabs and another instance of this policy could look to ensure the appropriate copyright comment is in each file.