Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Argument contains duplicate analyzer instances. (Parameter 'analyzers') #1592

Open
gpshonik opened this issue Dec 5, 2024 · 5 comments
Open

Comments

@gpshonik
Copy link

gpshonik commented Dec 5, 2024

I believe this issue was fixed at some point, but it seems to be back with Roslynator 2022 v4.12..9 and Visual Studio 2022 v17.12.3.

StreamJsonRpc.RemoteInvocationException: Argument contains duplicate analyzer instances. (Parameter 'analyzers')
   at StreamJsonRpc.JsonRpc.<InvokeCoreAsync>d__156`1.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.CodeAnalysis.Remote.BrokeredServiceConnection`1.<TryInvokeAsync>d__18`1.MoveNext()
RPC server exception:
System.ArgumentException: Argument contains duplicate analyzer instances. (Parameter 'analyzers')
      at Microsoft.CodeAnalysis.Diagnostics.CompilationWithAnalyzers.VerifyAnalyzersArgumentForStaticApis(ImmutableArray`1 analyzers, Boolean allowDefaultOrEmpty)
      at Microsoft.CodeAnalysis.Diagnostics.CompilationWithAnalyzers..ctor(Compilation compilation, ImmutableArray`1 analyzers, CompilationWithAnalyzersOptions analysisOptions)
      at Microsoft.CodeAnalysis.Remote.Diagnostics.DiagnosticComputer.GetDiagnosticsAsync(ImmutableArray`1 projectAnalyzerIds, ImmutableArray`1 hostAnalyzerIds, Boolean reportSuppressedDiagnostics, Boolean logPerformanceInfo, Boolean getTelemetryInfo, CancellationToken cancellationToken)
      at Microsoft.CodeAnalysis.Remote.Diagnostics.DiagnosticComputer.GetNormalPriorityDiagnosticsAsync(ImmutableArray`1 projectAnalyzerIds, ImmutableArray`1 hostAnalyzerIds, Boolean reportSuppressedDiagnostics, Boolean logPerformanceInfo, Boolean getTelemetryInfo, CancellationToken cancellationToken)
      at Microsoft.CodeAnalysis.Remote.RemoteDiagnosticAnalyzerService.<>c__DisplayClass3_0.<<CalculateDiagnosticsAsync>b__0>d.MoveNext()
   --- End of stack trace from previous location ---
      at Microsoft.CodeAnalysis.Remote.RemoteWorkspace.<>c__DisplayClass7_0`1.<<RunWithSolutionAsync>g__ProcessSolutionAsync|1>d.MoveNext()
   --- End of stack trace from previous location ---
      at Microsoft.CodeAnalysis.Remote.RemoteWorkspace.RunWithSolutionAsync[T](AssetProvider assetProvider, Checksum solutionChecksum, Boolean updatePrimaryBranch, Func`2 implementation, CancellationToken cancellationToken)
      at Microsoft.CodeAnalysis.Remote.RemoteWorkspace.RunWithSolutionAsync[T](AssetProvider assetProvider, Checksum solutionChecksum, Boolean updatePrimaryBranch, Func`2 implementation, CancellationToken cancellationToken)
      at Microsoft.CodeAnalysis.Remote.BrokeredServiceBase.RunWithSolutionAsync[T](Checksum solutionChecksum, Func`2 implementation, CancellationToken cancellationToken)
      at Microsoft.CodeAnalysis.Remote.RemoteDiagnosticAnalyzerService.CalculateDiagnosticsAsync(Checksum solutionChecksum, DiagnosticArguments arguments, CancellationToken cancellationToken)

Minimal repro:
File...New Project...Create a new Console App (.NET 9)
Press Alt + F11 to trigger Run Code Analysis on Solution

Edit
Disabling the extension and restarting VS 2022 allows the Run Code Analysis on Solution to complete without errors

@josefpihrt
Copy link
Collaborator

I don't see Roslynator anywhere in the callstack. I would recommend to report this issue to Roslyn repo: https://github.com/dotnet/roslyn/issues.

@gpshonik
Copy link
Author

Broader issue being tracked here:

https://developercommunity.visualstudio.com/t/Getting-Argument-contains-duplicate-ana/10806027

Seems like an issue with other analyzer tools as well (at least CodeRush, for which there is a hotfix). Is it possible there was a breaking change in VS v17.12.3 that impacts the Roslynator vsix as well?

@ricbak
Copy link

ricbak commented Dec 12, 2024

I've got the same issue here.

Created a new console-application, and when trying to "Run Code Analysis on Solution", I get the same error.

@NotTheDBA
Copy link

I see the same issue; all other extensions are disabled so there isn't a conflict with any other non-MS utilities. Other Roslyn analyzer extensions seem to work fine.

@RealDotNetDave
Copy link

I'm having the same issue. I hope they fix this asap!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants