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

Beta 9 reports "Missing Analyzer Reference" #1345

Closed
sharwell opened this issue Aug 31, 2015 · 12 comments
Closed

Beta 9 reports "Missing Analyzer Reference" #1345

sharwell opened this issue Aug 31, 2015 · 12 comments
Assignees
Milestone

Comments

@sharwell
Copy link
Member

When 1.0.0-beta009 is installed in a project, Visual Studio reports a MissingAnalyzerReference diagnostic:

Analyzer assembly '{path}\StyleCopAnalyzers\packages\StyleCop.Analyzers.1.0.0-beta009\analyzers\dotnet\cs\Newtonsoft.Json.dll' depends on 'mscorlib, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e' but it was not found. Analyzers may not run correctly.

@sharwell
Copy link
Member Author

This issue is reported only inside the IDE. The AppVeyor build is still showing up clean with Beta 9.

@otac0n
Copy link
Contributor

otac0n commented Sep 1, 2015

Removing the analyzer reference to Newtonsoft (Expand References\Analyzers, Right-click Newtonsoft.Json, Remove) appears to fix the warning.

I did this, and eventually (certainly not right away) I started seeing this Info Message showing up in VS:

Message AD0001  The User Diagnostic Analyzer 'StyleCop.Analyzers.DocumentationRules.FileHeaderAnalyzers' threw an exception of type 'System.IO.FileNotFoundException' with message 'Could not load file or assembly 'Newtonsoft.Json, Version=7.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed' or one of its dependencies. The system cannot find the file specified.'.   

'StyleCop.Analyzers.DocumentationRules.FileHeaderAnalyzers' threw the following exception:
'System.IO.FileNotFoundException: Could not load file or assembly 'Newtonsoft.Json, Version=7.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed' or one of its dependencies. The system cannot find the file specified.
File name: 'Newtonsoft.Json, Version=7.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed'
   at StyleCop.Analyzers.SettingsHelper.GetStyleCopSettings(ImmutableArray`1 additionalFiles)
   at StyleCop.Analyzers.SettingsHelper.GetStyleCopSettings(SyntaxTreeAnalysisContext context)
   at StyleCop.Analyzers.DocumentationRules.FileHeaderAnalyzers.HandleSyntaxTreeAxtion(SyntaxTreeAnalysisContext context, Compilation compilation)
   at StyleCop.Analyzers.DocumentationRules.FileHeaderAnalyzers.<>c__DisplayClass80_0.<HandleCompilationStart>b__0(SyntaxTreeAnalysisContext ctx)
   at StyleCop.Analyzers.AnalyzerExtensions.<>c__DisplayClass1_0.<RegisterSyntaxTreeActionHonorExclusions>b__0(SyntaxTreeAnalysisContext c)
   at Microsoft.CodeAnalysis.Diagnostics.AnalyzerExecutor.<>c__DisplayClass33_0.<ExecuteSyntaxTreeActions>b__0()
   at Microsoft.CodeAnalysis.Diagnostics.AnalyzerExecutor.ExecuteAndCatchIfThrows_NoLock(DiagnosticAnalyzer analyzer, Action analyze)

WRN: Assembly binding logging is turned OFF.
To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1.
Note: There is some performance penalty associated with assembly bind failure logging.
To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog].
'.

@jimmymain
Copy link

@jimmymain
Copy link

I have obtained the source, and tried to take a look at this problem.
In attempting to build the solution, I have this same warning.

Severity    Code    Description Project File    Line
Warning MissingAnalyzerReference    Analyzer assembly 'D:\StyleCopAnalyzers\packages\StyleCop.Analyzers.1.0.0-beta009\analyzers\dotnet\cs\Newtonsoft.Json.dll' 
depends on 'mscorlib, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e' but it was not found. Analyzers may not run correctly. StyleCop.Analyzers      1

newtonsoft definitely has a dependency on mscorlib version 2.0.5.0, and is required by the solution.

I also had a problem with EmbeddedResource not being supported, but upon rebuilding, that problem has resolved, perhaps a missing package.

@jimmymain
Copy link

I think this warning can be safely ignored.
There was a similar issue with the FxCopAnalyzer https://github.com/dotnet/roslyn/pull/3047/files

it was solved by white listing all the system dll's. hopefully the warnings can be suppressed. If not, it's possibly a bug in roslyn, mscorlib should have been white listed in addition to the system libraries.

An alternative, is to rebuild newtonsoft without the silverlight targets and reference that, since it would appear that the reference to 2.0.5.0 is for silverlight, and is not actually required.

@jimmymain
Copy link

using the net45 version of newtonsoft.json.dll instead of the portable version, for both 6.0.8 and 7.0.1 of newtonsoft.json.dll solves the problem.

replace the library here: packages\StyleCop.Analyzers.1.0.0-beta009\analyzers\dotnet\cs

@NikolayIT
Copy link
Member

Cleaning the solution fixed this for me.

@alxru
Copy link

alxru commented Sep 8, 2015

I just want to confirm that using net45 version of Newtonsoft.Json.dll indeed resolves the issue with the missing references to 'mscorlib, Version=2.0.5.0'. Would be nice not to see all those warnings in v1.0.0.10.

@sharwell
Copy link
Member Author

sharwell commented Sep 8, 2015

Blocked on dotnet/roslyn#5065.

@nbarbettini
Copy link
Contributor

Ditto, can confirm that copying the net45 version of JSON.NET 7.0.1 into packages\StyleCop.Analyzers.1.0.0-beta010\analyzers\dotnet\cs makes the IDE warnings go away.

@jimmymain
Copy link

It's definitely worth considering deploying the net45 version of JSON until microsoft have completed roslyn/#5065

@sharwell
Copy link
Member Author

@jimmymain I think that could be a reasonable workaround. We could actually do it directly in the .nuspec file and not need to touch the projects at all.

@sharwell sharwell removed the blocked label Sep 13, 2015
@sharwell sharwell added this to the 1.0.0 Beta 12 milestone Sep 13, 2015
@sharwell sharwell self-assigned this Sep 13, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants