{"id":4073,"date":"2006-03-20T18:46:00","date_gmt":"2006-03-20T18:46:00","guid":{"rendered":"https:\/\/blogs.msdn.microsoft.com\/buckh\/2006\/03\/20\/how-to-validate-check-in-policies-evaluate-check-in-notes-and-check-for-conflicts\/"},"modified":"2006-03-20T18:46:00","modified_gmt":"2006-03-20T18:46:00","slug":"how-to-validate-check-in-policies-evaluate-check-in-notes-and-check-for-conflicts","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/buckh\/how-to-validate-check-in-policies-evaluate-check-in-notes-and-check-for-conflicts\/","title":{"rendered":"How to validate check-in policies, evaluate check-in notes, and check for conflicts"},"content":{"rendered":"<p>In the version control API, the <font face=\"Courier New\" color=\"#000000\">CheckIn()<\/font> method does not evaluate check-in policies and&nbsp;validate check-in notes.&nbsp; It provides with the ability to supply both an override comment and check-in notes, as applicable, but the evaluation and validation must have been performed prior to calling <font face=\"Courier New\">CheckIn()<\/font>.&nbsp; The reason for this is that in a real-world application, you will evaluate check-in policies and validate check-in notes at points in time that make sense for whatever you are writing.&nbsp; For example, the Visual Studio environment will evaluate check-in policies when certain events are triggered.&nbsp; Also, applications that are converting from a different version control system to TFS will want to bypass these checks.<\/p>\n<p>The&nbsp;<font face=\"Courier New\">EvaluateCheckin()<\/font> method evaluates policies and validate check-in notes.&nbsp; It also checks for conflicts.&nbsp; Here is the method signature along with its documentation.<\/p>\n<p><font face=\"Courier New\">&nbsp;&nbsp;&nbsp; \/\/********************************************************************************************<br>&nbsp;&nbsp;&nbsp; \/\/\/ &lt;summary&gt;<br>&nbsp;&nbsp;&nbsp; \/\/\/ Evaluate the changes to see if they are ready for checking in.<br>&nbsp;&nbsp;&nbsp; \/\/\/ &lt;\/summary&gt;<br>&nbsp;&nbsp;&nbsp; \/\/\/ &lt;param name=&#8221;options&#8221;&gt;Selects what to check (notes, policies, conflicts).&lt;\/param&gt;<br>&nbsp;&nbsp;&nbsp; \/\/\/ &lt;param name=&#8221;allChanges&#8221;&gt;All pending changes for the workspace (needed by checkin policies).<br>&nbsp;&nbsp;&nbsp; \/\/\/ &lt;\/param&gt;<br>&nbsp;&nbsp;&nbsp; \/\/\/ &lt;param name=&#8221;changes&#8221;&gt;List of changes to evaluate.&lt;\/param&gt;<br>&nbsp;&nbsp;&nbsp; \/\/\/ &lt;param name=&#8221;comment&#8221;&gt;Comment to go along with the checkin.&lt;\/param&gt;<br>&nbsp;&nbsp;&nbsp; \/\/\/ &lt;param name=&#8221;checkinNote&#8221;&gt;Any applicable checkin notes data.&lt;\/param&gt;<br>&nbsp;&nbsp;&nbsp; \/\/\/ &lt;param name=&#8221;workItemChanges&#8221;&gt;List of work item changes to occur with this checkin (supplied to checkin policies).&lt;\/param&gt;<br>&nbsp;&nbsp;&nbsp; \/\/\/ &lt;returns&gt;the results of what was checked&lt;\/returns&gt;<br>&nbsp;&nbsp;&nbsp; \/\/********************************************************************************************<br>&nbsp;&nbsp;&nbsp; public CheckinEvaluationResult EvaluateCheckin(CheckinEvaluationOptions options,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; PendingChange[] allChanges,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs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sp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; WorkItemCheckinInfo[] workItemChanges)<\/font><\/p>\n<p>The <font face=\"Courier New\">options<\/font> parameter controls what is evaluated and is a simple flag enum.<\/p>\n<p><font face=\"Courier New\">&nbsp;&nbsp;&nbsp; \/\/********************************************************************************************<br>&nbsp;&nbsp;&nbsp; \/\/\/ &lt;summary&gt;<br>&nbsp;&nbsp;&nbsp; \/\/\/ Used in pre-checkin evaluation, this enumeration&nbsp;is used to specify which aspects of a<br>&nbsp;&nbsp;&nbsp; \/\/\/ checkin should be evaluated.<br>&nbsp;&nbsp;&nbsp; \/\/\/ &lt;\/summary&gt;<br>&nbsp;&nbsp;&nbsp; \/\/********************************************************************************************<br>&nbsp;&nbsp;&nbsp; [Flags]<br>&nbsp;&nbsp;&nbsp; public enum CheckinEvaluationOptions<br>&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Notes = 0,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Policies = 1,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Conflicts = 2,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; All = -1,<br>&nbsp;&nbsp;&nbsp; }<\/font><\/p>\n<p>The result of the function is a CheckinEvaluationResult, which has the following properties.<\/p>\n<p><font face=\"Courier New\">&nbsp;&nbsp;&nbsp; \/\/********************************************************************************************<br>&nbsp;&nbsp;&nbsp; \/\/\/ &lt;summary&gt;<br>&nbsp;&nbsp;&nbsp; \/\/\/ These are the checkin conflicts returned by the server.<br>&nbsp;&nbsp;&nbsp; \/\/\/ &lt;\/summary&gt;<br>&nbsp;&nbsp;&nbsp; \/\/********************************************************************************************<br>&nbsp;&nbsp;&nbsp; public CheckinConflict[] Conflicts<\/p>\n<p>&nbsp;&nbsp;&nbsp; \/\/********************************************************************************************<br>&nbsp;&nbsp;&nbsp; \/\/\/ &lt;summary&gt;<br>&nbsp;&nbsp;&nbsp; \/\/\/ These are the checkin note problems (missing required notes, invalid checkin notes, etc.).<br>&nbsp;&nbsp;&nbsp; \/\/\/ &lt;\/summary&gt;<br>&nbsp;&nbsp;&nbsp; \/\/********************************************************************************************<br>&nbsp;&nbsp;&nbsp; public CheckinNoteFailure[] NoteFailures<\/p>\n<p>&nbsp;&nbsp;&nbsp; \/\/********************************************************************************************<br>&nbsp;&nbsp;&nbsp; \/\/\/ &lt;summary&gt;<br>&nbsp;&nbsp;&nbsp; \/\/\/ These are the checkin policy failures.<br>&nbsp;&nbsp;&nbsp; \/\/\/ &lt;\/summary&gt;<br>&nbsp;&nbsp;&nbsp; \/\/********************************************************************************************<br>&nbsp;&nbsp;&nbsp; public PolicyFailure[] PolicyFailures<\/p>\n<p>&nbsp;&nbsp;&nbsp; \/\/********************************************************************************************<br>&nbsp;&nbsp;&nbsp; \/\/\/ &lt;summary&gt;<br>&nbsp;&nbsp;&nbsp; \/\/\/ If evaluating policies throws an exception, this is the exception that occurred.&nbsp; It is null<br>&nbsp;&nbsp;&nbsp; \/\/\/ otherwise.<br>&nbsp;&nbsp;&nbsp; \/\/\/ &lt;\/summary&gt;<br>&nbsp;&nbsp;&nbsp; \/\/********************************************************************************************<br>&nbsp;&nbsp;&nbsp; public Exception PolicyEvaluationException<\/font><\/p>\n<p>The properties will be set according to the options you specify and according to what fails.&nbsp; So if you don&#8217;t request policy evaluation, for example, or there are no policy failures, the PolicyFailures property will be an empty array.<\/p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>In the version control API, the CheckIn() method does not evaluate check-in policies and&nbsp;validate check-in notes.&nbsp; It provides with the ability to supply both an override comment and check-in notes, as applicable, but the evaluation and validation must have been performed prior to calling CheckIn().&nbsp; The reason for this is that in a real-world application, [&hellip;]<\/p>\n","protected":false},"author":94,"featured_media":10268,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[6,8],"class_list":["post-4073","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-uncategorized","tag-source-control","tag-team-foundation"],"acf":[],"blog_post_summary":"<p>In the version control API, the CheckIn() method does not evaluate check-in policies and&nbsp;validate check-in notes.&nbsp; It provides with the ability to supply both an override comment and check-in notes, as applicable, but the evaluation and validation must have been performed prior to calling CheckIn().&nbsp; The reason for this is that in a real-world application, [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/buckh\/wp-json\/wp\/v2\/posts\/4073","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/buckh\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/buckh\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/buckh\/wp-json\/wp\/v2\/users\/94"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/buckh\/wp-json\/wp\/v2\/comments?post=4073"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/buckh\/wp-json\/wp\/v2\/posts\/4073\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/buckh\/wp-json\/wp\/v2\/media\/10268"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/buckh\/wp-json\/wp\/v2\/media?parent=4073"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/buckh\/wp-json\/wp\/v2\/categories?post=4073"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/buckh\/wp-json\/wp\/v2\/tags?post=4073"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}