Full documentation for SonarQube has moved to a new location: http://docs.sonarqube.org/display/SONAR

Skip to end of metadata
Go to start of metadata

Introduction

Version 3.0 of the C# plugin is an almost complete rewrite of what was previously known as the ".NET ecosystem". This was required in order to support SonarQube 4.2, its multi-language feature, and to be able to offer a better user experience.

Despite the magnitude and scope of the changes, we tried to reduce the migration effort to a minimum.

What features have been dropped?

  • Execution of tests (through Gallio) - only the import of existing code coverage reports is now supported 
  • Architectural rules (NDeps) - no replacement
  • Gendarme, an abandoned rule engine with no release for over 3 years, support has been dropped
  • Path patterns such as "$(SolutionDir)", "$(ProjectName)", etc. are no longer supported. These properties were only required for advanced use cases, and shouldn't required now that the plugins are easier to use. The Analysis Bootstrapper for Visual Studio Projects plugin will feed the right values for most of the properties.

What features haven't yet been reimplemented?

  • The analysis of Web Sites projects is not yet supported (SONARVS-46). Note that Web Applications projects are still supported.
  • ReSharper custom rules (SONARPLUGINS-3693)

Do not use the update center

The update center does not yet support the removal of plugins from ecosystems.
You will need to remove all previously installed .NET plugins before installing the new ones, old ecosystem .NET 2.1 and new plugins are not compatible and can not be mixed.

New plugin organization

There no longer is any abstract .NET or C# "core" plugin. Instead, .NET is now supported by 4 plugins:

Language plugins:

These core plugins provide basic language functionality: metrics, basic rules, FxCop / Code Analysis rules, import of NCover, OpenCover and Visual Studio Coverage Xml reports, as well as Visual Studio Test Execution Results reports.

  • C#
  • VB.NET 

Additional plugins:

  • StyleCop - Adds the support of StyleCop. Requires C# to be installed
  • R# / ReSharper - Adds the support of R#. Requires either C# or VB.NET to be installed
  • Analysis Bootstrapper for Visual Studio Projects - Reduces the manual configuration required to launch a SonarQube analysis by extracting information directly from Visual Studio solution and project files

Before the update, use the "safe" key strategy.

Before this rewrite, the use of sonar.dotnet.key.generation.strategy=safe was optional. After this rewrite, it is automatic. If you were already using the safe strategy, you have nothing to do, and can safely skip the rest of this section. If you were not, please read on.

The new C# and VB.NET plugins use the safe strategy automatically. Analyzing an existing project that was not previously using the safe strategy with the new plugins will change the project's module keys, and therefore potentially lose some history. For the smoothest transition possible, we recommend that before you upgrade, you do the following for each affected project:

  • make a dummy copy of your project, change its name to something easily identifiable
  • set sonar.dotnet.key.generation.strategy=safe in your dummy project's properties
  • analyze the dummy project
  • update the real project's module keys to the keys that have been set for the dummy project.
  • delete the dummy project.

In order to allow you to do this migration incrementally, you can set the property "sonar.visualstudio.projectKeyStrategy" to "unsafe" on projects yet to be migrated.

Icon
This "sonar.visualstudio.projectKeyStrategy" should not be used in production, and is provided only as a way to migrate to the 3.0 version of the plugin. It can be removed at any point of time in the future.

FxCop issue mapping

FxCop reports its issues on bytecode.

When a *.pdb file is present alongside the assembly (.exe or .dll), FxCop is able to map files back to source files and lines. When that file is not present, by default the issue is reported only on a logical class or method name. In such cases, the old .NET ecosystem was able to map the logical class or method names found in the byte code back to the source. Unfortunately, the mapping wasn't always accurate. Therefore that feature has been dropped for now, but will be reimplemented SONARFXCOP-32.

With the new plugins, any analysis that includes FxCop rules will fail if the *.pdb file corresponding to the assembly is not found.

Support of Team Foundation Server builds

TFS builds, which output assemblies of all projects to a common folder, are supported by the Analysis Bootstrapper for Visual Studio Projects using the "sonar.visualstudio.outputPaths" property.

Excluding generated code

"sonar.dotnet.excludeGeneratedCode" was previously supported to ignore generated code.

