Quick Search
Browse
Pages
Blog
Labels
Attachments
Mail
Advanced
What’s New
Space Directory
Feed Builder
Keyboard Shortcuts
Confluence Gadgets
Log In
Sign Up
Dashboard
Sonar
Copy Page
You are not logged in. Any changes you make will be marked as
anonymous
. You may want to
Log In
if you already have an account. You can also
Sign Up
for a new account.
This page is being edited by
.
Paragraph
Paragraph
Heading 1
Heading 2
Heading 3
Heading 4
Heading 5
Heading 6
Preformatted
Quote
Bold
Italic
Underline
More colours
Strikethrough
Subscript
Superscript
Monospace
Clear Formatting
Bullet list
Numbered list
Outdent
Indent
Align left
Align center
Align right
Link
Table
Insert
Insert Content
Image
Link
Attachment
Symbol
Emoticon
Wiki Markup
Horizontal rule
tinymce.confluence.insert_menu.macro_desc
Info
JIRA Issue
Status
Gallery
Tasklist
Table of Contents
Other Macros
Page Layout
No Layout
Two column (simple)
Two column (simple, left sidebar)
Two column (simple, right sidebar)
Three column (simple)
Two column
Two column (left sidebar)
Two column (right sidebar)
Three column
Three column (left and right sidebars)
Undo
Redo
Find/Replace
Keyboard Shortcuts Help
<table class="wysiwyg-macro" data-macro-name="info" data-macro-parameters="icon=false|title=Table of Contents" style="background-image: url(/plugins/servlet/confluence/placeholder/macro-heading?definition=e2luZm86aWNvbj1mYWxzZXx0aXRsZT1UYWJsZSBvZiBDb250ZW50c30&locale=en_GB&version=2); background-repeat: no-repeat;" data-macro-body-type="RICH_TEXT"><tr><td class="wysiwyg-macro-body"><img class="editor-inline-macro" src="/plugins/servlet/confluence/placeholder/macro?definition=e3RvY30&locale=en_GB&version=2" data-macro-name="toc"></td></tr></table><h1>General Questions</h1><h2>What is the difference between the Sonar .NET Plugins (up to version 0.6) and the Sonar C# Plugins Ecosystem (from version 1.0)?</h2><p>Historically, the support for the C# language was created under the ".NET Plugins" name, from version 0.1 to latest 0.6 released in June 2011.<br /> In the mean time, a complete rewrite of those plugins started in late 2010 in order to make C# a first-class language in Sonar. This not only involved upgrading the plugins to the latest APIs and Sonar development best-practices, but also making evolutions on the core of the Sonar platform itself to support new needs that the Java world had not brought before. <br /> The set of plugins was rebranded "C# Plugins Ecosystem" to highlight the enhanced support of the C# language <em>(C# being just one of several languages running on top of the .NET platform)</em>.</p><p>The main differences between those 2 sets of Sonar plugins are:</p><ul><li><strong>Home-made C# parser</strong>: no need to install SourceMonitor anymore, all the metrics are computed by the brand-new Sonar C# Core plugin. This opens lots of possibilities for the future, like being able to create our own C# rules.</li><li><strong>Better support of copy-paste detection</strong>, based on the new C# parser</li><li><strong>Maven is no more required for execution</strong>: assuming that you're solution has been compiled, you can run a Sonar analysis just with the <a class="confluence-link" href="/display/SONAR/Analyzing+with+Sonar+Runner" data-linked-resource-id="192872482" data-linked-resource-type="page" data-linked-resource-default-alias="Analyzing with Sonar Runner" data-base-url="http://docs.codehaus.org">Sonar Runner</a></li><li><strong>Java 6 is no more required for execution</strong>: the plugins run fine on a Java 5 VM</li><li><strong>Native support of Sonar way to handle multi-module</strong>: a .NET solution that contains C# projects will be considered like a standard root project with modules in Sonar. Each tool such as FxCop, StyleCop or Mono Gendarme will be run on each of these Visual Studio projects. With the dotnet plugin version 0.6, except for Gendarme, tools were launched only once for a whole Visual Studio solution.</li></ul><p>Unlike the former dotnet plugins, the Sonar C# plugins do not provide features such as compilation or packaging. These plugins are focused on their job : code quality analysis. That being said for compilation/packaging. You can still use whatever solution best feet your needs such as MsBuild scripts, Nant scripts or the <a href="http://maven-dotnet-plugin.appspot.com/">maven-dotnet-plugin</a> if you are familiar with maven.</p><table class="wysiwyg-macro" data-macro-name="tip" data-macro-parameters="title=To remember" style="background-image: url(/plugins/servlet/confluence/placeholder/macro-heading?definition=e3RpcDp0aXRsZT1UbyByZW1lbWJlcn0&locale=en_GB&version=2); background-repeat: no-repeat;" data-macro-body-type="RICH_TEXT"><tr><td class="wysiwyg-macro-body"><p>The C# Plugins Ecosystem is not just an evolution of the .NET plugins, it is a complete rewrite and thus introduces many changes. If you were a .NET plugins user before, we advice you to read the <a class="confluence-link" href="#How should I migrate from the .NET Plugins 0.6 to the new C# Plugins Ecosystem 1.0, and what will change?" data-anchor="How should I migrate from the .NET Plugins 0.6 to the new C# Plugins Ecosystem 1.0, and what will change?" data-linked-resource-default-alias="How should I migrate from the .NET Plugins 0.6 to the new C# Plugins Ecosystem 1.0, and what will change?" data-base-url="http://docs.codehaus.org">notes below about the migration process</a>.</p></td></tr></table><h2>How should I migrate from the .NET Plugins 0.6 to the new C# Plugins Ecosystem 1.0, and what will change?</h2><p>We tried to ensure backward compatibility at configuration level as much as possible, so the migration process should be pretty simple: remove the .NET plugins and add the new C# ones.<br /> If you where using the dotnet plugins, your maven configuration files do not need to change at all and can be reused with the new C# plugin. There is just a tiny exception to the previous sentence, if you use NCover for test coverage. See below for details...</p><p>Below a list of things to consider when migrating :</p><ol><li><strong>Gallio is not embedded anymore</strong>. Dotnet plugins version 0.6 comes with an embedded version of Gallio. This is not the case of the C# Gallio plugin which needs Gallio installed on the boxes where the analysis will be performed.</li><li><strong>NCover is not activated the same way</strong> using property "useNCover". Instead you need to set property "sonar.gallio.coverage.tool" to "NCover".</li></ol><p>So far we have seen only those two points. We'll enhance this section as we get feedback from users.</p><table class="wysiwyg-macro" data-macro-name="note" data-macro-parameters="title=What will changes once the migration is done?" style="background-image: url(/plugins/servlet/confluence/placeholder/macro-heading?definition=e25vdGU6dGl0bGU9V2hhdCB3aWxsIGNoYW5nZXMgb25jZSB0aGUgbWlncmF0aW9uIGlzIGRvbmU_fQ&locale=en_GB&version=2); background-repeat: no-repeat;" data-macro-body-type="RICH_TEXT"><tr><td class="wysiwyg-macro-body"><p>Size & complexity metrics are now computed by the C# Core Plugin, so they will definitely change (results will better reflect the reality, hopefully). As a consequence, this will also have impacts on some other metrics, like the rule compliance for instance.</p></td></tr></table><h2>Do I really need Java in order to analyse my C# projects ?</h2><p>Actually you do not !<br />The analysis can be triggered either by the Sonar Runner or by maven. Both are Java programs so what is the trick? The Sonar Runner works fine with <a href="http://www.ikvm.net/">IKVM</a>. IKVM is a very nice open source project which implements java in .net. If you want to try it with the Sonar Runner, you just need to edit the script sonar-runner.bat and replace the call to java by a call to IKVM:</p><table class="wysiwyg-macro" data-macro-name="code" style="background-image: url(/plugins/servlet/confluence/placeholder/macro-heading?definition=e2NvZGV9&locale=en_GB&version=2); background-repeat: no-repeat;" data-macro-body-type="PLAIN_TEXT"><tr><td class="wysiwyg-macro-body"><pre>rem "%JAVA_HOME%\bin\java.exe" %SONAR_RUNNER_OPTS% -classpath "%SONAR_RUNNER_HOME%\lib\sonar-runner.jar";"%SONAR_RUNNER_HOME%\lib\sonar-batch-bootstrapper.jar" "-Drunner.home=%SONAR_RUNNER_HOME%" "-Dproject.home=%PROJECT_HOME%" org.sonar.runner.Main %* PATH_TO_IKVM\ikvm.exe %SONAR_RUNNER_OPTS% -classpath "%SONAR_RUNNER_HOME%\lib\sonar-runner.jar";"%SONAR_RUNNER_HOME%\lib\sonar-batch-bootstrapper.jar" "-Drunner.home=%SONAR_RUNNER_HOME%" "-Dproject.home=%PROJECT_HOME%" org.sonar.runner.Main %*</pre></td></tr></table><p>In place of java, a .net process will be used. IKVM will recompiled on the fly the java jars used for the analysis to .net dll files. The recompilation will slow down significantly the analysis. IKVM could be used to transform jar files to dll files prior to any execution (using ikvmc). The problem is that the sonar runner downloads plugins jar files at the beginning of the analysis from the target sonar server instance. Hence we cannot pre compiled all the jars files needed to run an analysis without changing the way the runner works. <br />Right now it is not very useful to use IKVM with the sonar runner. However, this looks very promising for a future Visual Studio integration <img class="emoticon emoticon-wink" data-emoticon-name="wink" border="0" src="/s/en_GB/3278/15/_/images/icons/emoticons/wink.png" alt="(wink)" title="(wink)" /></p><h2>How can I exclude a project from the analysis of a .NET solution?</h2><p>You can do so using the standard "sonar.skippedModules" property (see <a class="confluence-link" href="/display/SONAR/Analysis+Parameters" data-linked-resource-id="113541435" data-linked-resource-type="page" data-linked-resource-default-alias="Analysis Parameters" data-base-url="http://docs.codehaus.org">Analysis Parameters</a> page for Sonar properties): it is a comma-separated list of project names. The names that you must use here are the identifiers that you can find in the .SLN file: the identifier is the first string you can find right after the equals sign on a project definition. </p><p>For instance, on the following SLN file excerpt, you would use "FooProject":</p><table class="wysiwyg-macro" data-macro-name="code" style="background-image: url(/plugins/servlet/confluence/placeholder/macro-heading?definition=e2NvZGV9&locale=en_GB&version=2); background-repeat: no-repeat;" data-macro-body-type="PLAIN_TEXT"><tr><td class="wysiwyg-macro-body"><pre>Project("{E24C65DC-7377-472B-9ABA-BC803B73C61A}") = "FooProject", "FooProject", "{59BECB8B-A7E3-4823-9CE6-584D0D1755EE}"</pre></td></tr></table><h1>Sonar C# Parser</h1><h2>What are the current limitations?</h2><p>Currently, the SonarSource C# parser has the following limitations:</p><ul><li>Pre-processing directives are not supported</li><li>Parsing errors may occur with the '?' operator in specific circumstances (e.g. <a class="external-link" href="http://old.nabble.com/Problem-with-C--Squid-sensor-tt32091064.html#a32091064" rel="nofollow">http://old.nabble.com/Problem-with-C--Squid-sensor-tt32091064.html#a32091064</a>)</li></ul><h1>Rules</h1><h2>How can I use FxCop with Visual Studio Static Analysis rules in sonar?</h2><p>Check out <a href="https://github.com/vladonemo/SonarFxCopRulesGenerator">this page</a>, where everything is explained.</p><h1>Tests and code coverage</h1><h2>How can I run Gallio and PartCover on a 64-bits Windows?</h2><p>Gallio and PartCover work perfectly out-of-the-box on x86 Windows, but not on 64-bits versions of this OS. To make them work correctly, here's what you have to do:</p><ol><li>Download the latest Gallio x64 installer (<a class="external-link" href="http://www.gallio.org/Downloads.aspx" rel="nofollow">http://www.gallio.org/Downloads.aspx</a>) and install it in a folder not under "Program Files"</li><li>Download the latest PartCover installer (<a class="external-link" href="https://github.com/sawilde/partcover.net4" rel="nofollow">https://github.com/sawilde/partcover.net4</a>, click on Downloads) and install it in a folder not under "Program Files"</li><li><p>Run "corflags.exe" on Gallio and PartCover executables:</p><table class="wysiwyg-macro" data-macro-name="code" style="background-image: url(/plugins/servlet/confluence/placeholder/macro-heading?definition=e2NvZGV9&locale=en_GB&version=2); background-repeat: no-repeat;" data-macro-body-type="PLAIN_TEXT"><tr><td class="wysiwyg-macro-body"><pre>## go into PartCover folder corflags /32bit+ /force PartCover.exe corflags /32bit+ /force PartCover.Browser.exe ## go into Gallio bin folder corflags /32bit+ /force Gallio.Echo.exe </pre></td></tr></table></li></ol><p><em>(Source: <a href="http://www.planetgeek.ch/2009/10/15/get-partcover-running-on-x64-windows/">http://www.planetgeek.ch/2009/10/15/get-partcover-running-on-x64-windows/</a>)</em></p><p><em><br /></em></p><h2>How can I run integration tests ?</h2><table class="wysiwyg-macro" data-macro-name="note" style="background-image: url(/plugins/servlet/confluence/placeholder/macro-heading?definition=e25vdGV9&locale=en_GB&version=2); background-repeat: no-repeat;" data-macro-body-type="RICH_TEXT"><tr><td class="wysiwyg-macro-body"><p>Available since version 1.3 of the C# plugins</p></td></tr></table><p>Integration testing is activated using property <strong>sonar.gallio.it.mode </strong>:</p><table class="wysiwyg-macro" data-macro-name="code" style="background-image: url(/plugins/servlet/confluence/placeholder/macro-heading?definition=e2NvZGV9&locale=en_GB&version=2); background-repeat: no-repeat;" data-macro-body-type="PLAIN_TEXT"><tr><td class="wysiwyg-macro-body"><pre>sonar.gallio.it.mode=active </pre></td></tr></table><p>Integration tests must be part of the analysed solution. They can either be located in dedicated projects or located in regular test projects, next to unit tests. <br />If there are located in dedicated projects, theses projects need to be specified using property <strong>sonar.dotnet.visualstudio.itProjectPattern</strong>. Below an example :</p><table class="wysiwyg-macro" data-macro-name="code" style="background-image: url(/plugins/servlet/confluence/placeholder/macro-heading?definition=e2NvZGV9&locale=en_GB&version=2); background-repeat: no-repeat;" data-macro-body-type="PLAIN_TEXT"><tr><td class="wysiwyg-macro-body"><pre>sonar.dotnet.visualstudio.itProjectPattern=*.IntegTest </pre></td></tr></table><p>If integration tests are next to unit tests, in the same projects, you need to specify to sonar which ones are unit tests and which ones are integration tests. Gallio filters comes to the rescue : </p><table class="wysiwyg-macro" data-macro-name="code" style="background-image: url(/plugins/servlet/confluence/placeholder/macro-heading?definition=e2NvZGV9&locale=en_GB&version=2); background-repeat: no-repeat;" data-macro-body-type="PLAIN_TEXT"><tr><td class="wysiwyg-macro-body"><pre>sonar.gallio.filter=CategoryName:unit sonar.gallio.it.filter=CategoryName:selenium </pre></td></tr></table><p>With the preceding configuration fragment, all test cases annotated "unit" (i.e.<em> [Category("unit")]</em>) are considered to be unit test cases whereas test cases annotated "selenium" (i.e. <em>[Category("selenium")]</em>) are considered to be integration test cases.</p><h1>Compatibility with other plugins</h1><h2>SCM Activity plugin</h2><p>The C# Plugins Ecosystem is compatible with the SCM Activity plugin, provided that you have specified the "sonar.scm.url" property in your POM or "sonar-project.properties" file. For instance:</p><table class="wysiwyg-macro" data-macro-name="code" style="background-image: url(/plugins/servlet/confluence/placeholder/macro-heading?definition=e2NvZGV9&locale=en_GB&version=2); background-repeat: no-repeat;" data-macro-body-type="PLAIN_TEXT"><tr><td class="wysiwyg-macro-body"><pre>sonar.scm.url=scm:svn:http://my.svn.server/my-repo/trunk/my-project </pre></td></tr></table><h2>Other plugins</h2><p>Those plugins have been reported as compatible with the C# Plugins Ecosystem:</p><ul><li>Build stability</li><li>Timeline</li><li>Radiator</li><li>Sqale</li><li>Views</li></ul><h1>Integration of Sonar with Other Environments</h1><h2>How can I integrate Sonar in my existing TFS Build environment processes?</h2><p>Most people want to add Sonar as an additional step in existing processes, which usually brings a lot of troubles because those processes manipulate the generated artifacts (assemblies) - whereas Sonar C# Plugins rely best on information found in the source files (mostly CSPROJ config files).</p><p>Generally speaking, it's best / easier to set up a separate "continuous inspection" process that just:</p><ol><li>compiles the solution</li><li>runs a Sonar analysis</li></ol><p>, in order to keep the Sonar-related configuration as simple as possible.</p><p>You can read <a href="http://sonar.15.n6.nabble.com/Gendarme-FXCop-Prerequisites-tp4942146p4946759.html">this thread</a> to see how this has been achieved by C# plugin users.</p>
Please type the word appearing in the picture.
Attachments
Labels
Location
Watch this page
< Edit
Preview >
Loading…
Save
Cancel
Next hint
search
attachments
weblink
advanced