Dec 11, 2011

FxCop Integrator 3.0.0 Preview 1 Released

In Dec 11 2011, I released FxCop Integrator 3.0.0 Preview 1.

 

This release can be installed in VS11 Developer Preview.

So you can use same features as FxCop Integrator 2.0.0 RTW on VS11 Develop Preview.

 

FxCop Integrator 3.0.0 Preview 1 is available here.

Dec 5, 2011

FxCop Integrator 2.0.0 RTW Released

In Dec 4 2011, I released FxCop Integrator 2.0.0 RTW.

 

This release contains following new features:

  • Supported calculating code metrics with Code Metrics PowerTool.
  • Provided MSBuild tasks.
  • Supported to filter out auto-generated code from code analysis result.
  • Supported exporting report of code analysis result.
  • Supported multi-project analysis.
  • Supported file level analysis.
  • Added the feature to let developers more easily add a "SuppressMessage" tag into the code.

And also it contains many improvements and bug fixes.

 

FxCop Integrator 2.0.0 RTW is available here.

Nov 28, 2011

FxCop Integrator 2.0.0 RC Released

In Nov 27 2011, I released FxCop Integrator 2.0.0 RC. You can download it from CodePlex project site.

The 2.0.0 RC contains following new features.

 

 

Provides MSBuild tasks

I implemented MSBuild custom tasks to execute code inspection and code metrics calculation. These MSBuild tasks work the same as FxCop Integrator’s on-demand execution.

You can install MSBuild tasks with the msi installer not VSIX. So, you can install them to the machine that doesn’t have Visual Studio (e.g. CI server).

 

The MSBuild tasks installer creates %PROGRAMFILES%\MSBuild\FxCop Integrator\FxCopIntegrator.targets. When you add

<Import Project="$(PROGRAMFILES)\MSBuild\FxCop Integrator\FxCopIntegrator.targets" />

to the project file and specify

/p:FxCopCmdPath=”the path of FxCopCmd.exe” /p:EnableCodeInspectionOnBuild=true

as MSBuild command line parameter, MSBuild executes code inspection after build.

FYI, when you specify following command line parameter, MSBuild executes code metrics calculation after build.

/p:MetricsPath=”the path of Metrics.exe” /p:EnableCodeMetricsCalculationOnBuild=true

 

The internal specification of the “Code Analysis on Build” feature was changed.

In 2.0.0 Beta 2 or before, the specification of this feature is

  1. When the FxCop Integrator extension is loaded, it generates “CodeAnalysis.exe” that can analyze code the same as FxCop Integrator’s on-demand execution.
  2. When user enable '”Code Analysis on Build”, FxCop Integrator changes a project file to add the Exec MSBuild task to execute CodeAnalysis.exe into the “AfterBuild” target.

But 2.0.0 RC or later,

  1. When user install FxCop Integrator MSBuild tasks and enable “Code Inspection on Build”, FxCop Integrator changes a project file to import the above targets file and to add the EnableCodeInspectionOnBuild property.

For backward compatibility, you can still use the old style “Code Analysis on Build” feature, but it will be deprecated in the future release.

 

 

Warning Filtering Feature

I implemented the warning filtering feature to filter out warnings against the code that is defined in a designer file or an auto-generated file.

You can define filtering patterns with the code analysis configuration editor.

 

image

 

By default, FxCop Integrator defines filtering patterns to filter out designer code (e.g. *.Designer.cs, etc) and auto-generated code (e.g. *.generated.cs, *.g.cs, etc).

Nov 13, 2011

FxCop Integrator 2.0.0 Beta 2 Released

In Nov 11 2011, I released FxCop Integrator 2.0.0 Beta 2. You can download it from CodePlex project site.

FxCop Integrator is a Visual Studio 2010 extension that integrates FxCop to VS2010 and makes it easy to execute FxCop like VS2010 Premium/Ultimate. It also supports to filter code analysis results and shows the FxCop rule detail.

Version 2.0.0 supports to execute Metrics.exe (Visual Studio Code Metrics Power Tools 10.0) and provides some new features.

 

 

Visual Studio Code Metrics Power Tools 10.0 Integration

FxCop Integrator 2.0.0 supports to integrate Visual Studio Code Metrics Power Tools 10.0. You can easily execute Metrics.exe on the Solution Explorer.

support_code_metrics_thumb[7]

 

When you execute code metrics calculation, FxCop Integrator shows calculation result as below.

image_thumb[22]

 

Because FxCop Integrator supports FxCop and Metrics, I added some menus for executing code analysis.

  • [Code Analysis] : Execute both FxCop and Metrics.
  • [More Tasks…] > [Inspect XXX] : Execute FxCop only. 
  • [More Tasks…] > [Calculate Metrics] : Execute Metrics only.

 

But if you don’t want to use Metrics, you can change the [Code Analysis] menu behavior from option page.

image_thumb[7]

 

 

Multi-Project Analysis, File Level Analysis

FxCop Integrator 1.X only supported to analyze all projects in a solution or a single project. But 2.0.0 supports to analyze selected multi-project.

image_thumb[10]

 

Also you can analyze only some types that are defined in the specified file. This feature can be used when the language of source code is C# or VB.NET. And, this doesn’t support code metrics calculation.

image_thumb[13]

 

 

Message Suppression

The Suppress Message is added in the Rule Detail window to let developers more easily add a “SuppressMessage” attribute into the code.

image_thumb[16]

 

 

Export Code Analysis Result

The [Export] menu is added in the Code Inspection Result window and the Code Metrics Calculation Result window. You can export code analysis result as CSV.

image_thumb[19]

 

 

And more improvements and bug fixes.

 

I’ll release FxCop Integrator 2.0.0 RTW in late November or early December.

May 8, 2011

FxCop Integrator 1.4.0 Planned Feature Set

After I released FxCop Integrator 1.3.0 on Apr 24 2011, I received some bug reports. The cause of them is the "Code Analysis on Build" feature that is implemented in 1.3.0. I don't know why, but event handlers of Visual Studio build events, are used by this feature, don't work in VS2010 SP1. So I immediately released 1.3.0p1 that is disabled this feature.

In 1.4.0, I'll enable the "Code Analysis on Build" feature again. I plan to implement it with a different way, thus it should be able to be used on VS2010 SP1.


I also plan to implement following features,

Enable customization of data grid of code analysis result window. I'll enable data grid of code analysis result window to sort, show/hide columns and persistent column settings.

More useful error report window. I'll add the error report window that makes it easy to send feedback.


I'll release FxCop Integrator 1.4.0 in May 22 2011.

May 5, 2011

FxCop Integrator 1.3.0p1 Released

I've released FxCop Integrator 1.3.0p1.

In this release, I temporarily disabled the "Code Analysis on Build" feature that is implemented in ver1.3.0, because I realized that events of EnvDTE.BuildEventsClass don't raised on VS2010 SP1(*). "Code Analysis on Build" depends to their events, so I had no choice but to disable it. I'll enable this feature in the future release if I can find out a workaround.
This version is also improved performance and fixed some bugs.


* I sent a feedback about this problem to Microsoft Connect.

May 4, 2011

How to store/restore UI state of Visual Studio tool window pane


A tool window pane of Visual Studio is a class that inherits from Microsoft.VisualStudio.Shell.ToolWindowPane. We can create a sub classes of this to add custom a tool window pane to our VSPackage.

ToolWindowPane class has overridable SaveUIState and LoadUIState methods. It seems that we can use them to store/restore UI state of tool window pane, but thier methods are never called. According to this thread, it looks like their methods are only called on document windows not tool window panes.

Instead of SaveUIState and LoadUIState, we can use OnCreate and OnClose methods. Just like the name implies, OnCreate is called when a tool window pane is created, and OnClose is called when a tool window pane is closed. So if we override them, we can implement the feature to store/restore UI state.

For example, we can store UI state to xml file and restore UI state from xml file like this.