The same behavior is now achieved by setting the standard exclusions property "sonar.exclusions" to "**/Reference.cs", "**/*.designer.cs", "**/*.Designer.cs" and "**/*.g.cs".

The lines / lines of code metric increased with the new plugin

The old .NET ecosystem has issues with supporting generic types. Those issues have been fixed. Therefore analysis with the new plugins can result in higher values for the lines and lines of code metrics, if generics were heavily used in the project. Additionally, the files metric also changed slightly.

Because of the increased accuracy of these basic metrics, you may notice a ripple effect through the other metrics that are derived using these numbers.

The issues metric decreased with the new plugin

The old .NET ecosystem allowed rules engines such as FxCop to report issues on the project level, without attaching them to specific files.

For instance, this drilldown from the old system shows a total of 116 major issues on 2 files, each having just 53 and 17 issues respectively.
So the "issues" metric is set to 116, but the sum of actual issues on the files is just 53 + 17 = 70.

The drilldown was broken whenever a rule with no attached file was selected.

The new behavior of the plugin is to not import such issues. The drilldown will now always work properly, but a decrease is the issue metric is to be expected.

Old versus new properties

The properties from the old .NET ecosystem that still apply are still supported in order to reduce the migration cost.

However, the support of these deprecated properties will eventually be removed, so you are strongly encouraged to update to use the newer equivalents  as soon as possible.

Deprecated properties are listed under "Deprecated" property tabs, in order to allow them to be unset.

In general, when both an deprecated property and its new replacement are specified, the deprecated one is used, in order to force them to be properly unset.

Old propertyStill supported?Replaced byDescription
sonar.fxcop.installDirectory

Yes, but deprecated

Not visible in the "Deprecated" property tabs

C#:
sonar.cs.fxcop.fxCopCmdPath

VB.NET:
sonar.vbnet.fxcop.fxCopCmdPath

Used when FxCop rules are enabled.

The new property should contain the full path to FxCopCmd.exe

Example: C:/Program Files/Microsoft Visual Studio 12.0/Team Tools/Static Analysis Tools/FxCop/FxCopCmd.exe

sonar.stylecop.installDirectoryYes, but deprecatedsonar.stylecop.styleCopDllPath

Used when StyleCop rules are enabled.

StyleCop is no longer embedded in the plugin, it now must be installed first.

The new property should contain the full path to StyleCop.dll

Example: C:/Program Files/StyleCop 4.7/StyleCop.dll

sonar.resharper.installDirectoryYes, but deprecatedsonar.resharper.inspectCodePath

Used when ReSharper rules are enabled.

The new property should contain the full path to inspectcode.exe

Example: C:/Program Files/jb-commandline-8.1.23.523/inspectcode.exe

sonar.ncover.installDirectoryNo

C#:
sonar.cs.ncover3.reportsPaths

VB.NET:
sonar.vbnet.ncover3.reportsPaths

NCover is no longer executed, only existing reports are imported.

The new property should contain the path to those existing reports.

Example: report1.nccov, report2.nccov

Used whenever the new property is set.

sonar.opencover.installDirectoryNo

C#:
sonar.cs.opencover.reportsPaths

VB.NET:
sonar.vbnet.opencover.reportsPaths

OpenCover is no longer executed, only existing reports are imported.

The new property should contain the path to those existing reports.

Example: report1.xml, report2.xml

Used whenever the new property is set.

Old propertyStill supported?Replaced byDescription
sonar.dotnet.2.0.sdk.directoryYes, but deprecatedsonar.stylecop.msBuildPath

Used when StyleCop are enabled in association with sonar.dotnet.version to locate which MsBuild.exe to invoke.

The new property should contain the full path to MsBuild.exe

Example: C:/Program Files/MSBuild/12.0/Bin/MsBuild.exe

sonar.dotnet.3.5.sdk.directoryYes, but deprecatedsonar.stylecop.msBuildPath

Used when StyleCop are enabled in association with sonar.dotnet.version to locate which MsBuild.exe to invoke.

The new property should contain the full path to MsBuild.exe

Example: C:/Program Files/MSBuild/12.0/Bin/MsBuild.exe

sonar.dotnet.4.0.sdk.directoryYes, but deprecatedsonar.stylecop.msBuildPath

