Skip to content

Commit

Permalink
Merge pull request #2232 from mavasani/VersionCheckAnalyzer
Browse files Browse the repository at this point in the history
Fix the VersionCheckAnalyzer to work correctly on Dev15 and above
  • Loading branch information
mavasani committed Mar 21, 2019
2 parents a53d969 + 95c8dbb commit ea7ff1c
Show file tree
Hide file tree
Showing 29 changed files with 140 additions and 160 deletions.
20 changes: 12 additions & 8 deletions README.md
Expand Up @@ -20,15 +20,17 @@ This is the **primary analyzer package** for this repo that contains all **the p

This analyzer package contains all the ported FxCop rules that are applicable for both _.NetCore/.NetStandard_ and _Desktop .NetFramework_ projects. You **do not need to install any separate analyzer package from this repo to get target-framework specific FxCop rules**.

[More info about rules in this package](src/Microsoft.CodeAnalysis.FxCopAnalyzers/Microsoft.CodeAnalysis.FxCopAnalyzers.md)

This analyzer package contains the following subpackages or NuGet dependencies that are automatically installed when you install the Microsoft.CodeAnalysis.FxCopAnalyzers package:

### Microsoft.CodeQuality.Analyzers

*Latest stable version:* [![NuGet](https://img.shields.io/nuget/v/Microsoft.CodeQuality.Analyzers.svg)](https://www.nuget.org/packages/Microsoft.CodeQuality.Analyzers)

This package contains common code quality improvement rules that are not specific to usage of any particular API. For example, [CA1801](https://docs.microsoft.com/en-us/visualstudio/code-quality/ca1801-review-unused-parameters) (ReviewUnusedParameters) flags parameters that are unused and is part of this package.
This package contains common code quality improvement rules that are not specific to usage of any particular API. For example, [CA1801](https://docs.microsoft.com/en-us/visualstudio/code-quality/ca1801-review-unused-parameters) (ReviewUnusedParameters) flags parameters that are unused and is part of this package.

[More info](src/Microsoft.CodeQuality.Analyzers/Microsoft.CodeQuality.Analyzers.md)
[More info about rules in this package](src/Microsoft.CodeQuality.Analyzers/Microsoft.CodeQuality.Analyzers.md)

### Microsoft.NetCore.Analyzers

Expand All @@ -38,7 +40,7 @@ This package contains rules for correct usage of APIs that are present in _.NetC

**NOTE:** This analyzer package is applicable for both _.NetCore/.NetStandard_ and _Desktop .NetFramework_ projects. If the API whose usage is being checked exists only in _.NetCore/.NetStandard_ libraries, then the analyzer will bail out silently for _Desktop .NetFramework_ projects. Otherwise, if the API exists in both _.NetCore/.NetStandard_ and _Desktop .NetFramework_ libraries, the analyzer will run correctly for both _.NetCore/.NetStandard_ and _Desktop .NetFramework_ projects.

[More info](src/Microsoft.NetCore.Analyzers/Microsoft.NetCore.Analyzers.md)
[More info about rules in this package](src/Microsoft.NetCore.Analyzers/Microsoft.NetCore.Analyzers.md)

### Microsoft.NetFramework.Analyzers

Expand All @@ -48,7 +50,7 @@ This package contains rules for correct usage of APIs that are present only in _

**NOTE:** The analyzers in this package will silently bail out if installed on a _.NetCore/.NetStandard_ project that do not have the underlying API whose usage is being checked. If future versions of _.NetCore/.NetStandard_ libraries include these APIs, the analyzers will automatically light up on _.NetCore/.NetStandard_ projects that target these libraries.

[More info](src/Microsoft.NetFramework.Analyzers/Microsoft.NetFramework.Analyzers.md)
[More info about rules in this package](src/Microsoft.NetFramework.Analyzers/Microsoft.NetFramework.Analyzers.md)


Other analyzer packages
Expand All @@ -60,7 +62,7 @@ Other analyzer packages

This package contains rules for correct usage of APIs from the [Microsoft.CodeAnalysis](https://www.nuget.org/packages/Microsoft.CodeAnalysis) NuGet package, i.e. .NET Compiler Platform ("Roslyn") APIs. These are primarily aimed towards helping authors of diagnostic analyzers and code fix providers to invoke the Microsoft.CodeAnalysis APIs in a recommended manner.

[More info](src/Microsoft.CodeAnalysis.Analyzers/Microsoft.CodeAnalysis.Analyzers.md)
[More info about rules in this package](src/Microsoft.CodeAnalysis.Analyzers/Microsoft.CodeAnalysis.Analyzers.md)


### Roslyn.Diagnostics.Analyzers
Expand All @@ -69,7 +71,7 @@ This package contains rules for correct usage of APIs from the [Microsoft.CodeAn

This package contains rules that are very specific to the .NET Compiler Platform ("Roslyn") project, i.e. https://github.com/dotnet/roslyn repo. This analyzer package is _not intended for general consumption_ outside the Roslyn repo.

[More info](src/Roslyn.Diagnostics.Analyzers/Roslyn.Diagnostics.Analyzers.md)
[More info about rules in this package](src/Roslyn.Diagnostics.Analyzers/Roslyn.Diagnostics.Analyzers.md)


### Microsoft.CodeAnalysis.BannedApiAnalyzers
Expand All @@ -78,15 +80,15 @@ This package contains rules that are very specific to the .NET Compiler Platform

This package contains customizable rules for identifying references to banned APIs.

[More info](src/Microsoft.CodeAnalysis.BannedApiAnalyzers/Microsoft.CodeAnalysis.BannedApiAnalyzers.md)
[More info about rules in this package](src/Microsoft.CodeAnalysis.BannedApiAnalyzers/Microsoft.CodeAnalysis.BannedApiAnalyzers.md)

### Microsoft.CodeAnalysis.PublicApiAnalyzers

*Latest stable version:* [![NuGet](https://img.shields.io/nuget/v/Microsoft.CodeAnalysis.PublicApiAnalyzers.svg)](https://www.nuget.org/packages/Microsoft.CodeAnalysis.PublicApiAnalyzers)

This package contains rules to help library authors monitoring change to their public APIs.

[More info](src/src/PublicApiAnalyzers/Microsoft.CodeAnalysis.PublicApiAnalyzers.md)
[More info about rules in this package](src/PublicApiAnalyzers/Microsoft.CodeAnalysis.PublicApiAnalyzers.md)

### MetaCompilation (prototype)

Expand All @@ -96,6 +98,8 @@ The MetaCompilation Analyzer is an analyzer that functions as a tutorial to teac

For instructions on using this tutorial, see [Instructions](src/MetaCompilation.Analyzers/Core/ReadMe.md#instructions).

[More info about rules in this package](src/MetaCompilation.Analyzers/MetaCompilation.Analyzers.md)

Getting Started
===============

Expand Down
2 changes: 1 addition & 1 deletion eng/GenerateAnalyzerNuspec.targets
Expand Up @@ -39,7 +39,7 @@
</ItemGroup>

<PropertyGroup Condition="'$(GenerateAnalyzerMdFile)' == 'true'">
<AnalyzerDocumentationFileDir>$(RepoRoot)src\$(NuspecPackageId)</AnalyzerDocumentationFileDir>
<AnalyzerDocumentationFileDir Condition="'$(AnalyzerDocumentationFileDir)' == ''">$(RepoRoot)src\$(NuspecPackageId)</AnalyzerDocumentationFileDir>
<AnalyzerDocumentationFileName>$(NuspecPackageId).md</AnalyzerDocumentationFileName>
</PropertyGroup>

Expand Down
Expand Up @@ -9,6 +9,7 @@
<Summary>PerformanceSensitive Analyzers</Summary>
<ReleaseNotes>PerformanceSensitive Analyzers</ReleaseNotes>
<PackageTags>Roslyn CodeAnalysis Compiler CSharp Diagnostic Analyzers Syntax Semantics Performance</PackageTags>
<AnalyzerDocumentationFileDir>$(RepoRoot)src\PerformanceSensitiveAnalyzers</AnalyzerDocumentationFileDir>
</PropertyGroup>

<ItemGroup>
Expand Down
Expand Up @@ -10,6 +10,7 @@
<Summary>Public API Analyzer</Summary>
<ReleaseNotes>Public API Analyzers</ReleaseNotes>
<PackageTags>Roslyn CodeAnalysis Compiler CSharp VB VisualBasic Diagnostic Analyzers Syntax Semantics PublicApi ApiAnalyzer</PackageTags>
<AnalyzerDocumentationFileDir>$(RepoRoot)src\PublicApiAnalyzers</AnalyzerDocumentationFileDir>
</PropertyGroup>

<Choose>
Expand Down
Expand Up @@ -34,5 +34,8 @@
<AnalyzerRulesetAssembly Include="Microsoft.CodeAnalysis.BannedApiAnalyzers.dll" />
<AnalyzerRulesetAssembly Include="Microsoft.CodeAnalysis.CSharp.BannedApiAnalyzers.dll" />
<AnalyzerRulesetAssembly Include="Microsoft.CodeAnalysis.VisualBasic.BannedApiAnalyzers.dll" />
<AnalyzerRulesetAssembly Include="Roslyn.Diagnostics.Analyzers.dll" />
<AnalyzerRulesetAssembly Include="Roslyn.Diagnostics.CSharp.Analyzers.dll" />
<AnalyzerRulesetAssembly Include="Roslyn.Diagnostics.VisualBasic.Analyzers.dll" />
</ItemGroup>
</Project>
Expand Up @@ -154,4 +154,4 @@ Sr. No. | Rule ID | Title | Category | Enabled | CodeFix | Description |
151 | CA5363 | Do Not Disable Request Validation | Security | True | False | Request validation is a feature in ASP.NET that examines HTTP requests and determines whether they contain potentially dangerous content. This check adds protection from markup or code in the URL query string, cookies, or posted form values that might have been added for malicious purposes. So, it is generally desirable and should be left enabled for defense in depth. |
152 | CA5364 | Do Not Use Deprecated Security Protocols | Security | True | False | Using a deprecated security protocol rather than the system default is risky. |
153 | CA5365 | Do Not Disable HTTP Header Checking | Security | True | False | HTTP header checking enables encoding of the carriage return and newline characters, \r and \n, that are found in response headers. This encoding can help to avoid injection attacks that exploit an application that echoes untrusted data contained by the header. |
154 | CA9999 | Analyzer version mismatch | Reliability | True | False | Analyzers in this package are preview version and are tied to a specific API version of Microsoft.CodeAnalysis. You have a mismatch between the analyzer and Microsoft.CodeAnalysis version and should switch your analyzer NuGet package/VSIX to a matching version of the Microsoft.CodeAnalysis. |
154 | CA9999 | Analyzer version mismatch | Reliability | True | False | Analyzers in this package require a certain minimum version of Microsoft.CodeAnalysis to execute correctly. Refer to https://docs.microsoft.com/en-us/visualstudio/code-quality/install-fxcop-analyzers?view=vs-2017#fxcopanalyzers-package-versions to install the correct analyzer version. |

This file was deleted.

Expand Up @@ -7,10 +7,22 @@
Restore would conclude that there is a cyclic dependency between us and the Microsoft.CodeAnalysis.VersionCheckAnalyzer package.
-->
<PackageId>*$(MSBuildProjectFullPath)*</PackageId>
<MicrosoftCodeAnalysisVersion>2.0.0</MicrosoftCodeAnalysisVersion>
</PropertyGroup>

<Choose>
<When Condition="'$(TargetFramework)' == 'netstandard1.3'">
<PropertyGroup>
<PackageTargetFallback>portable-net45+win8</PackageTargetFallback>
</PropertyGroup>
</When>
</Choose>

<ItemGroup>
<InternalsVisibleTo Include="Microsoft.CodeAnalysis.UnitTests" />
<Compile Include="..\Utilities\Compiler\DiagnosticCategory.cs" Link="DiagnosticCategory.cs" />
<Compile Include="..\Utilities\Compiler\DiagnosticHelpers.cs" Link="DiagnosticHelpers.cs" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.CodeAnalysis.Common" Version="$(MicrosoftCodeAnalysisVersion)" />
</ItemGroup>
<Import Project="..\Utilities\Compiler\Analyzer.Utilities.projitems" Label="Shared" />
<Import Project="..\Utilities\Workspaces\Workspaces.Utilities.projitems" Label="Shared" />
</Project>
@@ -1,4 +1,4 @@

Sr. No. | Rule ID | Title | Category | Enabled | CodeFix | Description |
--------|---------|-------|----------|---------|---------|--------------------------------------------------------------------------------------------------------------|
1 | CA9999 | Analyzer version mismatch | Reliability | True | False | Analyzers in this package are preview version and are tied to a specific API version of Microsoft.CodeAnalysis. You have a mismatch between the analyzer and Microsoft.CodeAnalysis version and should switch your analyzer NuGet package/VSIX to a matching version of the Microsoft.CodeAnalysis. |
1 | CA9999 | Analyzer version mismatch | Reliability | True | False | Analyzers in this package require a certain minimum version of Microsoft.CodeAnalysis to execute correctly. Refer to https://docs.microsoft.com/en-us/visualstudio/code-quality/install-fxcop-analyzers?view=vs-2017#fxcopanalyzers-package-versions to install the correct analyzer version. |
Expand Up @@ -118,10 +118,10 @@
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<data name="VersionCheckDescription" xml:space="preserve">
<value>Analyzers in this package are preview version and are tied to a specific API version of Microsoft.CodeAnalysis. You have a mismatch between the analyzer and Microsoft.CodeAnalysis version and should switch your analyzer NuGet package/VSIX to a matching version of the Microsoft.CodeAnalysis.</value>
<value>Analyzers in this package require a certain minimum version of Microsoft.CodeAnalysis to execute correctly. Refer to https://docs.microsoft.com/en-us/visualstudio/code-quality/install-fxcop-analyzers?view=vs-2017#fxcopanalyzers-package-versions to install the correct analyzer version.</value>
</data>
<data name="VersionCheckMessage" xml:space="preserve">
<value>Version mismatch between the analyzer package '{0}' and Microsoft.CodeAnalysis '{1}'. Certain analyzers in this package will not run until the version mismatch is fixed. Analyzers in this package are preview version and are tied to a specific API version of Microsoft.CodeAnalysis. Please switch your analyzer NuGet package/VSIX to a matching version of the Microsoft.CodeAnalysis.</value>
<value>Version mismatch between the analyzer package '{0}' and Microsoft.CodeAnalysis '{1}'. Certain analyzers in this package will not run until the version mismatch is fixed. Refer to https://docs.microsoft.com/en-us/visualstudio/code-quality/install-fxcop-analyzers?view=vs-2017#fxcopanalyzers-package-versions to install the correct analyzer version.</value>
</data>
<data name="VersionCheckTitle" xml:space="preserve">
<value>Analyzer version mismatch</value>
Expand Down
Expand Up @@ -15,7 +15,7 @@ public sealed class AnalyzerVersionCheckAnalyzer : DiagnosticAnalyzer
private const string RuleId = "CA9999";

// TODO: Below version must be autogenerated using the project properties.
private const string RequiredMicrosoftCodeAnalysisVersion = "2.6.0";
private const string RequiredMicrosoftCodeAnalysisVersion = "2.9.0";

private static readonly LocalizableString s_localizableTitle = new LocalizableResourceString(nameof(MicrosoftCodeAnalysisVersionCheckAnalyzerResources.VersionCheckTitle), MicrosoftCodeAnalysisVersionCheckAnalyzerResources.ResourceManager, typeof(MicrosoftCodeAnalysisVersionCheckAnalyzerResources));
private static readonly LocalizableString s_localizableMessageFormat = new LocalizableResourceString(nameof(MicrosoftCodeAnalysisVersionCheckAnalyzerResources.VersionCheckMessage), MicrosoftCodeAnalysisVersionCheckAnalyzerResources.ResourceManager, typeof(MicrosoftCodeAnalysisVersionCheckAnalyzerResources));
Expand Down
Expand Up @@ -3,13 +3,13 @@
<file datatype="xml" source-language="en" target-language="cs" original="../MicrosoftCodeAnalysisVersionCheckAnalyzerResources.resx">
<body>
<trans-unit id="VersionCheckDescription">
<source>Analyzers in this package are preview version and are tied to a specific API version of Microsoft.CodeAnalysis. You have a mismatch between the analyzer and Microsoft.CodeAnalysis version and should switch your analyzer NuGet package/VSIX to a matching version of the Microsoft.CodeAnalysis.</source>
<target state="new">Analyzers in this package are preview version and are tied to a specific API version of Microsoft.CodeAnalysis. You have a mismatch between the analyzer and Microsoft.CodeAnalysis version and should switch your analyzer NuGet package/VSIX to a matching version of the Microsoft.CodeAnalysis.</target>
<source>Analyzers in this package require a certain minimum version of Microsoft.CodeAnalysis to execute correctly. Refer to https://docs.microsoft.com/en-us/visualstudio/code-quality/install-fxcop-analyzers?view=vs-2017#fxcopanalyzers-package-versions to install the correct analyzer version.</source>
<target state="new">Analyzers in this package require a certain minimum version of Microsoft.CodeAnalysis to execute correctly. Refer to https://docs.microsoft.com/en-us/visualstudio/code-quality/install-fxcop-analyzers?view=vs-2017#fxcopanalyzers-package-versions to install the correct analyzer version.</target>
<note />
</trans-unit>
<trans-unit id="VersionCheckMessage">
<source>Version mismatch between the analyzer package '{0}' and Microsoft.CodeAnalysis '{1}'. Certain analyzers in this package will not run until the version mismatch is fixed. Analyzers in this package are preview version and are tied to a specific API version of Microsoft.CodeAnalysis. Please switch your analyzer NuGet package/VSIX to a matching version of the Microsoft.CodeAnalysis.</source>
<target state="new">Version mismatch between the analyzer package '{0}' and Microsoft.CodeAnalysis '{1}'. Certain analyzers in this package will not run until the version mismatch is fixed. Analyzers in this package are preview version and are tied to a specific API version of Microsoft.CodeAnalysis. Please switch your analyzer NuGet package/VSIX to a matching version of the Microsoft.CodeAnalysis.</target>
<source>Version mismatch between the analyzer package '{0}' and Microsoft.CodeAnalysis '{1}'. Certain analyzers in this package will not run until the version mismatch is fixed. Refer to https://docs.microsoft.com/en-us/visualstudio/code-quality/install-fxcop-analyzers?view=vs-2017#fxcopanalyzers-package-versions to install the correct analyzer version.</source>
<target state="new">Version mismatch between the analyzer package '{0}' and Microsoft.CodeAnalysis '{1}'. Certain analyzers in this package will not run until the version mismatch is fixed. Refer to https://docs.microsoft.com/en-us/visualstudio/code-quality/install-fxcop-analyzers?view=vs-2017#fxcopanalyzers-package-versions to install the correct analyzer version.</target>
<note />
</trans-unit>
<trans-unit id="VersionCheckTitle">
Expand Down

0 comments on commit ea7ff1c

Please sign in to comment.