Skip to content

Commit ea7ff1c

Browse files
authored
Merge pull request #2232 from mavasani/VersionCheckAnalyzer
Fix the VersionCheckAnalyzer to work correctly on Dev15 and above
2 parents a53d969 + 95c8dbb commit ea7ff1c

File tree

29 files changed

+140
-160
lines changed

29 files changed

+140
-160
lines changed

README.md

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,17 @@ This is the **primary analyzer package** for this repo that contains all **the p
2020

2121
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**.
2222

23+
[More info about rules in this package](src/Microsoft.CodeAnalysis.FxCopAnalyzers/Microsoft.CodeAnalysis.FxCopAnalyzers.md)
24+
2325
This analyzer package contains the following subpackages or NuGet dependencies that are automatically installed when you install the Microsoft.CodeAnalysis.FxCopAnalyzers package:
2426

2527
### Microsoft.CodeQuality.Analyzers
2628

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

29-
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.
31+
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.
3032

31-
[More info](src/Microsoft.CodeQuality.Analyzers/Microsoft.CodeQuality.Analyzers.md)
33+
[More info about rules in this package](src/Microsoft.CodeQuality.Analyzers/Microsoft.CodeQuality.Analyzers.md)
3234

3335
### Microsoft.NetCore.Analyzers
3436

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

3941
**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.
4042

41-
[More info](src/Microsoft.NetCore.Analyzers/Microsoft.NetCore.Analyzers.md)
43+
[More info about rules in this package](src/Microsoft.NetCore.Analyzers/Microsoft.NetCore.Analyzers.md)
4244

4345
### Microsoft.NetFramework.Analyzers
4446

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

4951
**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.
5052

51-
[More info](src/Microsoft.NetFramework.Analyzers/Microsoft.NetFramework.Analyzers.md)
53+
[More info about rules in this package](src/Microsoft.NetFramework.Analyzers/Microsoft.NetFramework.Analyzers.md)
5254

5355

5456
Other analyzer packages
@@ -60,7 +62,7 @@ Other analyzer packages
6062

6163
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.
6264

63-
[More info](src/Microsoft.CodeAnalysis.Analyzers/Microsoft.CodeAnalysis.Analyzers.md)
65+
[More info about rules in this package](src/Microsoft.CodeAnalysis.Analyzers/Microsoft.CodeAnalysis.Analyzers.md)
6466

6567

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

7072
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.
7173

72-
[More info](src/Roslyn.Diagnostics.Analyzers/Roslyn.Diagnostics.Analyzers.md)
74+
[More info about rules in this package](src/Roslyn.Diagnostics.Analyzers/Roslyn.Diagnostics.Analyzers.md)
7375

7476

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

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

81-
[More info](src/Microsoft.CodeAnalysis.BannedApiAnalyzers/Microsoft.CodeAnalysis.BannedApiAnalyzers.md)
83+
[More info about rules in this package](src/Microsoft.CodeAnalysis.BannedApiAnalyzers/Microsoft.CodeAnalysis.BannedApiAnalyzers.md)
8284

8385
### Microsoft.CodeAnalysis.PublicApiAnalyzers
8486

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

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

89-
[More info](src/src/PublicApiAnalyzers/Microsoft.CodeAnalysis.PublicApiAnalyzers.md)
91+
[More info about rules in this package](src/PublicApiAnalyzers/Microsoft.CodeAnalysis.PublicApiAnalyzers.md)
9092

9193
### MetaCompilation (prototype)
9294

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

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

101+
[More info about rules in this package](src/MetaCompilation.Analyzers/MetaCompilation.Analyzers.md)
102+
99103
Getting Started
100104
===============
101105

eng/GenerateAnalyzerNuspec.targets

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
</ItemGroup>
4040

4141
<PropertyGroup Condition="'$(GenerateAnalyzerMdFile)' == 'true'">
42-
<AnalyzerDocumentationFileDir>$(RepoRoot)src\$(NuspecPackageId)</AnalyzerDocumentationFileDir>
42+
<AnalyzerDocumentationFileDir Condition="'$(AnalyzerDocumentationFileDir)' == ''">$(RepoRoot)src\$(NuspecPackageId)</AnalyzerDocumentationFileDir>
4343
<AnalyzerDocumentationFileName>$(NuspecPackageId).md</AnalyzerDocumentationFileName>
4444
</PropertyGroup>
4545

nuget/PerformanceSensitiveAnalyzers/Microsoft.CodeAnalysis.PerformanceSensitiveAnalyzers.Package.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
<Summary>PerformanceSensitive Analyzers</Summary>
1010
<ReleaseNotes>PerformanceSensitive Analyzers</ReleaseNotes>
1111
<PackageTags>Roslyn CodeAnalysis Compiler CSharp Diagnostic Analyzers Syntax Semantics Performance</PackageTags>
12+
<AnalyzerDocumentationFileDir>$(RepoRoot)src\PerformanceSensitiveAnalyzers</AnalyzerDocumentationFileDir>
1213
</PropertyGroup>
1314

1415
<ItemGroup>

nuget/PublicApiAnalyzers/Microsoft.CodeAnalysis.PublicApiAnalyzers.Package.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
<Summary>Public API Analyzer</Summary>
1111
<ReleaseNotes>Public API Analyzers</ReleaseNotes>
1212
<PackageTags>Roslyn CodeAnalysis Compiler CSharp VB VisualBasic Diagnostic Analyzers Syntax Semantics PublicApi ApiAnalyzer</PackageTags>
13+
<AnalyzerDocumentationFileDir>$(RepoRoot)src\PublicApiAnalyzers</AnalyzerDocumentationFileDir>
1314
</PropertyGroup>
1415

1516
<Choose>

nuget/Roslyn.Diagnostics.Analyzers/Roslyn.Diagnostics.Analyzers.Package.csproj

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,5 +34,8 @@
3434
<AnalyzerRulesetAssembly Include="Microsoft.CodeAnalysis.BannedApiAnalyzers.dll" />
3535
<AnalyzerRulesetAssembly Include="Microsoft.CodeAnalysis.CSharp.BannedApiAnalyzers.dll" />
3636
<AnalyzerRulesetAssembly Include="Microsoft.CodeAnalysis.VisualBasic.BannedApiAnalyzers.dll" />
37+
<AnalyzerRulesetAssembly Include="Roslyn.Diagnostics.Analyzers.dll" />
38+
<AnalyzerRulesetAssembly Include="Roslyn.Diagnostics.CSharp.Analyzers.dll" />
39+
<AnalyzerRulesetAssembly Include="Roslyn.Diagnostics.VisualBasic.Analyzers.dll" />
3740
</ItemGroup>
3841
</Project>

src/Microsoft.CodeAnalysis.FxCopAnalyzers/Microsoft.CodeAnalysis.FxCopAnalyzers.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,4 +154,4 @@ Sr. No. | Rule ID | Title | Category | Enabled | CodeFix | Description |
154154
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. |
155155
152 | CA5364 | Do Not Use Deprecated Security Protocols | Security | True | False | Using a deprecated security protocol rather than the system default is risky. |
156156
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. |
157-
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. |
157+
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. |

src/Microsoft.CodeAnalysis.PublicApiAnalyzers/Microsoft.CodeAnalysis.PublicApiAnalyzers.md

Lines changed: 0 additions & 10 deletions
This file was deleted.

src/Microsoft.CodeAnalysis.VersionCheckAnalyzer/Microsoft.CodeAnalysis.VersionCheckAnalyzer.csproj

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,22 @@
77
Restore would conclude that there is a cyclic dependency between us and the Microsoft.CodeAnalysis.VersionCheckAnalyzer package.
88
-->
99
<PackageId>*$(MSBuildProjectFullPath)*</PackageId>
10+
<MicrosoftCodeAnalysisVersion>2.0.0</MicrosoftCodeAnalysisVersion>
1011
</PropertyGroup>
12+
13+
<Choose>
14+
<When Condition="'$(TargetFramework)' == 'netstandard1.3'">
15+
<PropertyGroup>
16+
<PackageTargetFallback>portable-net45+win8</PackageTargetFallback>
17+
</PropertyGroup>
18+
</When>
19+
</Choose>
20+
1121
<ItemGroup>
12-
<InternalsVisibleTo Include="Microsoft.CodeAnalysis.UnitTests" />
22+
<Compile Include="..\Utilities\Compiler\DiagnosticCategory.cs" Link="DiagnosticCategory.cs" />
23+
<Compile Include="..\Utilities\Compiler\DiagnosticHelpers.cs" Link="DiagnosticHelpers.cs" />
24+
</ItemGroup>
25+
<ItemGroup>
26+
<PackageReference Include="Microsoft.CodeAnalysis.Common" Version="$(MicrosoftCodeAnalysisVersion)" />
1327
</ItemGroup>
14-
<Import Project="..\Utilities\Compiler\Analyzer.Utilities.projitems" Label="Shared" />
15-
<Import Project="..\Utilities\Workspaces\Workspaces.Utilities.projitems" Label="Shared" />
1628
</Project>
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11

22
Sr. No. | Rule ID | Title | Category | Enabled | CodeFix | Description |
33
--------|---------|-------|----------|---------|---------|--------------------------------------------------------------------------------------------------------------|
4-
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. |
4+
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. |

src/Microsoft.CodeAnalysis.VersionCheckAnalyzer/MicrosoftCodeAnalysisVersionCheckAnalyzerResources.resx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,10 +118,10 @@
118118
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
119119
</resheader>
120120
<data name="VersionCheckDescription" xml:space="preserve">
121-
<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>
121+
<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>
122122
</data>
123123
<data name="VersionCheckMessage" xml:space="preserve">
124-
<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>
124+
<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>
125125
</data>
126126
<data name="VersionCheckTitle" xml:space="preserve">
127127
<value>Analyzer version mismatch</value>

0 commit comments

Comments
 (0)