Used when StyleCop are enabled in association with sonar.dotnet.version to locate which MsBuild.exe to invoke.

The new property should contain the full path to MsBuild.exe

Example: C:/Program Files/MSBuild/12.0/Bin/MsBuild.exe

sonar.dotnet.4.5.sdk.directoryYes, but deprecatedsonar.stylecop.msBuildPath

Used when StyleCop are enabled in association with sonar.dotnet.version to locate which MsBuild.exe to invoke.

The new property should contain the full path to MsBuild.exe

Example: C:/Program Files/MSBuild/12.0/Bin/MsBuild.exe

sonar.dotnet.versionYes, but deprecatedsonar.stylecop.msBuildPath

Used when StyleCop are enabled in association with sonar.dotnet.?.?.sdk.directory to locate which MsBuild.exe to invoke.

The new property should contain the full path to MsBuild.exe

Example: C:/Program Files/MSBuild/12.0/Bin/MsBuild.exe

Old propertyStill Supported?Replaced byDescription
sonar.dotnet.buildConfigurationYes, but deprecatedThe most recently built assembly is now picked

Used by the Analysis Bootstrapper for Visual Studio Projects to determine which assembly to pick.

The most recently build assembly is now automatically picked, unless this property is explicitly set.

Example: If the last build was a Release one, then the Release assembly will be analyzed

sonar.dotnet.buildPlatformYes, but deprecatedThe most recently built assembly is now picked

Used by the Analysis Bootstrapper for Visual Studio Projects to determine which assembly to pick.

The most recently build assembly is now automatically picked, unless this property is explicitly set.

Example: If the last build was a Release one, then the Release assembly will be analyzed

Old propertyStill Supported?Replaced byDescription
sonar.dotnet.assembliesNo

C#:
sonar.cs.fxcop.assembly 

VB.NET:
sonar.vbnet.fxcop.assembly 

The assemblies should be correctly guessed by the Visual Studio bootstrapper, which sets "sonar.cs.fxcop.assembly" and "sonar.vbnet.fxcop.assembly".

Also read about "sonar.visualstudio.outputPaths".

sonar.dotnet.test.assembliesNoNot Available

Formerly used by the Gallio plugin to determine which assembly to use to execute the tests.

Tests are no longer executed, only existing test reports can be imported, so this property is now of no use to the plugin.

sonar.fxcop.assemblyDependencyDirectoriesNo

C#:
sonar.cs.fxcop.directories 
sonar.cs.fxcop.references 

VB.NET:
sonar.vbnet.fxcop.directories
sonar.vbnet.fxcop.references 

Formerly used to pass additional assembly dependencies to FxCop for the analysis.

FxCop will by default look in the folder of the analysed assembly for additional dependencies.

FxCop is executed with the "/searchgac" flag, to also search the Global Assembly Cache.

This property could abused to support the Team Foundation Server usecase, where assemblies were moved to a common folder. See the TFS chapter for details.

Old propertyStill Supported?Replaced byDescription
sonar.dotnet.visualstudio.solution.fileYes, but deprecatedsonar.visualstudio.solutionThe new property behaves as the old one, and should be used for scenarios where there are multiple solution files in the folder of the project to be analyzed.
    
sonar.fxcop.timeoutMinutes

Yes, but deprecated

Not visible in the "Deprecated" property tabs

C#:
sonar.cs.fxcop.timeoutMinutes

VB.NET:
sonar.vbnet.fxcop.timeoutMinutes

 
sonar.stylecop.timeoutMinutesYes, fully supported This property is fully supported, and is not deprecated.
sonar.resharper.timeoutMinutesYes, fully supported This property is fully supported, and is not deprecated.
Old propertyStill Supported?Replaced byDescription
sonar.silverlight.3.mscorlib.locationNoNot AvailableFormerly used by the Gendarme plugin to analyze Silverlight projects.
sonar.silverlight.4.mscorlib.locationNoNot AvailableFormerly used by the Gendarme plugin to analyze Silverlight projects.
sonar.silverlight.5.mscorlib.locationNoNot AvailableFormerly used by the Gendarme plugin to analyze Silverlight projects.
sonar.silverlight.versionNoNot AvailableFormerly used by the Gendarme plugin to analyze Silverlight projects.
Old propertyStill Supported?Replaced byDescription
sonar.dotnet.visualstudio.testProjectPatternNosonar.visualstudio.testProjectPattern

 

