Click here to Skip to main content
15,898,020 members
Articles / DevOps / TFS

Code Review for Visual Studio 2012 Professional with TFS 2012

Rate me:
Please Sign up or sign in to vote.
5.00/5 (2 votes)
24 Sep 2013CPOL4 min read 87.3K   425   13  
VS 2012 Professional or lower versions do not have the Code Review module. To achieve this, I came up with a solution which will add a new work item type in TFS 2012. We will also learn how to create a new work item type in TFS.
<?xml version="1.0" encoding="utf-8"?>
<Witd:WITD application="Work item type editor" version="1.0" xmlns:Witd="http://schemas.microsoft.com/VisualStudio/2008/workitemtracking/typedef">
  <WORKITEMTYPE name="Code Review">
    <DESCRIPTION>Describes a divergence between required and actual behavior, and tracks the work done to correct the code and verify the correction.</DESCRIPTION>
    <FIELDS>
      <FIELD name="Iteration Path" refname="System.IterationPath" type="TreePath" reportable="dimension">
        <HELPTEXT>The iteration within which this bug will be fixed</HELPTEXT>
      </FIELD>
      <FIELD name="Iteration ID" refname="System.IterationId" type="Integer" />
      <FIELD name="External Link Count" refname="System.ExternalLinkCount" type="Integer" />
      <FIELD name="Team Project" refname="System.TeamProject" type="String" reportable="dimension" />
      <FIELD name="Hyperlink Count" refname="System.HyperLinkCount" type="Integer" />
      <FIELD name="Attached File Count" refname="System.AttachedFileCount" type="Integer" />
      <FIELD name="Node Name" refname="System.NodeName" type="String" />
      <FIELD name="Area Path" refname="System.AreaPath" type="TreePath" reportable="dimension">
        <HELPTEXT>The area of the product with which this bug is associated</HELPTEXT>
      </FIELD>
      <FIELD name="Revised Date" refname="System.RevisedDate" type="DateTime" reportable="detail" />
      <FIELD name="Changed Date" refname="System.ChangedDate" type="DateTime" reportable="dimension" />
      <FIELD name="ID" refname="System.Id" type="Integer" reportable="dimension" />
      <FIELD name="Area ID" refname="System.AreaId" type="Integer" />
      <FIELD name="Authorized As" refname="System.AuthorizedAs" type="String" syncnamechanges="true" />
      <FIELD name="Title" refname="System.Title" type="String" reportable="dimension">
        <REQUIRED />
        <HELPTEXT>Stories affected and how</HELPTEXT>
      </FIELD>
      <FIELD name="State" refname="System.State" type="String" reportable="dimension">
        <HELPTEXT>Change on reviewing, fixing or verifying the fix. Active = not yet fixed; Resolved = fix not yet verified; Closed = fix verified.</HELPTEXT>
      </FIELD>
      <FIELD name="Authorized Date" refname="System.AuthorizedDate" type="DateTime" />
      <FIELD name="Watermark" refname="System.Watermark" type="Integer" />
      <FIELD name="Rev" refname="System.Rev" type="Integer" reportable="dimension" />
      <FIELD name="Changed By" refname="System.ChangedBy" type="String" syncnamechanges="true" reportable="dimension">
        <ALLOWEXISTINGVALUE />
        <VALIDUSER />
      </FIELD>
      <FIELD name="Reason" refname="System.Reason" type="String" reportable="dimension">
        <HELPTEXT>The reason why the bug is in the current state</HELPTEXT>
      </FIELD>
      <FIELD name="Assigned To" refname="System.AssignedTo" type="String" syncnamechanges="true" reportable="dimension">
        <ALLOWEXISTINGVALUE />
        <VALIDUSER />
        <HELPTEXT>The person currently working on this code review</HELPTEXT>
      </FIELD>
      <FIELD name="Work Item Type" refname="System.WorkItemType" type="String" reportable="dimension" />
      <FIELD name="Created Date" refname="System.CreatedDate" type="DateTime" reportable="dimension" />
      <FIELD name="Created By" refname="System.CreatedBy" type="String" syncnamechanges="true" reportable="dimension" />
      <FIELD name="Description" refname="System.Description" type="HTML" />
      <FIELD name="History" refname="System.History" type="History">
        <HELPTEXT>Discussion thread plus automatic record of changes</HELPTEXT>
      </FIELD>
      <FIELD name="Related Link Count" refname="System.RelatedLinkCount" type="Integer" />
      <FIELD name="Tags" refname="System.Tags" type="PlainText" />
      <FIELD name="Integration Build" refname="Microsoft.VSTS.Build.IntegrationBuild" type="String" reportable="dimension">
        <SUGGESTEDVALUES expanditems="true" filteritems="excludegroups">
          <GLOBALLIST name="Builds - Wizard" />
        </SUGGESTEDVALUES>
        <SUGGESTEDVALUES expanditems="true">
          <LISTITEM value="&lt;None&gt;" />
        </SUGGESTEDVALUES>
        <HELPTEXT>The build in which the bug was fixed</HELPTEXT>
      </FIELD>
      <FIELD name="Closed Date" refname="Microsoft.VSTS.Common.ClosedDate" type="DateTime" reportable="dimension">
        <WHENNOTCHANGED field="System.State">
          <READONLY />
        </WHENNOTCHANGED>
      </FIELD>
      <FIELD name="System Info" refname="Microsoft.VSTS.TCM.SystemInfo" type="HTML">
        <HELPTEXT>Test context, provided automatically by test infrastructure</HELPTEXT>
      </FIELD>
      <FIELD name="Repro Steps" refname="Microsoft.VSTS.TCM.ReproSteps" type="HTML">
        <HELPTEXT>How to see the bug. End by contrasting expected with actual behavior.</HELPTEXT>
      </FIELD>
      <FIELD name="Severity" refname="Microsoft.VSTS.Common.Severity" type="String" reportable="dimension">
        <ALLOWEDVALUES expanditems="true">
          <LISTITEM value="1 - Critical" />
          <LISTITEM value="2 - High" />
          <LISTITEM value="3 - Medium" />
          <LISTITEM value="4 - Low" />
        </ALLOWEDVALUES>
        <DEFAULT from="value" value="3 - Medium" />
        <HELPTEXT>Assessment of the effect of the bug on the project</HELPTEXT>
      </FIELD>
      <FIELD name="Found In" refname="Microsoft.VSTS.Build.FoundIn" type="String" reportable="dimension">
        <SUGGESTEDVALUES expanditems="true" filteritems="excludegroups">
          <GLOBALLIST name="Builds - Wizard" />
        </SUGGESTEDVALUES>
        <SUGGESTEDVALUES expanditems="true">
          <LISTITEM value="&lt;None&gt;" />
        </SUGGESTEDVALUES>
        <HELPTEXT>The build in which the bug was found</HELPTEXT>
      </FIELD>
      <FIELD name="Closed By" refname="Microsoft.VSTS.Common.ClosedBy" type="String" syncnamechanges="true" reportable="dimension">
        <WHENNOTCHANGED field="System.State">
          <ALLOWEXISTINGVALUE />
          <READONLY />
        </WHENNOTCHANGED>
      </FIELD>
      <FIELD name="Priority" refname="Microsoft.VSTS.Common.Priority" type="Integer" reportable="dimension">
        <ALLOWEDVALUES expanditems="true">
          <LISTITEM value="1" />
          <LISTITEM value="2" />
          <LISTITEM value="3" />
          <LISTITEM value="4" />
        </ALLOWEDVALUES>
        <DEFAULT from="value" value="2" />
        <HELPTEXT>Business importance. 1=must fix; 4=unimportant.</HELPTEXT>
      </FIELD>
      <FIELD name="State Change Date" refname="Microsoft.VSTS.Common.StateChangeDate" type="DateTime">
        <WHENNOTCHANGED field="System.State">
          <READONLY />
        </WHENNOTCHANGED>
        <WHENCHANGED field="System.State">
          <SERVERDEFAULT from="clock" />
        </WHENCHANGED>
      </FIELD>
      <FIELD name="Activated Date" refname="Microsoft.VSTS.Common.ActivatedDate" type="DateTime" reportable="dimension">
        <WHENNOTCHANGED field="System.State">
          <READONLY />
        </WHENNOTCHANGED>
      </FIELD>
      <FIELD name="Activated By" refname="Microsoft.VSTS.Common.ActivatedBy" type="String" syncnamechanges="true" reportable="dimension">
        <WHENNOTCHANGED field="System.State">
          <ALLOWEXISTINGVALUE />
          <READONLY />
        </WHENNOTCHANGED>
      </FIELD>
      <FIELD name="Resolved Date" refname="Microsoft.VSTS.Common.ResolvedDate" type="DateTime" reportable="dimension">
        <WHENNOTCHANGED field="System.State">
          <READONLY />
        </WHENNOTCHANGED>
      </FIELD>
      <FIELD name="Resolved By" refname="Microsoft.VSTS.Common.ResolvedBy" type="String" syncnamechanges="true" reportable="dimension">
        <WHENNOTCHANGED field="System.State">
          <ALLOWEXISTINGVALUE />
          <READONLY />
        </WHENNOTCHANGED>
      </FIELD>
      <FIELD name="Resolved Reason" refname="Microsoft.VSTS.Common.ResolvedReason" type="String" reportable="dimension">
        <ALLOWEDVALUES expanditems="true">
          <LISTITEM value="Duplicate" />
          <LISTITEM value="Deferred" />
          <LISTITEM value="Obsolete" />
          <LISTITEM value="As Designed" />
          <LISTITEM value="Cannot Reproduce" />
          <LISTITEM value="Fixed" />
          <LISTITEM value="Copied to Backlog" />
        </ALLOWEDVALUES>
        <FROZEN />
        <HELPTEXT>The reason why the bug was resolved</HELPTEXT>
      </FIELD>
      <FIELD name="Stack Rank" refname="Microsoft.VSTS.Common.StackRank" type="Double" reportable="dimension">
        <HELPTEXT>Work first on items with lower-valued stack rank. Set in triage.</HELPTEXT>
      </FIELD>
      <FIELD name="CodeReview ReviewedBy" refname="CodeReview.ReviewedBy" type="String" reportable="dimension">
        <ALLOWEXISTINGVALUE />
        <VALIDUSER />
        <REQUIRED />
      </FIELD>
      <FIELD name="CodeReview Suggestion" refname="CodeReview.Suggestion" type="HTML" />
    </FIELDS>
    <WORKFLOW>
      <STATES>
        <STATE value="Closed">
          <FIELDS>
            <FIELD refname="Microsoft.VSTS.Common.ResolvedReason">
              <READONLY />
            </FIELD>
          </FIELDS>
        </STATE>
        <STATE value="Active">
          <FIELDS>
            <FIELD refname="Microsoft.VSTS.Common.ClosedDate">
              <EMPTY />
            </FIELD>
            <FIELD refname="Microsoft.VSTS.Common.ClosedBy">
              <ALLOWEXISTINGVALUE />
              <EMPTY />
            </FIELD>
            <FIELD refname="Microsoft.VSTS.Common.ResolvedDate">
              <EMPTY />
            </FIELD>
            <FIELD refname="Microsoft.VSTS.Common.ResolvedBy">
              <ALLOWEXISTINGVALUE />
              <EMPTY />
            </FIELD>
            <FIELD refname="Microsoft.VSTS.Common.ResolvedReason">
              <EMPTY />
            </FIELD>
          </FIELDS>
        </STATE>
        <STATE value="Resolved">
          <FIELDS>
            <FIELD refname="Microsoft.VSTS.Common.ClosedDate">
              <EMPTY />
            </FIELD>
            <FIELD refname="Microsoft.VSTS.Common.ClosedBy">
              <ALLOWEXISTINGVALUE />
              <EMPTY />
            </FIELD>
            <FIELD refname="Microsoft.VSTS.Common.ResolvedReason">
              <REQUIRED />
            </FIELD>
          </FIELDS>
        </STATE>
      </STATES>
      <TRANSITIONS>
        <TRANSITION from="Resolved" to="Closed">
          <REASONS>
            <DEFAULTREASON value="Verified" />
          </REASONS>
          <FIELDS>
            <FIELD refname="Microsoft.VSTS.Common.ClosedBy">
              <ALLOWEXISTINGVALUE />
              <COPY from="currentuser" />
              <VALIDUSER />
              <REQUIRED />
            </FIELD>
            <FIELD refname="Microsoft.VSTS.Common.ClosedDate">
              <SERVERDEFAULT from="clock" />
            </FIELD>
            <FIELD refname="Microsoft.VSTS.Common.ActivatedDate">
              <READONLY />
            </FIELD>
            <FIELD refname="Microsoft.VSTS.Common.ActivatedBy">
              <ALLOWEXISTINGVALUE />
              <READONLY />
            </FIELD>
            <FIELD refname="Microsoft.VSTS.Common.ResolvedDate">
              <READONLY />
            </FIELD>
            <FIELD refname="Microsoft.VSTS.Common.ResolvedBy">
              <ALLOWEXISTINGVALUE />
              <READONLY />
            </FIELD>
          </FIELDS>
        </TRANSITION>
        <TRANSITION from="" to="Active">
          <REASONS>
            <DEFAULTREASON value="New" />
          </REASONS>
          <FIELDS>
            <FIELD refname="Microsoft.VSTS.Common.ActivatedBy">
              <ALLOWEXISTINGVALUE />
              <COPY from="currentuser" />
              <VALIDUSER />
              <REQUIRED />
            </FIELD>
            <FIELD refname="Microsoft.VSTS.Common.ActivatedDate">
              <SERVERDEFAULT from="clock" />
            </FIELD>
          </FIELDS>
        </TRANSITION>
        <TRANSITION from="Closed" to="Active">
          <REASONS>
            <DEFAULTREASON value="Reactivated" />
          </REASONS>
          <FIELDS>
            <FIELD refname="Microsoft.VSTS.Common.ActivatedBy">
              <ALLOWEXISTINGVALUE />
              <COPY from="currentuser" />
              <VALIDUSER />
              <REQUIRED />
            </FIELD>
            <FIELD refname="System.AssignedTo">
              <COPY from="field" field="Microsoft.VSTS.Common.ResolvedBy" />
            </FIELD>
            <FIELD refname="Microsoft.VSTS.Common.ActivatedDate">
              <SERVERDEFAULT from="clock" />
            </FIELD>
          </FIELDS>
        </TRANSITION>
        <TRANSITION from="Resolved" to="Active">
          <REASONS>
            <DEFAULTREASON value="Not fixed" />
          </REASONS>
          <FIELDS>
            <FIELD refname="Microsoft.VSTS.Common.ActivatedBy">
              <ALLOWEXISTINGVALUE />
              <COPY from="currentuser" />
              <VALIDUSER />
              <REQUIRED />
            </FIELD>
            <FIELD refname="System.AssignedTo">
              <COPY from="field" field="Microsoft.VSTS.Common.ResolvedBy" />
            </FIELD>
            <FIELD refname="Microsoft.VSTS.Common.ActivatedDate">
              <SERVERDEFAULT from="clock" />
            </FIELD>
          </FIELDS>
        </TRANSITION>
        <TRANSITION from="Active" to="Resolved">
          <REASONS>
            <REASON value="Duplicate">
              <FIELDS>
                <FIELD refname="Microsoft.VSTS.Common.ResolvedReason">
                  <COPY from="value" value="Duplicate" />
                  <ALLOWEDVALUES expanditems="true">
                    <LISTITEM value="Duplicate" />
                  </ALLOWEDVALUES>
                </FIELD>
              </FIELDS>
            </REASON>
            <REASON value="Deferred">
              <FIELDS>
                <FIELD refname="Microsoft.VSTS.Common.ResolvedReason">
                  <COPY from="value" value="Deferred" />
                  <ALLOWEDVALUES expanditems="true">
                    <LISTITEM value="Deferred" />
                  </ALLOWEDVALUES>
                </FIELD>
              </FIELDS>
            </REASON>
            <REASON value="Obsolete">
              <FIELDS>
                <FIELD refname="Microsoft.VSTS.Common.ResolvedReason">
                  <COPY from="value" value="Obsolete" />
                  <ALLOWEDVALUES expanditems="true">
                    <LISTITEM value="Obsolete" />
                  </ALLOWEDVALUES>
                </FIELD>
              </FIELDS>
            </REASON>
            <REASON value="As Designed">
              <FIELDS>
                <FIELD refname="Microsoft.VSTS.Common.ResolvedReason">
                  <COPY from="value" value="As Designed" />
                  <ALLOWEDVALUES expanditems="true">
                    <LISTITEM value="As Designed" />
                  </ALLOWEDVALUES>
                </FIELD>
              </FIELDS>
            </REASON>
            <REASON value="Copied to Backlog">
              <FIELDS>
                <FIELD refname="Microsoft.VSTS.Common.ResolvedReason">
                  <COPY from="value" value="Copied to Backlog" />
                  <ALLOWEDVALUES expanditems="true">
                    <LISTITEM value="Copied to Backlog" />
                  </ALLOWEDVALUES>
                </FIELD>
              </FIELDS>
            </REASON>
            <DEFAULTREASON value="Fixed">
              <FIELDS>
                <FIELD refname="Microsoft.VSTS.Common.ResolvedReason">
                  <COPY from="value" value="Fixed" />
                  <ALLOWEDVALUES expanditems="true">
                    <LISTITEM value="Fixed" />
                  </ALLOWEDVALUES>
                </FIELD>
              </FIELDS>
            </DEFAULTREASON>
          </REASONS>
          <FIELDS>
            <FIELD refname="Microsoft.VSTS.Common.ResolvedBy">
              <ALLOWEXISTINGVALUE />
              <COPY from="currentuser" />
              <VALIDUSER />
              <REQUIRED />
            </FIELD>
            <FIELD refname="Microsoft.VSTS.Common.ResolvedReason">
              <COPY from="value" value="Fixed" />
            </FIELD>
            <FIELD refname="System.AssignedTo">
              <COPY from="field" field="System.CreatedBy" />
            </FIELD>
            <FIELD refname="Microsoft.VSTS.Common.ActivatedDate">
              <READONLY />
            </FIELD>
            <FIELD refname="Microsoft.VSTS.Common.ActivatedBy">
              <ALLOWEXISTINGVALUE />
              <READONLY />
            </FIELD>
            <FIELD refname="Microsoft.VSTS.Common.ResolvedDate">
              <SERVERDEFAULT from="clock" />
            </FIELD>
          </FIELDS>
          <ACTIONS>
            <ACTION value="Microsoft.VSTS.Actions.Checkin" />
          </ACTIONS>
        </TRANSITION>
      </TRANSITIONS>
    </WORKFLOW>
    <FORM>
      <Layout HideReadOnlyEmptyFields="true" HideControlBorders="true">
        <Group Margin="(4,0,0,0)">
          <Column PercentWidth="100">
            <Control FieldName="System.Title" Type="FieldControl" ControlFontSize="large" EmptyText="&lt;Enter title here&gt;" LabelPosition="Top" />
          </Column>
        </Group>
        <Group Margin="(10,0,0,0)">
          <Column PercentWidth="33">
            <Group Label="Status">
              <Column PercentWidth="100">
                <Control FieldName="System.AssignedTo" EmptyText="&lt;No one&gt;" Type="FieldControl" Label="Assi&amp;gned To" LabelPosition="Left" />
                <Control FieldName="CodeReview.ReviewedBy" Type="FieldControl" Label="Re&amp;viewed By" LabelPosition="Left" EmptyText="&lt;No one&gt;" />
                <Control FieldName="System.State" Type="FieldControl" Label="Stat&amp;e" LabelPosition="Left" />
                <Control FieldName="System.Reason" Type="FieldControl" Label="Reason" LabelPosition="Left" />
                <Control FieldName="Microsoft.VSTS.Common.ResolvedReason" Type="FieldControl" Label="Resolved Reason" LabelPosition="Left" ReadOnly="True" />
              </Column>
            </Group>
          </Column>
          <Column PercentWidth="33">
            <Group Label="Classification">
              <Column PercentWidth="100">
                <Control FieldName="System.AreaPath" Type="WorkItemClassificationControl" Label="&amp;Area" LabelPosition="Left" />
                <Control FieldName="System.IterationPath" Type="WorkItemClassificationControl" Label="Ite&amp;ration" LabelPosition="Left" />
              </Column>
            </Group>
          </Column>
          <Column PercentWidth="33">
            <Group Label="Planning">
              <Column PercentWidth="100">
                <Control FieldName="Microsoft.VSTS.Common.StackRank" Type="FieldControl" Label="Stack Rank" LabelPosition="Left" NumberFormat="DecimalNumbers" MaxLength="10" EmptyText="&lt;None&gt;" />
                <Control FieldName="Microsoft.VSTS.Common.Priority" Type="FieldControl" Label="Priority" LabelPosition="Left" />
                <Control FieldName="Microsoft.VSTS.Common.Severity" Type="FieldControl" Label="Severity" LabelPosition="Left" />
              </Column>
            </Group>
          </Column>
        </Group>
        <Group>
          <Column PercentWidth="50">
            <TabGroup>
              <Tab Label="Description">
                <Control FieldName="System.Description" Type="HtmlFieldControl" MinimumSize="(100,200)" Dock="Fill" LabelPosition="Top" />
              </Tab>
              <Tab Label="Suggestion">
                <Control FieldName="CodeReview.Suggestion" Type="HtmlFieldControl" LabelPosition="Top" Dock="Fill" MinimumSize="(100,200)" />
              </Tab>
            </TabGroup>
          </Column>
          <Column PercentWidth="50">
            <TabGroup Margin="(5,0,0,0)">
              <Tab Label="History">
                <Control FieldName="System.History" Type="WorkItemLogControl" Dock="Fill" LabelPosition="Top" />
              </Tab>
              <Tab Label="All Links">
                <Control Type="LinksControl" Name="GeneralLinks" LabelPosition="Top">
                  <LinksControlOptions>
                    <LinkColumns>
                      <LinkColumn RefName="System.Id" />
                      <LinkColumn RefName="System.WorkItemType" />
                      <LinkColumn RefName="System.Title" />
                      <LinkColumn RefName="System.AssignedTo" />
                      <LinkColumn RefName="System.State" />
                      <LinkColumn LinkAttribute="System.Links.Comment" />
                    </LinkColumns>
                  </LinksControlOptions>
                </Control>
              </Tab>
              <Tab Label="Attachments">
                <Control Type="AttachmentsControl" LabelPosition="Top" />
              </Tab>
            </TabGroup>
          </Column>
        </Group>
      </Layout>
    </FORM>
  </WORKITEMTYPE>
</Witd:WITD>

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



Comments and Discussions