Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Tip
titleAutomated .NET Code Review

Note that the Build Log report will tabulate code analysis results if they are in the MSBuild log. This can be a convenient way to run an automated code review of your new .NET codebase. See Code Analysis in MSDN for additional details on using MSBuild for code reviews.

To activate this, you can add a RunCodeAnalysis element to the .NET project file using an . This can be made an automated step in the upgrade process by adding an Author/Fix (aka a Post-Edit) to the template upgrade script as shown below.

Code Block
<Author>
...
<Fix name="Post-Edit">
<Replace name="Activate Code Analysis" lang="csproj">
<OldBlock><![CDATA[
  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
]]></OldBlock>
<NewBlock><![CDATA[
  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
    <RunCodeAnalysis>true</RunCodeAnalysis>
]]></NewBlock>
</Replace>
</Fix>
</Author>
 

The resulting build log may contain code review messages, for example:

Code Block
MSBUILD : warning CA1060: Microsoft.Design : Because it is a P/Invoke method, 'basForm.GetWindowPlacement(int, ref basForm.WINDOWPLACEMENT)' 
  should be defined in a class named NativeMethods, SafeNativeMethods, or UnsafeNativeMethods. 
  [C:\gmClients\Client\proj\deploy\App\Sample.csproj]

This information will be captured in the .NET Build Log Report fields:

Code Block
Project Name        = Sample.vbp
Task Tag            = std
Dialect             = csh
Source Name         = MigName-App-std-csh.NETBld.log
Run Date            = 2017/09/16 10:20
Message Type        = warning
Tool                = CODEREV
Message Number      = CA1060
Message Text        = Because it is a P/Invoke method, 'basForm.GetWindowPlacement(int, ref basForm.WINDOWPLACEMENT)' should be defined in a class named NativeMethods, SafeNativeMethods, or UnsafeNativeMethods.
Generalized Text    = Microsoft.Design
Source File Name    = 
Source Task Type    = -
Source Text         = -
Source Record       = -
.NET Project Folder = 'C:\gmClients\Client\proj\deploy\App'
Build Order         = _0001

...