sonar.dotnet.visualstudio.itProjectPatternNoNot Available

 

    
sonar.dotnet.key.generation.strategyNo

Now set to "safe" by default

Use
sonar.visualstudio.projectKeyStrategy=unsafe
while upgrading to C# 3.0.

See the chapter on project keys for details.
Old propertyStill Supported?Replaced byDescription
sonar.fxcop.modeNoNot Available

The execution of FxCop is now always driven by the plugin.

Reusing existing reports is no longer supported.

sonar.gendarme.modeNoNot AvailableGendarme is no longer supported.
sonar.stylecop.modeNoNot Available

The execution of StyleCop is now always driven by the plugin.

Reusing existing reports is no longer supported.

sonar.gallio.modeNoNot Available

It now is only possible to import existing code coverage reports.

Tests are no longer executed as part of the analysis by the plugin.

sonar.gallio.it.modeNoNot Available

Integration tests code coverage import is not yet supported.

See SONARPLUGINS-3661

sonar.resharper.modeNoNot Available

The execution of R# is now always driven by the plugin.

Reusing existing reports is no longer supported.

sonar.ndeps.modeNoNot AvailableNDeps is no longer supported.
Old propertyStill Supported?Replaced byDescription
sonar.fxcop.reports.pathNoNot Available

The execution of FxCop is now always driven by the plugin.

Reusing existing reports is no longer supported.

sonar.gendarme.reports.pathNoNot AvailableGendarme is no longer supported.
sonar.stylecop.reports.pathNoNot Available

The execution of StyleCop is now always driven by the plugin.

Reusing existing reports is no longer supported.

sonar.resharper.reports.pathNoNot Available

The execution of R# is now always driven by the plugin.

Reusing existing reports is no longer supported.

Old propertyStill Supported?Replaced byDescription
sonar.gallio.reports.pathNo

C#:
sonar.cs.vstest.reportsPaths

VB.NET:
sonar.vbnet.vstest.reportsPaths 

NCover is not yet supported: SONARPLUGINS-3678

sonar.gallio.it.reports.pathNo

Not Available

Tests result reports import of integration tests is not yet supported by SonarQube: SONAR-4101

sonar.gallio.it.coverage.reports.pathNoNot AvailableIntegration tests code coverage import is not yet supported.

See SONARPLUGINS-3661

sonar.gallio.filterNoNot AvailableGallio is no longer supported.
sonar.gallio.coverage.excludesNoNot AvailableGallio is no longer supported.
sonar.gallio.runnerNoNot AvailableGallio is no longer supported.
sonar.gallio.safe.modeNoNot AvailableGallio is no longer supported.
sonar.gallio.timeoutMinutesNoNot AvailableGallio is no longer supported.
Old propertyStill Supported?Replaced byDescription
sonar.resharper.dotSettings.pathNoNot AvailableAll the configuration customization should be made within SonarQube.
sonar.stylecop.analyzers.settingsNoNot AvailableAll the configuration customization should be made within SonarQube.
    
sonar.gendarme.confidence NoNot AvailableGendarme is no longer supported.
    
sonar.fxcop.ignoreGeneratedCodeNoUse standard SonarQube exclusions 
sonar.dotnet.excludeGeneratedCodeNoUse standard SonarQube exclusionsSee the exclude generated code chapter.
Old propertyStill Supported?Replaced byDescription
sonar.resharper.additionalArgumentsNoNot AvailableThis configuration parameter is no longer supported.
sonar.resharper.includeAllFilesNoNot AvailableThis configuration parameter is no longer supported.
    
sonar.ndeps.ignorable.fieldsNoNot AvailableNDeps is no longer supported.
    
sonar.resharper.customRules.definitionNoNot AvailableCustom R# rules are not yet supported. SONARPLUGINS-3693
sonar.fxcop.customRules.definitionNoCustom FxCop rules are now supported via the rule template:
"Template for custom FxCop rules" (CustomRuleTemplate) 
 

 

 

 

  • No labels