public CustomToolWindowPane : ToolWindowPane
{
    private string path;

    public CustomToolWindowPane()
    {
        ...
        var directory = Path.GetDirectoryName(typeof(CustomToolWindowPane).Assembly.Location);
        path = Path.Combine(directory, "uistate.xml");
    }

    protected override void OnCreate()
    {
        using (var stream = File.Open(path, FileMode.Open))
        {
            var serializer = new XmlSerializer(typeof(UIState));
            var state = (UIState)serializer.Deserialize(stream);
            ApplyUIState(state);
        }
    }

    private void ApplyUIState(UIState state)
    {
        ...
    }

    protected override void OnClose()
    {
        var state = BuildUpUIState();
        using (var stream = File.Open(path, FileMode.Create))
        {
            var serializer = new XmlSerializer(typeof(UIState));
            serializer.Serialize(stream, state);
        }
    }

    private UIState BuildUpUIState()
    {
        ...
    }


    public class UIState
    {
        ...
    }
}

Apr 25, 2011

FxCop Integrator 1.3.0 Released

I've just released FxCop Integrator 1.3.0 in Apr 24 2011. This version contains new features: "Code Analysis on Build" and "FxCop Dictionary Support". I also fixed some bugs.

FxCop Integrator 1.3.0 available here. Please try it and send me to feedback.

Apr 4, 2011

FxCop Integrator 1.3.0 Planned Feature Set


After I released FxCop Integrator 1.2.0, I got some bug reports and suggestion of new features from users. I'll fix and implement them as possible.

The following are planned features of FxCop Integrator 1.3.0.


Code Analysis on Build
This is like "Code Analysis on Build" of Visual Studio 2010 Ultimate or Premium.
This feature allow you to perform code analysis automatically when you build a project. And you can select whether or not FxCop Integrator should break build if code analysis result has error.

Code Analysis Configuration Editor of ver1.3.0


FxCop Dictionary Support
FxCop contains some naming rules and supports "Custom Dictionary" to allow you to customize them. Ver1.3.0 will support to pass a dictionary file to FxCop. In addition, ver1.3.0 will contain FxCop dictionary editor.

FxCop Dictionary Editor of ver1.3.0


Silverlight Project Support
Ver1.2.0 couldn't analyze a Silverlight project. Because silverlight assemblies are located in %PROGRAMFILES%\Reference Assemblies\Microsoft\Framework\Silverlight\vx.x not GAC and FxCop Integrator cound't specify reference assemblies to FxCop.
This problem will be solved in ver1.3.0.


FxCop 1.36 Support
Now I'm implementing the parser of FxCop 1.36 analysis report. The next version of FxCop Integrator will support to analyze with FxCop 1.36.


Custom Ruleset Selection
The code analysis configuration editor of ver1.3.0 will support to select a ruleset file that is located in any folder.

Feb 26, 2011

How to test behavior of a killed Android application

Background
The Android application doesn't always continue to run in same process. When an user run your application and others same time, and one of other applications requires more memory, then there is a possibility that the process of your application is killed. Later, your application are started in a new process and activities are recreated when the user re-launch your application.
But the user doesn't know your application process was killed. So, your application should be shown the same as before. To resume the state of last time, you need to implement and test storing/restoring application data.

But how can we easily test that situation?

This post explains how to test behavior of a killed Android application with Android emulator.


Testing behavior of a killed Android application
The most easy way to test, launch your application, show any activity and rotate emulator with Ctrl+F11 or Ctrl+F12.
When an Android device is rotated, activities are recreated. This is the same situation as Android application is killed and restartd.

But, if you prevent rotation your activity, you can't use above technique.
In this case, first, launch your application, show any activity and back to home with Home button or launch another application.

Next, kill your application process with ddms or adb (that is the same situation as Android kills your application to collect memory).
If you want to use ddms (or Eclipse ddms perspective), select process which you want to kill and push stop button.
Kill any process with DDMS perspective of Eclipse

If you want to use adb,
  1. launch "adb shell".
  2. find PID of the process which you want to kill with "ps"
  3. execute "kill PID"

Finally, re-launch your application. Android starts it in new process and recreate your activity.

Jan 24, 2011

How To Use VS2010 Code Analysis Rules and Localization Resources in FxCop 10.0

I learned VS2010 Pro contains static code analysis rules and the stand-alone FxCop 10.0 can use them (thanks @Pedro).

By default, VS2010 code analysis rules were installed in %PROGRAMFILES%\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\FxCop\Rules. If you copy assemblies in this directory to FxCop Rules directory (%PROGRAMFILES%\Microsoft FxCop 10.0\Rules by default), FxCop can detect VS2010 code analysis rules.

But, what good is it?

The stand-alone FxCop doesn't contain Maintainability and Reliability rules. Thus, this technique allows you to use them in FxCop.

Additionally, localization resources are also contained in %PROGRAMFILES%\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\FxCop. For example, VS2010 Pro Japanese Edition has ja directory in the above directory. If you copy this one to FxCop Rules directory, you can localize rule list of FxCop GUI and FxCopCmd output messages.

Localized FxCop GUI


FxCop Integrator 1.2.0 Released: Support Code Analysis Behavior Customization

I've just released FxCop Integrator 1.2.0. It supports code analysis behavior customization so that an user can specify RuleSet and some FxCopCmd options.

FxCop Integrator 1.2.0 is available here.

Summary of New Feature
Now FxCop Integrator shows [Edit Code Analysis Configuration] in  a context menu of Solution or Project.
A new context menu [Edit Code Analysis Configuration]

When you select this one, FxCop Integrator opens Code Analysis Configuration Editor window. In this window, you can specify following options:

  1. Whether or not analyzing code of a project
  2. Whether or not searching GAC for missing reference assemblies
  3. Whether or not suppressing analysis results against generated code
  4. Timeout for analysis deadlock detection
  5. Whether or not analyzing code with RuleSet
Code Analysis Configuration Editor window

Do you notice that Code Analysis Configuration Editor has Override option?
FxCop Integrator supports Solution Configuration and Project Configuration. Solution Configuration is used to analyze all projects in the solution. Project Configuration is used to analyze the specific project. If Solution Configuration and Project Configuration set different value to an option, and checked its Override, FxCop Integrator overrides option value of Solution Configuration with Project Configuration's value.

Jan 8, 2011

Design of FxCop Integrator New Feature: Support Ruleset and Configuration

I'm designing "Code Analysis Configuration", a new feature of FxCop Integrator, to support Ruleset and code analysis behavior configuration.

It will provide the following features.

  • Enable/Disable rules with Ruleset
  • Set some FxCopCmd option
  • Apply configuration to all projects are contained a solution
  • Override configuration on a specific project
  • Visual Configuration Editor


Enable/Disable rules with Ruleset
Ruleset is a logical grouping of code analysis rules. You can enable/disable rules with Ruleset.
I'll support to analyze your code with a built-in ruleset or a custom ruleset.

Set some FxCopCmd option
I'll enable to change some FxCopCmd option (e.g. whether FxCop searchs GAC for missing assembly or not, weather FxCop analyzes auto-generated code or not, and so on).

Apply configuration to all projects are contained a solution
If you create a configuration file for a solution, FxCop Integrator will use it to analyze each project is contained the solution.

Override configuration on a specific project
You'll be able to override "solution configuration" on a specific project. For example,  you can use different Rulesets between "Common Feature Project" and "UI Project".

Visual Configuration Editor
I'll implement Visual Configuration Editor to be able to edit above configurations in Visual Studio IDE. The following image is a preview of Visual Configuration Editor.

Visual Configuration Editor Preview

FxCop Integrator 1.1.1 Released: Code Analysis Bug Fix

I've just released FxCop Integrator 1.1.1, it contians a code analysis bug fix related "Web Site" project. In this version, you can analyze a solution contains "Web Site" project.

FxCop Integrator 1.1.1 is available here.

And, I plan to release v1.2.0 in Jan 16 2011. This version will support Ruleset and changing some FxCop options. So you will be able to customize code analysis behavior.

First Post

test