I got a task which is need to check whether a specific class with Summary when it is checked-in on Team Foundation System.
I have found a way which is turn on the code analysis in the process of check-in, the problem is there is no Summary checking item in rules.
Is there any way to check each class whether with Summary during the check-in?
Is it possible to customize BuildprocessTemplate to make it?
can this checkin policy evaluate make it?
public override PolicyFailure[] Evaluate()
{
List<PolicyFailure> failures = new List<PolicyFailure>();
foreach(PendingChange pc in PendingCheckin.PendingChanges.CheckedPendingChanges)
{
if(pc.LocalItem == null)
{
continue;
}
/* Open the file */
using(FileStream fs = new FileStream(pc.FileName,FileMode.Open,FileAccess.Read))
{
StreamReader fs1 = new StreamReader(fs);
string eachline= fs1.ReadLine();
int PublicCount=0;
int SummaryCount = 0;
while(eachline !="")
{
if (eachline.IndexOf("/// <summary>")!=-1)
{
SummaryCount++;
}
if (eachline.IndexOf("public")!=-1)
{
PublicCount++;
}
}
if(PublicCount != SummaryCount)
{
failures.Add(new PolicyFailure("Class Summary missing"));
}
fs.Close();
}
}
return failures.ToArray();
}