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

NSubstitute.Analyzers.CSharp produces warnings about Microsoft.CodeAnalysis.CSharp in project, no analyzer output #77

Open
erizzo opened this issue Mar 13, 2019 · 4 comments

Comments

@erizzo
Copy link

erizzo commented Mar 13, 2019

Question
I have an ordinary Test project in my solution, targeting .Net Framework 4.6.2. When I added a Nuget reference to NSubstitute.Analyzers.CSharp, I got several warnings like this:

An instance of analyzer NSubstitute.Analyzers.CSharp.DiagnosticAnalyzers.NonVirtualSetupWhenAnalyzer cannot be created from C:\Users\erizzo.nuget\packages\nsubstitute.analyzers.csharp\1.0.6\analyzers\dotnet\cs\NSubstitute.Analyzers.CSharp.dll : Could not load file or assembly 'Microsoft.CodeAnalysis.CSharp, Version=2.8.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified..

I then tried adding Nuget reference to Microsoft.CodeAnalysis.CSharp (I tried both 2.8.0 and the latest stable version, 2.10.0), but it made no difference.

Obviously, the NSubstitute analyzers are not producing any warnings, either.

Any ideas what I can do?

VisualStudio version is 15.6.7 (VS 2017)

@tpodolak
Copy link
Member

Hi @erizzo, thanks for reporting. I will try to take a look, however, I don't have access to this particular version on Visual Studio. I will take a look if this issue occurs on the one I own (15.7.6) and will get back to you

@dtchepak can you move this issue to NSubstitute.Analyzers repository? GitHub should be able to do this by now (but it seems I cant do it on my own)

@erizzo
Copy link
Author

erizzo commented Mar 13, 2019

Thanks. I apologize for not noticing there was a separate repo for the analyzers.

@zvirja zvirja pinned this issue Mar 13, 2019
@zvirja zvirja unpinned this issue Mar 13, 2019
@zvirja zvirja transferred this issue from nsubstitute/NSubstitute Mar 13, 2019
@tpodolak
Copy link
Member

tpodolak commented Mar 13, 2019

@erizzo I did some digging and also asked on Roslyn gitter channel, and I am afraid I don't have good news. NSubstitute.Analyzers from the very first stable version depends on

<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="2.8.2" PrivateAssets="all" />

This is the package which provides the Roslyn goodies thanks to which we are able to analyze c# code, report diagnostic etc. When the analyzer is added to project, this dependency is provided by VisualStudio itself - not by a NuGet reference/dependency. VisualStudio is shipped together with specific Roslyn version, the mapping between them is listed here. So as you can see from the link above you need Visual Studio 2017 version 15.7 or higher in order to make them work.
At this point I can only advice to update VS to at least 15.7, would that be a problem for you @erizzo?
From my side, I will add documentation which will clearly indicate min VS version is required for given NSubstitute.Analyzer package. I will also play around and see if it is possible to downgrade the Workspace packages to lower version but I am afraid it might not be possible

@dtchepak
Copy link
Member

@erizzo Thanks for taking the time to raise the issue! Logging it in the other repo isn't a problem -- we'd much prefer to have a record of the issue than have people be put off trying to decide which repo it should go in! :)

@zvirja Thanks for moving this.

@tpodolak Seems like you've already found the issue. I did find the same message mentioned in this issue, but not sure how comparable that is.

@tpodolak tpodolak pinned this issue Mar 19, 2019
@tpodolak tpodolak unpinned this issue Apr 11, 2019
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

3 participants