lucenenet-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] [lucenenet] NightOwl888 opened a new pull request #467: Fix for code analyzer support on Visual Studio 2017 (fixes #394)
Date Thu, 15 Apr 2021 02:22:33 GMT

NightOwl888 opened a new pull request #467:
URL: https://github.com/apache/lucenenet/pull/467


   Fixes #394.
   
   This downgrades our code analyzers from .NET Standard 2.0 to .NET Standard 1.3 to fix analyzer
loading issues in Visual Studio 2017 when referencing the `Lucene.Net` NuGet package.
   
   ![image](https://user-images.githubusercontent.com/1538288/114800897-cb9ac200-9dc4-11eb-8805-63fc6b088dc1.png)
   
   It also downgrades `Microsoft.CodeAnalysis.CSharp.Workspaces` and `Microsoft.CodeAnalysis.VisualBasic.Workspaces`
to 2.6.1 and adds direct dependencies on  `Microsoft.CodeAnalysis.CSharp` and `Microsoft.CodeAnalysis.VisualBasic`.
There is an [unofficial guide that describes how this versioning works](https://roslyn-analyzers.readthedocs.io/en/latest/nuget-packages.html#nuget-packages),
but this should add support for Visual Studio 15.6.1 and higher (previously it was 16.4.0
and higher).
   
   The patch was confirmed to work on Visual Studio 15.9.29 as well as Visual Studio 16.8.2
in both C# and Visual Basic.
   
   A `Version.props` file was also added so we can manually bump the binary version (version
revision only) whenever a change is made, which is [a requirement of Visual Studio](https://github.com/dotnet/roslyn/issues/4381#issuecomment-342867710)
to be able to reload an analyzer. This will prevent workarounds like https://github.com/apache/lucenenet/issues/286#issuecomment-663833490
from being necessary, and helps to ensure we are verifying the correct copy when debugging.
   
   > NOTE: An attempt was made to detect the [Visual Studio version](https://docs.microsoft.com/en-us/dotnet/api/envdte._dte.version?redirectedfrom=MSDN&view=visualstudiosdk-2019#EnvDTE__DTE_Version)
and disable installation of the analyzer using the `install.ps1` script, but it turns out
that [scripting support in NuGet packages is now deprecated](https://docs.microsoft.com/en-us/nuget/create-packages/supporting-multiple-target-frameworks#content-files-and-powershell-scripts)
and analyzers are now loaded by convention rather than with scripts. The scripts (which even
Microsoft's NuGet-packaged analyzers ship with) are only for backward compatibility support
with older VS versions and exit early to prevent double-installation from happening when convention-based
support exists.
   
   ### References
   
   - [Analyzer NuGet formats](https://docs.microsoft.com/en-us/nuget/guides/analyzers-conventions)
   - [How to create a Roslyn Analyzer project for C#](https://roslyn-analyzers.readthedocs.io/en/latest/how-to-start.html#how-to-create-a-roslyn-analyzer-project-for-c)
(unofficial guide to mult-targeting Visual Studio versions)
   - [xunit.analyzers](https://github.com/xunit/xunit.analyzers/blob/main/src/xunit.analyzers/xunit.analyzers.csproj)
   - [StyleCop.Analyzers](https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/3c877565bcfeae0e737158d7c5a7092a87ef9186/StyleCop.Analyzers/StyleCop.Analyzers/StyleCop.Analyzers.csproj)
   - [Tutorial: Write your first analyzer and code fix](https://docs.microsoft.com/en-us/dotnet/csharp/roslyn-sdk/tutorials/how-to-write-csharp-analyzer-code-fix)


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



Mime
View raw message