Skip to content
| Marketplace
Sign in
Visual Studio>Tools>XAnalysis CTP
XAnalysis CTP

XAnalysis CTP

Doğu Tümerdem - outlook

|
693 installs
| (6) | Free
Customizable and Free Code Analysis Tool for Visual Studio 2012 with Roslyn.
Download

XAnalysis is a Visual Studio 2012 Extension, to help you to improve the code quality of your team. Using this tool you can add new analysis scripts, add them to your list, and let your developers to see the problems of theirs codes while they are typing. See http://www.dotnetcup.com for more details.

Roslyn is the new language service for Visual Studio 2012 bu it's still CTP. This tool developed using Roslyn CTP version 1.2.20906.2, and needs it on runtime.

To make Roslyn available, download and install it. Use /rootsuffix Roslyn parameter when you start Visual Studio 2012.

 

You can open window using VIEW/Other Windows/XAnalysis. This will open a control window for XAnalysis.



This window shows the list of the analysis scripts for which are loaded and active. The server URL is the common site that your team can download scripts. By default I implemented some of the code analysis rules for you and those might be samples while you will write you owns. The default site ishttp://www.dotnetcup.com/AnalysisScripts. Soon I’ll develop a site to share your own scripts with the rest of the world or discuss on them.

The next combo contains some commands that can be run. On the result screen you can see the results for your action. For example, if an error occurs while compilation, you can see the error on this window.

 

How it works:
Roslyn has a new approach called “Compiler as a Service”. This helps us to compile C# scripts as a service. Xanalysis uses this feature, to run your analysis scripts while you are typing your code. When you download a script, Xanalysis writes them to “Documents\XAnalysis Scripts” folder. XAnalysis uses this folder to write you logs and custom assemblies to be used in your scripts.
Every things starts with ScriptLoader.csx script file. This file has a method defined as lambda expression with name Load.

Load = () =>
{
}

The containing class exposes some methods to load you scripts and custom DLLs. To register your scripts you can use Register method. Which has the following signature:

Register(string scriptFilename, string code = null, string description = "", bool enabled = true)

Example:
Register(@"Class Naming.csx", "N1001", "Checks the naming convension of class declaration identifiers.");


First parameter is the filename of the script. Second parameter is an arbitrary code for this script. By using this code you can use SuppressMessageAttribute to suppres this analysis script. To do this, you don’t need to writer no line of code, this will be managed at the background. The third parameter is the description for this script, that your team can see on the management panel of XAnalysis.
To register a dll, that you want to use in you analysis script, you can use RegisterReference method which has the following signature:

RegisterReference(string referencePath)

Example:
RegisterReference("CodeQualityExtensions.dll");

This method will be register your assembly, that you can use in your scripts.
Everything starts with RegisterScript.csx. It check existence on your local documents folder, if it cannot find this file, it tries to download from the url written on the control panel. Hopefully it finds the file then it downloads. It loads it, compiles it and generates a list of script and assembly files. Then it start to download them. Then each scripts will be loaded, and starts to check your code while you’re typing. You can use “Open Local” command on the control panel to see the script on your local Documents folder.
The next step is the code analysis script format. It exposes a delegate which can be implemented using lambda expression as the following:

GetIssues = (IDocument document, CommonSyntaxNode node, CancellationToken cancellationToken) =>
{
 ...
}

For more information about the arguments types you need to see Roslyn web site. As I said it is still CTP, but it already exciting. When I’ll able to open the site dotnetcup.com you will be able to find different scripts there...

Your team’s own script site:
Easy, on an IIS, create a site and add a mime type for .csx extension as text/plain, then your will set the site as their URL, that all.

 

Suppressing Message:

For some reason you may need to suppress a warning. In this case you can use SuppressMessage attribute for class, method etc. To suppress a message, pass the code value that you provided in Register method, as first parameter to attribute constructor.

 

You can contact me at dogu.tumerdem@gmail.com. Please send your feedback and consider that it is still CTP and stays CTP until Roslyn will be released.

 

  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
© 2025 Microsoft