dbolin / Apex.Analyzers

Roslyn powered analyzers for C# to support convention defined architecture
MIT License
15 stars 2 forks source link

Version 1.1 does not work with Visual Studio 16.4 #34

Closed mwelsh1118 closed 4 years ago

mwelsh1118 commented 4 years ago

The new Microsoft.CodeAnalysis package that's referenced in 1.1 (Microsoft.CodeAnalysis 3.5) isn't included in Visual Studio 2019 Update 4, so compiling with that version of MSBuild produces this warning --

CSC : warning CS8032: An instance of analyzer Apex.Analyzers.Immutable.ApexAnalyzersImmutableAnalyzer cannot be created from C:\Users\markwelsh\source\repos\ApexExample\packages\Apex.Analyzers.Immutable.1.1.0\analyzers\dotnet\cs\Apex.Analyzers.Immutable.dll : Could not load file or assembly 'Microsoft.CodeAnalysis, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified..

Is there a way to work around this? Or would it be possible to roll back to the version supported by 16.4? That's the most recent servicing baseline.

dbolin commented 4 years ago

Does the analyzer still work despite the warnings?

Looks like you may need a reference to the latest Microsoft.Net.Compilers package... I don't have the older version of VS so I can't test that.

mwelsh1118 commented 4 years ago

No, with the warning the rules are not applied.

The Microsoft.Net.Compilers package works, but it's also deprecated. The replacement, Microsoft.Net.Compilers.Toolset, has the following warning: "Using it as a long term solution for providing newer compilers on older MSBuild installations is explicitly not supported. That can and will break on a regular basis." So we probably couldn't use that in production, unfortunately.

dbolin commented 4 years ago

Version 1.2.0 reverts back to 3.4.0, so you can try that and see if it works

dbolin commented 4 years ago

Actually I can't publish a new version yet - running into a problem where the analyzer can't load the new library project, I thought it might be because of ProjectReference and analyzers (which would be why attributes was using PackageReference) but that doesn't seem to be it.

dbolin commented 4 years ago

This is available now in 1.2.4 to be tested

mwelsh1118 commented 4 years ago

That version works. Thanks!