Unable to analyze C# with Roslyn analyzer

133 views
Skip to first unread message

arjen.v...@gmail.com

unread,
May 11, 2016, 12:20:32 PM5/11/16
to SonarQube
Hi,

I am trying to use a Roslyn Analyzer in combination with SonarQube. First I have build the analyzer in Visual Studio. Then I've used RoslynSonarQubePluginGenerator to generate a jar file.
Then I copied sonar-csharp 5.2 and my analyzer jar to my SonarQube 4.5 and restarted sonar.

Then when I analyze my project:
      MSBuild.SonarQube.Runner.exe begin /k:"csharp_key" /n:"csharp_name" /v:"0.5"  /d:sonar.verbose=true
      "C:\Program Files (x86)\MSBuild\14.0\Bin\MSBuild.exe" /t:Rebuild
      MSBuild.SonarQube.Runner.exe  end

I get this error:

ERROR: Error during Sonar runner execution
org.sonar.runner.impl.RunnerException: Unable to execute Sonar
        at org.sonar.runner.impl.BatchLauncher$1.delegateExecution(BatchLauncher.java:91)
        at org.sonar.runner.impl.BatchLauncher$1.run(BatchLauncher.java:75)
        at java.security.AccessController.doPrivileged(Native Method)
        at org.sonar.runner.impl.BatchLauncher.doExecute(BatchLauncher.java:69)
        at org.sonar.runner.impl.BatchLauncher.execute(BatchLauncher.java:50)
        at org.sonar.runner.api.EmbeddedRunner.doExecute(EmbeddedRunner.java:102)
        at org.sonar.runner.api.Runner.execute(Runner.java:100)
        at org.sonar.runner.Main.executeTask(Main.java:70)
        at org.sonar.runner.Main.execute(Main.java:59)
        at org.sonar.runner.Main.main(Main.java:53)
Caused by: org.picocontainer.injectors.AbstractInjector$UnsatisfiableDependenciesException: org.sonar.plugins.roslynsdk.RoslynSdkRulesDefi
tion has unsatisfied dependency 'class org.sonar.plugins.roslynsdk.RoslynSdkConfiguration' for constructor 'public org.sonar.plugins.rosly
dk.RoslynSdkRulesDefinition(org.sonar.plugins.roslynsdk.RoslynSdkConfiguration)' from org.picocontainer.DefaultPicoContainer@33cd31cf:301<
mmutable]:org.picocontainer.DefaultPicoContainer@2111c3cc:317<[Immutable]:org.picocontainer.DefaultPicoContainer@4ee127c6:16<[Immutable]:o
.picocontainer.DefaultPicoContainer@51338b5:100<|
        at org.picocontainer.injectors.ConstructorInjector.getGreediestSatisfiableConstructor(ConstructorInjector.java:191)
        at org.picocontainer.injectors.ConstructorInjector.getGreediestSatisfiableConstructor(ConstructorInjector.java:110)
        at org.picocontainer.injectors.ConstructorInjector.access$100(ConstructorInjector.java:51)
        at org.picocontainer.injectors.ConstructorInjector$1.run(ConstructorInjector.java:331)
        at org.picocontainer.injectors.AbstractInjector$ThreadLocalCyclicDependencyGuard.observe(AbstractInjector.java:270)
        at org.picocontainer.injectors.ConstructorInjector.getComponentInstance(ConstructorInjector.java:364)
        at org.picocontainer.injectors.AbstractInjectionFactory$LifecycleAdapter.getComponentInstance(AbstractInjectionFactory.java:56)
        at org.picocontainer.behaviors.AbstractBehavior.getComponentInstance(AbstractBehavior.java:64)
        at org.picocontainer.behaviors.Stored.getComponentInstance(Stored.java:91)
        at org.picocontainer.DefaultPicoContainer.getLocalInstance(DefaultPicoContainer.java:605)
        at org.picocontainer.DefaultPicoContainer.getComponents(DefaultPicoContainer.java:586)
        at org.sonar.api.platform.ComponentContainer.getComponentsByType(ComponentContainer.java:217)
        at org.sonar.api.batch.BatchExtensionDictionnary.completeBatchExtensions(BatchExtensionDictionnary.java:104)
        at org.sonar.api.batch.BatchExtensionDictionnary.getExtensions(BatchExtensionDictionnary.java:98)
        at org.sonar.api.batch.BatchExtensionDictionnary.selectMavenPluginHandlers(BatchExtensionDictionnary.java:74)
        at org.sonar.batch.scan.maven.MavenPluginsConfigurator.execute(MavenPluginsConfigurator.java:48)
        at org.sonar.batch.phases.PhaseExecutor.executeMavenPhase(PhaseExecutor.java:171)
        at org.sonar.batch.phases.PhaseExecutor.execute(PhaseExecutor.java:105)
        at org.sonar.batch.scan.ModuleScanContainer.doAfterStart(ModuleScanContainer.java:194)
        at org.sonar.api.platform.ComponentContainer.startComponents(ComponentContainer.java:93)
        at org.sonar.api.platform.ComponentContainer.execute(ComponentContainer.java:78)
        at org.sonar.batch.scan.ProjectScanContainer.scan(ProjectScanContainer.java:233)
        at org.sonar.batch.scan.ProjectScanContainer.scanRecursively(ProjectScanContainer.java:228)
        at org.sonar.batch.scan.ProjectScanContainer.scanRecursively(ProjectScanContainer.java:226)
        at org.sonar.batch.scan.ProjectScanContainer.doAfterStart(ProjectScanContainer.java:221)
        at org.sonar.api.platform.ComponentContainer.startComponents(ComponentContainer.java:93)
        at org.sonar.api.platform.ComponentContainer.execute(ComponentContainer.java:78)
        at org.sonar.batch.scan.ScanTask.scan(ScanTask.java:64)
        at org.sonar.batch.scan.ScanTask.execute(ScanTask.java:51)
        at org.sonar.batch.bootstrap.TaskContainer.doAfterStart(TaskContainer.java:125)
        at org.sonar.api.platform.ComponentContainer.startComponents(ComponentContainer.java:93)
        at org.sonar.api.platform.ComponentContainer.execute(ComponentContainer.java:78)
        at org.sonar.batch.bootstrap.BootstrapContainer.executeTask(BootstrapContainer.java:173)
        at org.sonar.batch.bootstrapper.Batch.executeTask(Batch.java:95)
        at org.sonar.batch.bootstrapper.Batch.execute(Batch.java:67)
        at org.sonar.runner.batch.IsolatedLauncher.execute(IsolatedLauncher.java:48)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:483)
        at org.sonar.runner.impl.BatchLauncher$1.delegateExecution(BatchLauncher.java:87)

Other roslyn analyzers, which i downloaded with nuget, also didnt work. So I think it's not related to the analyzer itself.

Any ideas how to fix this ?

Regards,
Arjen
Message has been deleted

duncanp

unread,
May 18, 2016, 5:06:43 AM5/18/16
to SonarQube, arjen.v...@gmail.com
Hi Arjen,

The plugin generated by the SDK is built against the v4.5.2 SonarQube jars (4.5.2 was the LTS version at the point the SDK was created).

Does your plugin work on SonarQube 4.5.2?

Also, if you let me know the NuGet package id for one of the public Roslyn analyzers that doesn't work for you, I'll try it building a plugin for it using the SDK.

Regards,
Duncan

Dinesh Bolkensteyn

unread,
May 19, 2016, 9:27:28 AM5/19/16
to SonarQube, arjen.v...@gmail.com
I'm available to reproduce this on SQ LTS.

This is caused by a bug in the generated plugins.

arjen.v...@gmail.com

unread,
May 19, 2016, 11:40:09 AM5/19/16
to SonarQube, arjen.v...@gmail.com
I had tested with both my own analyzers, and the SigGuidelineAnalyzers that were mentioned in another topic.
The test was done with SonarQube 4.5.4 and both analyzers resulted in the same error.
Afterwards I tried SonarQube 5.1.2 which does work for both of them. So the jars were OK.

Those are the only two instances I have on my machine. 

Another thing that I noticed, is that sometimes (like 1 out of 10), it seems the produced jar is incomplete. However, regenerating the jar without changing anything else does fix this.
I think it might just be my machine being slow and locking some file or something. If I can find a reproducible scenario for that I''ll post it here.


Op donderdag 19 mei 2016 15:27:28 UTC+2 schreef Dinesh Bolkensteyn:
Reply all
Reply to author
Forward
0 new messages