diff --git a/.markdownlint.json b/.markdownlint.json
index c464661bec..183fb8f237 100644
--- a/.markdownlint.json
+++ b/.markdownlint.json
@@ -1,6 +1,7 @@
{
"default": true,
"MD013": false,
+ "MD024": false,
"MD026": false,
"MD041": false,
"MD046": {
diff --git a/Directory.Build.props b/Directory.Build.props
index 7a056e3aae..efc14905e8 100644
--- a/Directory.Build.props
+++ b/Directory.Build.props
@@ -12,6 +12,11 @@
+
+
+ false
+
+
preview
16
diff --git a/README.md b/README.md
index 44f4e31f11..c70f4a7360 100644
--- a/README.md
+++ b/README.md
@@ -16,6 +16,20 @@ Microsoft created a set of analyzers called [Microsoft.CodeAnalysis.FxCopAnalyze
## Main analyzers
+Recently the set of analyzer packages produced by this repository have been consolidated. The following table summarizes this information:
+
+| NuGet Package Name | Version | Summary |
+|----------|:-------:|---------|
+| Microsoft.CodeAnalysis.NetAnalyzers | [![NuGet](https://img.shields.io/nuget/v/Microsoft.CodeAnalysis.NetAnalyzers.svg)](https://www.nuget.org/packages/Microsoft.CodeAnalysis.NetAnalyzers) | ✔️ Primary analyzer package for this repo. Included default for .NET 5+. For earlier targets [read more](#microsoftcodeanalysisnetanalyzers). |
+| Microsoft.CodeAnalysis.BannedApiAnalyzers | [![NuGet](https://img.shields.io/nuget/v/Microsoft.CodeAnalysis.BannedApiAnalyzers.svg)](https://www.nuget.org/packages/Microsoft.CodeAnalysis.BannedApiAnalyzers) | ✔️ Allows banning use of arbitrary code. [Read more](#microsoftcodeanalysisbannedapianalyzers). |
+| Microsoft.CodeAnalysis.PublicApiAnalyzers | [![NuGet](https://img.shields.io/nuget/v/Microsoft.CodeAnalysis.PublicApiAnalyzers.svg)](https://www.nuget.org/packages/Microsoft.CodeAnalysis.PublicApiAnalyzers) | ✔️ Helps library authors monitor changes to their public APIs. [Read more](#microsoftcodeanalysispublicapianalyzers). |
+| Microsoft.CodeAnalysis.Analyzers | [![NuGet](https://img.shields.io/nuget/v/Microsoft.CodeAnalysis.Analyzers.svg)](https://www.nuget.org/packages/Microsoft.CodeAnalysis.Analyzers) | ⚠️ Intended projects providing analyzers and code fixes. [Read more](#microsoftcodeanalysisanalyzers). |
+| Roslyn.Diagnostics.Analyzers | [![NuGet](https://img.shields.io/nuget/v/Roslyn.Diagnostics.Analyzers.svg)](https://www.nuget.org/packages/Roslyn.Diagnostics.Analyzers) | ⚠️ Rules specific to the Roslyn project, not intended for general consumption. [Read more](#roslyndiagnosticsanalyzers). |
+| Microsoft.CodeAnalysis.FxCopAnalyzers | [![NuGet](https://img.shields.io/nuget/v/Microsoft.CodeAnalysis.FxCopAnalyzers.svg)](https://www.nuget.org/packages/Microsoft.CodeAnalysis.FxCopAnalyzers) | ⛔ Use `Microsoft.CodeAnalysis.NetAnalyzers` instead. [Read more](#microsoftcodeanalysisfxcopanalyzers). |
+| Microsoft.CodeQuality.Analyzers | [![NuGet](https://img.shields.io/nuget/v/Microsoft.CodeQuality.Analyzers.svg)](https://www.nuget.org/packages/Microsoft.CodeQuality.Analyzers) | ⛔ Use `Microsoft.CodeAnalysis.NetAnalyzers` instead. [Read more](#microsoftcodequalityanalyzers). |
+| Microsoft.NetCore.Analyzers | [![NuGet](https://img.shields.io/nuget/v/Microsoft.NetCore.Analyzers.svg)](https://www.nuget.org/packages/Microsoft.NetCore.Analyzers) | ⛔ Use `Microsoft.CodeAnalysis.NetAnalyzers` instead. [Read more](#microsoftnetcoreanalyzers). |
+| Microsoft.NetFramework.Analyzers | [![NuGet](https://img.shields.io/nuget/v/Microsoft.NetFramework.Analyzers.svg)](https://www.nuget.org/packages/Microsoft.NetFramework.Analyzers) | ⛔ Use `Microsoft.CodeAnalysis.NetAnalyzers` instead. [Read more](#microsoftnetcoreanalyzers). |
+
### Microsoft.CodeAnalysis.NetAnalyzers
*Latest stable version:* [![NuGet](https://img.shields.io/nuget/v/Microsoft.CodeAnalysis.NetAnalyzers.svg)](https://www.nuget.org/packages/Microsoft.CodeAnalysis.NetAnalyzers)
diff --git a/azure-pipelines.yml b/azure-pipelines.yml
index 77f344f11d..e90ed77c0b 100644
--- a/azure-pipelines.yml
+++ b/azure-pipelines.yml
@@ -91,7 +91,7 @@ jobs:
_configuration: Release
pool:
name: NetCorePublic-Pool
- queue: BuildPool.Ubuntu.1604.amd64.Open
+ queue: BuildPool.Ubuntu.1804.amd64.Open
timeoutInMinutes: 40
steps:
- checkout: self
@@ -122,5 +122,5 @@ jobs:
steps:
- script: sudo npm install -g markdownlint-cli
displayName: Install markdownlint-cli
- - script: markdownlint '**/*.md' -i '**/AnalyzerReleases.*.md' -i 'docs/Analyzer reference page template.md' -i 'eng/common/**/*.md'
+ - script: markdownlint '**/*.md' -i 'docs/Analyzer reference page template.md' -i 'eng/common/**/*.md'
displayName: Run markdownlint
diff --git a/eng/GenerateAnalyzerNuspec.targets b/eng/GenerateAnalyzerNuspec.targets
index e444794396..a79e9d33ff 100644
--- a/eng/GenerateAnalyzerNuspec.targets
+++ b/eng/GenerateAnalyzerNuspec.targets
@@ -144,7 +144,7 @@
<_NuspecMetadata Include="copyright=$(Copyright)" />
<_NuspecMetadata Include="license=$(PackageLicenseExpression)" />
<_NuspecMetadata Include="projectUrl=$(PackageProjectUrl)" />
- <_NuspecMetadata Include="iconUrl=$(PackageIconUrl)" />
+ <_NuspecMetadata Include="icon=$(PackageIcon)" />
<_NuspecMetadata Include="releaseNotes=$(PackageReleaseNotes)" />
<_NuspecMetadata Include="tags=$(PackageTags)" />
<_NuspecMetadata Include="serviceable=$(Serviceable)" />
diff --git a/eng/Signing.props b/eng/Signing.props
new file mode 100644
index 0000000000..586fe4875a
--- /dev/null
+++ b/eng/Signing.props
@@ -0,0 +1,5 @@
+
+
+ true
+
+
diff --git a/eng/Version.Details.xml b/eng/Version.Details.xml
index 7ac6d116ad..ac27761e27 100644
--- a/eng/Version.Details.xml
+++ b/eng/Version.Details.xml
@@ -3,9 +3,9 @@
-
+
https://github.com/dotnet/arcade
- 1d951297eb7bdd29a31dff3149606152717ed6b4
+ c5c6ef92686f208055e884bad45d32966f0b1f95
diff --git a/eng/Versions.props b/eng/Versions.props
index d2adbd8cf1..1bb2b1edb1 100644
--- a/eng/Versions.props
+++ b/eng/Versions.props
@@ -3,7 +3,7 @@
3.3.3
beta1
6.0.0
- preview4
+ preview5
$(VersionPrefix)
$(NetAnalyzersVersionPrefix)
diff --git a/nuget/PublicApiAnalyzers/Microsoft.CodeAnalysis.PublicApiAnalyzers.Package.csproj b/nuget/PublicApiAnalyzers/Microsoft.CodeAnalysis.PublicApiAnalyzers.Package.csproj
index c290a3127e..741235007a 100644
--- a/nuget/PublicApiAnalyzers/Microsoft.CodeAnalysis.PublicApiAnalyzers.Package.csproj
+++ b/nuget/PublicApiAnalyzers/Microsoft.CodeAnalysis.PublicApiAnalyzers.Package.csproj
@@ -13,6 +13,7 @@
Roslyn CodeAnalysis Compiler CSharp VB VisualBasic Diagnostic Analyzers Syntax Semantics PublicApi ApiAnalyzer
$(RepoRoot)src\PublicApiAnalyzers
$(RepoRoot)src\PublicApiAnalyzers
+ true
diff --git a/nuget/Roslyn.Diagnostics.Analyzers/Roslyn.Diagnostics.Analyzers.Package.csproj b/nuget/Roslyn.Diagnostics.Analyzers/Roslyn.Diagnostics.Analyzers.Package.csproj
index 0ad37d3e79..4525797672 100644
--- a/nuget/Roslyn.Diagnostics.Analyzers/Roslyn.Diagnostics.Analyzers.Package.csproj
+++ b/nuget/Roslyn.Diagnostics.Analyzers/Roslyn.Diagnostics.Analyzers.Package.csproj
@@ -10,6 +10,7 @@
Roslyn.Diagnostics Analyzers
Roslyn.Diagnostics Analyzers
Roslyn CodeAnalysis Compiler CSharp VB VisualBasic Diagnostic Analyzers Syntax Semantics
+ true
diff --git a/nuget/Text.Analyzers/Text.Analyzers.Package.csproj b/nuget/Text.Analyzers/Text.Analyzers.Package.csproj
index df3ae1f1f3..f8dc0d7020 100644
--- a/nuget/Text.Analyzers/Text.Analyzers.Package.csproj
+++ b/nuget/Text.Analyzers/Text.Analyzers.Package.csproj
@@ -11,6 +11,7 @@
Text Analyzers
Text Analyzers
Roslyn CodeAnalysis Compiler CSharp VB VisualBasic Diagnostic Analyzers Syntax Semantics
+ true
true
diff --git a/src/Microsoft.CodeAnalysis.Analyzers/CSharp/AnalyzerReleases.Shipped.md b/src/Microsoft.CodeAnalysis.Analyzers/CSharp/AnalyzerReleases.Shipped.md
index 4356fad5fd..f19591db48 100644
--- a/src/Microsoft.CodeAnalysis.Analyzers/CSharp/AnalyzerReleases.Shipped.md
+++ b/src/Microsoft.CodeAnalysis.Analyzers/CSharp/AnalyzerReleases.Shipped.md
@@ -1,6 +1,7 @@
## Release 2.9.8
### New Rules
+
Rule ID | Category | Severity | Notes
--------|----------|----------|-------
-RS1014 | MicrosoftCodeAnalysisCorrectness | Warning | CSharpImmutableObjectMethodAnalyzer
\ No newline at end of file
+RS1014 | MicrosoftCodeAnalysisCorrectness | Warning | CSharpImmutableObjectMethodAnalyzer
diff --git a/src/Microsoft.CodeAnalysis.Analyzers/Core/AnalyzerReleases.Shipped.md b/src/Microsoft.CodeAnalysis.Analyzers/Core/AnalyzerReleases.Shipped.md
index df4983403b..7ce0a429a3 100644
--- a/src/Microsoft.CodeAnalysis.Analyzers/Core/AnalyzerReleases.Shipped.md
+++ b/src/Microsoft.CodeAnalysis.Analyzers/Core/AnalyzerReleases.Shipped.md
@@ -1,6 +1,7 @@
## Release 3.0.0
### New Rules
+
Rule ID | Category | Severity | Notes
--------|----------|----------|-------
RS1024 | MicrosoftCodeAnalysisCorrectness | Warning | CompareSymbolsCorrectlyAnalyzer
@@ -20,10 +21,10 @@ RS2006 | MicrosoftCodeAnalysisReleaseTracking | Warning | DiagnosticDescriptorCr
RS2007 | MicrosoftCodeAnalysisReleaseTracking | Warning | DiagnosticDescriptorCreationAnalyzer, [Documentation](https://github.com/dotnet/roslyn-analyzers/blob/main/src/Microsoft.CodeAnalysis.Analyzers/ReleaseTrackingAnalyzers.Help.md)
RS2008 | MicrosoftCodeAnalysisReleaseTracking | Warning | DiagnosticDescriptorCreationAnalyzer, [Documentation](https://github.com/dotnet/roslyn-analyzers/blob/main/src/Microsoft.CodeAnalysis.Analyzers/ReleaseTrackingAnalyzers.Help.md)
-
## Release 2.9.8
### New Rules
+
Rule ID | Category | Severity | Notes
--------|----------|----------|-------
RS1001 | MicrosoftCodeAnalysisCorrectness | Warning | DiagnosticAnalyzerAttributeAnalyzer
@@ -52,6 +53,7 @@ RS1023 | Library | Warning | UpgradeMSBuildWorkspaceAnalyzer
## Release 3.3.0
### New Rules
+
Rule ID | Category | Severity | Notes
--------|----------|----------|-------
RS1031 | MicrosoftCodeAnalysisDesign | Warning | DiagnosticDescriptorCreationAnalyzer
diff --git a/src/Microsoft.CodeAnalysis.Analyzers/Core/AnalyzerReleases.Unshipped.md b/src/Microsoft.CodeAnalysis.Analyzers/Core/AnalyzerReleases.Unshipped.md
index 72c1634f2a..c2e30e9f91 100644
--- a/src/Microsoft.CodeAnalysis.Analyzers/Core/AnalyzerReleases.Unshipped.md
+++ b/src/Microsoft.CodeAnalysis.Analyzers/Core/AnalyzerReleases.Unshipped.md
@@ -1,6 +1,7 @@
; Please do not edit this file manually, it should only be updated through code fix application.
### New Rules
+
Rule ID | Category | Severity | Notes
--------|----------|----------|-------
RS1034 | MicrosoftCodeAnalysisPerformance | Warning | PreferIsKindAnalyzer
diff --git a/src/Microsoft.CodeAnalysis.Analyzers/Core/MetaAnalyzers/CompareSymbolsCorrectlyAnalyzer.cs b/src/Microsoft.CodeAnalysis.Analyzers/Core/MetaAnalyzers/CompareSymbolsCorrectlyAnalyzer.cs
index 216940bfe0..5ebe82460a 100644
--- a/src/Microsoft.CodeAnalysis.Analyzers/Core/MetaAnalyzers/CompareSymbolsCorrectlyAnalyzer.cs
+++ b/src/Microsoft.CodeAnalysis.Analyzers/Core/MetaAnalyzers/CompareSymbolsCorrectlyAnalyzer.cs
@@ -21,6 +21,7 @@ public class CompareSymbolsCorrectlyAnalyzer : DiagnosticAnalyzer
private static readonly string s_symbolTypeFullName = typeof(ISymbol).FullName;
private const string s_symbolEqualsName = nameof(ISymbol.Equals);
+ private const string s_HashCodeCombineName = "Combine";
public const string SymbolEqualityComparerName = "Microsoft.CodeAnalysis.SymbolEqualityComparer";
public static readonly DiagnosticDescriptor EqualityRule = new(
@@ -78,9 +79,10 @@ public override void Initialize(AnalysisContext context)
OperationKind.BinaryOperator);
var equalityComparerMethods = GetEqualityComparerMethodsToCheck(compilation);
+ var systemHashCode = compilation.GetOrCreateTypeByMetadataName(WellKnownTypeNames.SystemHashCode);
context.RegisterOperationAction(
- context => HandleInvocationOperation(in context, symbolType, symbolEqualityComparerType, equalityComparerMethods),
+ context => HandleInvocationOperation(in context, symbolType, symbolEqualityComparerType, equalityComparerMethods, systemHashCode),
OperationKind.Invocation);
if (symbolEqualityComparerType != null)
@@ -140,8 +142,12 @@ private static void HandleBinaryOperator(in OperationAnalysisContext context, IN
context.ReportDiagnostic(binary.Syntax.GetLocation().CreateDiagnostic(EqualityRule));
}
- private static void HandleInvocationOperation(in OperationAnalysisContext context, INamedTypeSymbol symbolType,
- INamedTypeSymbol? symbolEqualityComparerType, ImmutableDictionary> equalityComparerMethods)
+ private static void HandleInvocationOperation(
+ in OperationAnalysisContext context,
+ INamedTypeSymbol symbolType,
+ INamedTypeSymbol? symbolEqualityComparerType,
+ ImmutableDictionary> equalityComparerMethods,
+ INamedTypeSymbol? systemHashCodeType)
{
var invocationOperation = (IInvocationOperation)context.Operation;
var method = invocationOperation.TargetMethod;
@@ -149,14 +155,16 @@ private static void HandleInvocationOperation(in OperationAnalysisContext contex
switch (method.Name)
{
case WellKnownMemberNames.ObjectGetHashCode:
- if (IsNotInstanceInvocationOrNotOnSymbol(invocationOperation, symbolType))
+ // This is a call for an instance of ISymbol.GetHashCode()
+ // without the correct arguments
+ if (IsSymbolType(invocationOperation.Instance, symbolType))
{
context.ReportDiagnostic(invocationOperation.CreateDiagnostic(GetHashCodeRule));
}
break;
case s_symbolEqualsName:
- if (symbolEqualityComparerType != null && IsNotInstanceInvocationOrNotOnSymbol(invocationOperation, symbolType))
+ if (symbolEqualityComparerType is not null && IsNotInstanceInvocationOrNotOnSymbol(invocationOperation, symbolType))
{
var parameters = invocationOperation.Arguments;
if (parameters.All(p => IsSymbolType(p.Value, symbolType)))
@@ -166,10 +174,21 @@ private static void HandleInvocationOperation(in OperationAnalysisContext contex
}
break;
+ case s_HashCodeCombineName:
+ // A call System.HashCode.Combine(ISymbol) will do the wrong thing and should be avoided
+ if (systemHashCodeType is not null &&
+ invocationOperation.Instance is null &&
+ systemHashCodeType.Equals(method.ContainingType, SymbolEqualityComparer.Default) &&
+ invocationOperation.Arguments.Any(arg => IsSymbolType(arg.Value, symbolType)))
+ {
+ context.ReportDiagnostic(invocationOperation.CreateDiagnostic(GetHashCodeRule));
+ }
+ break;
+
default:
if (equalityComparerMethods.TryGetValue(method.Name, out var possibleMethodTypes))
{
- if (symbolEqualityComparerType != null &&
+ if (symbolEqualityComparerType is not null &&
possibleMethodTypes.Contains(method.ContainingType.OriginalDefinition) &&
IsBehavingOnSymbolType(method, symbolType) &&
!invocationOperation.Arguments.Any(arg => IsSymbolType(arg.Value, symbolEqualityComparerType)))
@@ -228,9 +247,9 @@ private static void HandleObjectCreation(in OperationAnalysisContext context, IN
}
}
- private static bool IsSymbolType(IOperation operation, INamedTypeSymbol symbolType)
+ private static bool IsSymbolType(IOperation? operation, INamedTypeSymbol symbolType)
{
- if (operation.Type is object && IsSymbolType(operation.Type, symbolType))
+ if (operation?.Type is object && IsSymbolType(operation.Type, symbolType))
{
return true;
}
diff --git a/src/Microsoft.CodeAnalysis.Analyzers/Core/xlf/CodeAnalysisDiagnosticsResources.fr.xlf b/src/Microsoft.CodeAnalysis.Analyzers/Core/xlf/CodeAnalysisDiagnosticsResources.fr.xlf
index ab6b2bfd35..876746cf5c 100644
--- a/src/Microsoft.CodeAnalysis.Analyzers/Core/xlf/CodeAnalysisDiagnosticsResources.fr.xlf
+++ b/src/Microsoft.CodeAnalysis.Analyzers/Core/xlf/CodeAnalysisDiagnosticsResources.fr.xlf
@@ -259,7 +259,7 @@
- Utilisez 'syntax.IsKind(kind)' au lieu de 'syntax.Kind() == kind' pour la vérification des genres de syntaxe. Dans la mesure où le code utilisant 'IsKind' est légèrement plus efficace au moment de l'exécution, l'utilisation systématique de cette forme permet d'améliorer les performances dans les scénarios d'analyse complexes.
+ Utilisez 'syntax.IsKind(kind)' au lieu de 'syntax.Kind() == kind' pour la vérification des genres de syntaxe. Dans la mesure où le code utilisant 'IsKind' est légèrement plus efficace au moment de l'exécution, l'utilisation cohérente de ce formulaire permet d'améliorer les performances dans les scénarios d'analyse complexes.
diff --git a/src/Microsoft.CodeAnalysis.Analyzers/Core/xlf/CodeAnalysisDiagnosticsResources.ja.xlf b/src/Microsoft.CodeAnalysis.Analyzers/Core/xlf/CodeAnalysisDiagnosticsResources.ja.xlf
index c3edebc972..2d4594133c 100644
--- a/src/Microsoft.CodeAnalysis.Analyzers/Core/xlf/CodeAnalysisDiagnosticsResources.ja.xlf
+++ b/src/Microsoft.CodeAnalysis.Analyzers/Core/xlf/CodeAnalysisDiagnosticsResources.ja.xlf
@@ -304,7 +304,7 @@
- アナライザー リリース間で診断 ID の重複しているエントリを削除してください
+ アナライザー リリース間で診断 ID の重複しているエントリを削除する
diff --git a/src/Microsoft.CodeAnalysis.Analyzers/Core/xlf/CodeAnalysisDiagnosticsResources.ko.xlf b/src/Microsoft.CodeAnalysis.Analyzers/Core/xlf/CodeAnalysisDiagnosticsResources.ko.xlf
index 735d8f20c2..86d75d1d02 100644
--- a/src/Microsoft.CodeAnalysis.Analyzers/Core/xlf/CodeAnalysisDiagnosticsResources.ko.xlf
+++ b/src/Microsoft.CodeAnalysis.Analyzers/Core/xlf/CodeAnalysisDiagnosticsResources.ko.xlf
@@ -557,7 +557,7 @@
- 사용자가 단일 코드 수정 사항을 사용하여 기본 진단의 여러 인스턴스를 수정할 수 있도록 하려면 CodeFixProvider가 FixAll 지원을 제공해야 합니다. 자세한 내용은 https://github.com/dotnet/roslyn/blob/main/docs/analyzers/FixAllProvider.md의 설명서를 참조하세요.
+ 사용자가 단일 코드 수정 사항을 사용하여 기본 진단의 여러 인스턴스를 수정할 수 있도록 하려면 CodeFixProvider가 FixAll 지원을 제공해야 합니다. 자세한 내용은 https://github.com/dotnet/roslyn/blob/main/docs/analyzers/FixAllProvider.md에 있는 문서를 참조하세요.
@@ -692,4 +692,4 @@