Mike's profileFreeToDevBlogLists Tools Help

Blog


    May 26

    Integrate Microsoft C# Source Analysis with TFS

    UPDATE - 15 October 2008 : Please see MSBuild Extension Pack for the StyleCop task.

    UPDATE - 20 July 2008: This task is now available again. This task works with Source Analysis 4.2. A version for StyleCop 4.3 will be made available in the FreeToDev MSBuild Tasks Suite soon...

    The FTDSourceAnalysis MSBuild task (download here) provides a mechanism for scanning C# files for Source Analysis violations based on a collection of files, rather than the MSBuild integration offered by the tasks provided with the  Source Analysis install (which scans @(Compile) items).

    To use this task, place the FTDSourceAnalysis.dll file in C:\Program Files\MSBuild\Microsoft\SourceAnalysis\v4.2

    Sample

    <Project DefaultTargets="Default" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
        <UsingTask AssemblyFile="C:\Program Files\MSBuild\Microsoft\SourceAnalysis\v4.2\FTDSourceAnalysis.dll" TaskName="FTDSourceAnalysis"/>
        <Target Name="Default">
    <!-- Create a collection of files to scan -->
            <CreateItem Include="C:\SomeFiles\**\*.cs">
                <Output TaskParameter="Include" ItemName="SourceAnalysisFiles"/>
            </CreateItem>
            <!-- Run the FTDSourceAnalysis MSBuild task -->
            <FTDSourceAnalysis SourceFiles="@(SourceAnalysisFiles)" ShowOutput="true" ForceFullAnalysis="true" CacheResults="false" logFile="C:\FTDSALog.txt" SettingsFile="C:\Settings.SourceAnalysis">
                <Output TaskParameter="Succeeded" PropertyName="AllPassed"/>
                <Output TaskParameter="ViolationCount" PropertyName="Violations"/>
                <Output TaskParameter="FailedFiles" ItemName="Failures"/>
            </FTDSourceAnalysis>
            <Message Text="Succeeded: $(AllPassed), Violations: $(Violations)"/>
    <!--
        /// FailedFile format is:
        ///
        ///     <ItemGroup>
        ///     <FailedFile Include="filename">
        ///         <CheckId>SA Rule Number</CheckId>
        ///         <RuleDescription>Rule Description</RuleDescription>
        ///         <RuleName>Rule Name</RuleName>
        ///         <LineNumber>Line the violation appears on</LineNumber>
        ///         <Message>SA violation message</Message>
        ///     </FailedFile>
        ///  </ItemGroup>
    -->

            <Message Text="%(Failures.Identity) - Failed on Line %(Failures.LineNumber). %(Failures.CheckId): %(Failures.Message)"/>
        </Target>
    </Project>

    Sample Output

    Target Default:
        Performing Microsoft C# Source Analysis scan...
        Pass 1: FTDSourceAnalysis (2).cs...
        1 violations encountered.
        Succeeded: False, Violations: 1
        C:\SomeFiles\FTDSourceAnalysis (2).cs - Failed on Line 1. SA1638: The file attribute in the file header's copyright tag must contain the name of the file.

    This custom collection based scanning provides an easy way to scan various files as part of your TFS builds and flag any violations to the team.

    May 23

    Microsoft Source Analysis for C#

    Microsoft have finally released 'StyleCop' publicly! --- Details here

    May 21

    WMI Code Creator

    It's not new, but what a fantastic tool!

    "The WMI Code Creator tool allows you to generate VBScript, C#, and VB .NET code that uses WMI to complete a management task such as querying for management data, executing a method from a WMI class, or receiving event notifications using WMI."

    Overview

    The WMI Code Creator tool generates code that uses WMI to obtain management information or perform management tasks. You can use the tool to learn how to manage computers using WMI scripting and WMI .NET. The tool generates code that runs on the local computer, a remote computer, or a group of remote computers based on your selection from the Target Computer menu on the tool. You can also execute the generated code directly from the tool.
    The tool is meant to help IT Professionals quickly create management scripts and to help developers learn WMI scripting and WMI .NET. The tool helps take the complexity out of writing code that uses WMI and helps developers and IT Professionals understand how powerful and useful WMI can be for managing computers.
    Using the tool, you can query for management information such as the name and version of an operating system, how much free disk space is on a hard drive, or the state of a service. You can also use the tool to execute a method from a WMI class to perform a management task. For example, you can create code that executes the Create method of the Win32_Process class to create a new process such as Notepad or another executable. The tool also allows you to generate code to receive event notifications using WMI. For example, you can select to receive an event every time a process is started or stopped, or when a computer shuts down.
    The tool also allows you to browse through the available WMI namespaces and classes on the local computer to find their descriptions, properties, methods, and qualifiers.
    The code that creates the tool is also included in the download. The tool was created using WMI .NET, and the code for the tool can help developers understand how WMI .NET is used to create applications and manage information. Be sure to read the end-user license agreement that is included in the download.

    Download here

    May 17

    FreeToDev MSBuild Tasks Update

    UPDATE: 13 July 08 --- These tasks are now available in the FreeToDev MSBuild Tasks Suite

    A few minor updates

    • TFS SetBuildNumber - now accepts SetAssemblyVersion="bool". Set this to true if you would like the AssemblyVersion updated along with the AssemblyFileVersion
    • SetEnvironmentVariable - new task to set environment variables in MSBuild. Target can be Process | User | Machine

    e.g. <SetEnvironmentVariable Variable="$(MSBuildTest)" Val="ValAfter" Target="Process"/>

    Download Updated Tasks (FreeToDev.FrameworkTasks20 (2.08.0516.0)

    May 16

    LINQPad

    Untitled

    If you are looking at Getting Started with LINQ, you may want to download LINQPad

    "LINQPad supports everything in C# 3.0 and Framework 3.5:

    • LINQ to SQL 
    • LINQ to Objects
    • LINQ to XML

    LINQPad is also a great way to learn LINQ: it comes preloaded with 200 examples from the book, C# 3.0 in a Nutshell.

    And LINQPad is more than just a LINQ query tool: it's a code snippet IDE. Instantly execute any C# 3 or VB 9 expression or statement block!

    Best of all, LINQPad is free and needs no installation: just download and run.  The executable is only 2MB and is self-updating."

    T-SQL Static Analysis 2005 & 2008 --- Analysis and Review

    ScreenShot041

    In October 2007 I wrote a review on the T-SQL Static Analysis feature provided in the Visual Studio Team Edition for Database Professionals Power Tools. In February this year Microsoft released Version 2 of the Power Tools, Visual Studio® Team System 2008 Database Edition Power Tools (available here).

    For Static Analysis, Version 2 provides very little improvement over Version 1. I have updated my original review to include the changes provided with Version 2. I have also removed a star from both Rating and Potential as this product still suffers from three major problems:

    1. Inconsistent Error Reporting
    2. Minimal Documentation
    3. Too Few Rules

    I was hoping to put together a fresh review with lots to report on, however Version 2 has not delivered... Let's hope that V3 is better and not too far off... FTD

    Download Updated Review

    May 12

    T-SQL Static Analysis --- Analysis and Review

    UPDATE: 16 May 08 - This is available here.

    I'm working on a review for Version 2 and will update my original review soon... FTD