Skip to content

Commit a965593

Browse files
committed
Merge remote-tracking branch 'DotNetAnalyzers/master' into dowhile
2 parents bfbb4ca + e7af4b3 commit a965593

File tree

874 files changed

+29424
-3176
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

874 files changed

+29424
-3176
lines changed

.editorconfig

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ indent_size = 4
1212

1313
# Sort using and Import directives with System.* appearing first
1414
dotnet_sort_system_directives_first = true
15+
dotnet_separate_import_directive_groups = false
16+
csharp_using_directive_placement = inside_namespace:none
1517

1618
# Always use "this." and "Me." when applicable; let StyleCop Analyzers provide the warning and fix
1719
dotnet_style_qualification_for_field = true:none

NuGet.config

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
<packageSources>
44
<clear />
55
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" />
6-
<add key="roslyn" value="https://dotnet.myget.org/F/roslyn/api/v3/index.json" />
7-
<add key="roslyn-analyzers" value="https://dotnet.myget.org/F/roslyn-analyzers/api/v3/index.json" />
6+
<add key="dotnet-tools" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-tools/nuget/v3/index.json" />
7+
<add key="dotnet5" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet5/nuget/v3/index.json" />
88

99
<!-- Uncomment this to test unpublished builds from the AppVeyor feed. -->
1010
<!--<add key="appveyor-stylecop" value="https://ci.appveyor.com/nuget/stylecopanalyzers" />-->

StyleCop.Analyzers/Directory.Build.props

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
</PropertyGroup>
1111

1212
<PropertyGroup>
13-
<LangVersion>8</LangVersion>
14-
<Features>strict</Features>
13+
<LangVersion>9</LangVersion>
14+
<WarningLevel>5</WarningLevel>
1515
</PropertyGroup>
1616

1717
<PropertyGroup Condition="'$(BuildingInsideVisualStudio)' != 'true'">
@@ -45,8 +45,14 @@
4545
<ItemGroup>
4646
<PackageReference Include="AsyncUsageAnalyzers" Version="1.0.0-alpha003" PrivateAssets="all" />
4747
<PackageReference Include="DotNetAnalyzers.DocumentationAnalyzers" Version="1.0.0-beta.46" PrivateAssets="all" />
48-
<PackageReference Include="StyleCop.Analyzers" Version="1.2.0-beta.66" PrivateAssets="all" />
49-
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.CodeStyle" Version="3.6.0-4.20251.5" PrivateAssets="all" />
48+
<PackageReference Include="StyleCop.Analyzers" Version="1.2.0-beta.304" PrivateAssets="all" />
49+
<PackageReference Include="Microsoft.CodeAnalysis.Analyzers" Version="3.3.0" PrivateAssets="all" />
50+
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.CodeStyle" Version="3.8.0" PrivateAssets="all" />
51+
</ItemGroup>
52+
53+
<!-- C# Compiler -->
54+
<ItemGroup>
55+
<PackageReference Include="Microsoft.Net.Compilers.Toolset" Version="3.8.0" PrivateAssets="all" />
5056
</ItemGroup>
5157

5258
<!-- Public API -->

StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/DocumentationRules/FileHeaderCodeFixProvider.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ private static async Task<Document> GetTransformedDocumentAsync(Document documen
7777
private static async Task<SyntaxNode> GetTransformedSyntaxRootAsync(Document document, CancellationToken cancellationToken)
7878
{
7979
var root = await document.GetSyntaxRootAsync(cancellationToken).ConfigureAwait(false);
80-
var settings = document.Project.AnalyzerOptions.GetStyleCopSettings(cancellationToken);
80+
var settings = document.Project.AnalyzerOptions.GetStyleCopSettings(root.SyntaxTree, cancellationToken);
8181

8282
var fileHeader = FileHeaderHelpers.ParseFileHeader(root);
8383
SyntaxNode newSyntaxRoot;

StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/DocumentationRules/PropertySummaryDocumentationCodeFixProvider.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ namespace StyleCop.Analyzers.DocumentationRules
1414
using Microsoft.CodeAnalysis.CSharp;
1515
using Microsoft.CodeAnalysis.CSharp.Syntax;
1616
using StyleCop.Analyzers.Helpers;
17-
using StyleCop.Analyzers.Helpers.ObjectPools;
1817

1918
/// <summary>
2019
/// Implements the code fix for property summary documentation.

StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/DocumentationRules/SA1600CodeFixProvider.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33

44
namespace StyleCop.Analyzers.DocumentationRules
55
{
6-
using System;
76
using System.Collections.Generic;
87
using System.Collections.Immutable;
98
using System.Composition;

StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/DocumentationRules/SA1642SA1643CodeFixProvider.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ public override async Task RegisterCodeFixesAsync(CodeFixContext context)
8282
internal static ImmutableArray<string> GenerateStandardText(Document document, BaseMethodDeclarationSyntax methodDeclaration, BaseTypeDeclarationSyntax typeDeclaration, CancellationToken cancellationToken)
8383
{
8484
bool isStruct = typeDeclaration.IsKind(SyntaxKind.StructDeclaration);
85-
var settings = document.Project.AnalyzerOptions.GetStyleCopSettings(cancellationToken);
85+
var settings = document.Project.AnalyzerOptions.GetStyleCopSettings(methodDeclaration.SyntaxTree, cancellationToken);
8686
var culture = new CultureInfo(settings.DocumentationRules.DocumentationCulture);
8787
var resourceManager = DocumentationResources.ResourceManager;
8888

StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/Helpers/FixAllContextHelper.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ namespace StyleCop.Analyzers.Helpers
1212
using System.Threading.Tasks;
1313
using Microsoft.CodeAnalysis;
1414
using Microsoft.CodeAnalysis.CodeFixes;
15-
using Microsoft.CodeAnalysis.Diagnostics;
1615

1716
internal static class FixAllContextHelper
1817
{
@@ -56,7 +55,8 @@ public static async Task<ImmutableDictionary<Document, ImmutableArray<Diagnostic
5655
{
5756
var projectDiagnostics = await GetAllDiagnosticsAsync(fixAllContext, projectToFix).ConfigureAwait(false);
5857
diagnostics.TryAdd(projectToFix.Id, projectDiagnostics);
59-
}, fixAllContext.CancellationToken);
58+
},
59+
fixAllContext.CancellationToken);
6060
}
6161

6262
await Task.WhenAll(tasks).ConfigureAwait(false);

StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/LayoutRules/SA1500CodeFixProvider.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ private static async Task<Document> GetTransformedDocumentAsync(Document documen
5555
{
5656
var syntaxRoot = await document.GetSyntaxRootAsync(cancellationToken).ConfigureAwait(false);
5757

58-
var settings = SettingsHelper.GetStyleCopSettings(document.Project.AnalyzerOptions, cancellationToken);
58+
var settings = SettingsHelper.GetStyleCopSettings(document.Project.AnalyzerOptions, syntaxRoot.SyntaxTree, cancellationToken);
5959
var braceToken = syntaxRoot.FindToken(diagnostic.Location.SourceSpan.Start);
6060
var tokenReplacements = GenerateBraceFixes(settings, ImmutableArray.Create(braceToken));
6161

@@ -286,7 +286,7 @@ protected override async Task<SyntaxNode> FixAllInDocumentAsync(FixAllContext fi
286286
.OrderBy(token => token.SpanStart)
287287
.ToImmutableArray();
288288

289-
var settings = SettingsHelper.GetStyleCopSettings(document.Project.AnalyzerOptions, fixAllContext.CancellationToken);
289+
var settings = SettingsHelper.GetStyleCopSettings(document.Project.AnalyzerOptions, syntaxRoot.SyntaxTree, fixAllContext.CancellationToken);
290290

291291
var tokenReplacements = GenerateBraceFixes(settings, tokens);
292292

StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/LayoutRules/SA1501CodeFixProvider.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public override Task RegisterCodeFixesAsync(CodeFixContext context)
5858
private static async Task<Document> GetTransformedDocumentAsync(Document document, Diagnostic diagnostic, CancellationToken cancellationToken)
5959
{
6060
var syntaxRoot = await document.GetSyntaxRootAsync(cancellationToken).ConfigureAwait(false);
61-
var settings = SettingsHelper.GetStyleCopSettings(document.Project.AnalyzerOptions, cancellationToken);
61+
var settings = SettingsHelper.GetStyleCopSettings(document.Project.AnalyzerOptions, syntaxRoot.SyntaxTree, cancellationToken);
6262
if (!(syntaxRoot.FindNode(diagnostic.Location.SourceSpan, getInnermostNodeForTie: true) is StatementSyntax statement))
6363
{
6464
return document;
@@ -301,8 +301,8 @@ protected override async Task<SyntaxNode> FixAllInDocumentAsync(FixAllContext fi
301301
}
302302

303303
var tokenReplaceMap = new Dictionary<SyntaxToken, SyntaxToken>();
304-
var settings = SettingsHelper.GetStyleCopSettings(document.Project.AnalyzerOptions, fixAllContext.CancellationToken);
305304
SyntaxNode syntaxRoot = await document.GetSyntaxRootAsync(fixAllContext.CancellationToken).ConfigureAwait(false);
305+
var settings = SettingsHelper.GetStyleCopSettings(document.Project.AnalyzerOptions, syntaxRoot.SyntaxTree, fixAllContext.CancellationToken);
306306

307307
foreach (var diagnostic in diagnostics.Sort(DiagnosticComparer.Instance))
308308
{

0 commit comments

Comments
 (0)