How to: Enforce get latest before check-in?

One of our customers had this problem: developers on his team forget to get latest before check-in and they end up with many conflicts and sometimes they overwrite each others’ changes by mistake. One solution is to enforce a custom check-in policy:

Follow the steps in this walkthrough to create a custom check-in policy and change the following in the policy class:

 

 public override PolicyFailure[] Evaluate()
{
   return PendingCheckin.PendingChanges.Workspace.Get(VersionSpec.Latest, GetOptions.Preview).NumOperations == 0
       ? new PolicyFailure[]{ }
       : new PolicyFailure[]{ new PolicyFailure("Sync first!", this) };
}