Skip to content

Commit 98f7f19

Browse files
authored
Merge pull request #3188 from sharwell/update-analyzers
Update Microsoft.CodeAnalysis.Analyzers
2 parents 4602661 + 6683e23 commit 98f7f19

54 files changed

Lines changed: 468 additions & 83 deletions

File tree

Some content is hidden

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

StyleCop.Analyzers/Directory.Build.props

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
<PackageReference Include="AsyncUsageAnalyzers" Version="1.0.0-alpha003" PrivateAssets="all" />
4747
<PackageReference Include="DotNetAnalyzers.DocumentationAnalyzers" Version="1.0.0-beta.46" PrivateAssets="all" />
4848
<PackageReference Include="StyleCop.Analyzers" Version="1.2.0-beta.66" PrivateAssets="all" />
49+
<PackageReference Include="Microsoft.CodeAnalysis.Analyzers" Version="3.3.0" PrivateAssets="all" />
4950
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.CodeStyle" Version="3.6.0-4.20251.5" PrivateAssets="all" />
5051
</ItemGroup>
5152

StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/NamingRules/SA1302CodeFixProvider.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,13 @@ internal class SA1302CodeFixProvider : CodeFixProvider
2828
public override ImmutableArray<string> FixableDiagnosticIds { get; } =
2929
ImmutableArray.Create(SA1302InterfaceNamesMustBeginWithI.DiagnosticId);
3030

31+
/// <inheritdoc/>
32+
public override FixAllProvider GetFixAllProvider()
33+
{
34+
// Fix All is not yet supported
35+
return null;
36+
}
37+
3138
/// <inheritdoc/>
3239
public override Task RegisterCodeFixesAsync(CodeFixContext context)
3340
{

StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/NamingRules/SA1314CodeFixProvider.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,13 @@ internal class SA1314CodeFixProvider : CodeFixProvider
2626
public override ImmutableArray<string> FixableDiagnosticIds { get; } =
2727
ImmutableArray.Create(SA1314TypeParameterNamesMustBeginWithT.DiagnosticId);
2828

29+
/// <inheritdoc/>
30+
public override FixAllProvider GetFixAllProvider()
31+
{
32+
// Fix All is not yet supported
33+
return null;
34+
}
35+
2936
/// <inheritdoc/>
3037
public override Task RegisterCodeFixesAsync(CodeFixContext context)
3138
{

StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/NamingRules/SA1316CodeFixProvider.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,13 @@ internal class SA1316CodeFixProvider : CodeFixProvider
2424
public override ImmutableArray<string> FixableDiagnosticIds { get; } =
2525
ImmutableArray.Create(SA1316TupleElementNamesShouldUseCorrectCasing.DiagnosticId);
2626

27+
/// <inheritdoc/>
28+
public override FixAllProvider GetFixAllProvider()
29+
{
30+
// Fix All is not yet supported
31+
return null;
32+
}
33+
2734
/// <inheritdoc/>
2835
public override Task RegisterCodeFixesAsync(CodeFixContext context)
2936
{

StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/ReadabilityRules/SA1141CodeFixProvider.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,13 @@ internal class SA1141CodeFixProvider : CodeFixProvider
2525
public override ImmutableArray<string> FixableDiagnosticIds { get; } =
2626
ImmutableArray.Create(SA1141UseTupleSyntax.DiagnosticId);
2727

28+
/// <inheritdoc/>
29+
public override FixAllProvider GetFixAllProvider()
30+
{
31+
// Fix All is not yet supported
32+
return null;
33+
}
34+
2835
/// <inheritdoc/>
2936
public override Task RegisterCodeFixesAsync(CodeFixContext context)
3037
{
@@ -125,7 +132,7 @@ private static SyntaxNode TransformArgumentListToTuple(SemanticModel semanticMod
125132
var argument = arguments[i];
126133

127134
var argumentTypeInfo = semanticModel.GetTypeInfo(argument.Expression);
128-
if (argumentTypeInfo.Type != argumentTypeInfo.ConvertedType)
135+
if (!Equals(argumentTypeInfo.Type, argumentTypeInfo.ConvertedType))
129136
{
130137
var expectedType = SyntaxFactory.ParseTypeName(argumentTypeInfo.ConvertedType.ToDisplayString());
131138
argument = argument.WithExpression(SyntaxFactory.CastExpression(expectedType, argument.Expression));

StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/ReadabilityRules/SA1142CodeFixProvider.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ private static async Task<Document> GetTransformedDocumentAsync(Document documen
5959
private static SyntaxNode GetReplacementNode(SemanticModel semanticModel, SyntaxNode fieldName)
6060
{
6161
var fieldSymbol = (IFieldSymbol)semanticModel.GetSymbolInfo(fieldName.Parent).Symbol;
62-
var fieldNameSymbol = fieldSymbol.ContainingType.GetMembers().OfType<IFieldSymbol>().Single(fs => (fs != fieldSymbol) && (fs.CorrespondingTupleField() == fieldSymbol));
62+
var fieldNameSymbol = fieldSymbol.ContainingType.GetMembers().OfType<IFieldSymbol>().Single(fs => !Equals(fs, fieldSymbol) && Equals(fs.CorrespondingTupleField(), fieldSymbol));
6363

6464
return SyntaxFactory.IdentifierName(fieldNameSymbol.Name).WithTriviaFrom(fieldName);
6565
}

StyleCop.Analyzers/StyleCop.Analyzers.Internal.ruleset

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@
1010
<Rule Id="xUnit1004" Action="Info" />
1111
</Rules>
1212
<Rules AnalyzerId="Microsoft.CodeAnalysis.Analyzers" RuleNamespace="Microsoft.CodeAnalysis.Analyzers">
13-
<Rule Id="RS1001" Action="None" />
14-
<Rule Id="RS1004" Action="None" />
13+
<Rule Id="RS1001" Action="None" /> <!-- Missing diagnostic analyzer attribute -->
14+
<Rule Id="RS1004" Action="None" /> <!-- Recommend adding language support to diagnostic analyzer -->
15+
<Rule Id="RS1029" Action="None" /> <!-- Do not use reserved diagnostic IDs -->
16+
<Rule Id="RS2008" Action="None" /> <!-- Enable analyzer release tracking -->
1517
</Rules>
1618
</RuleSet>

StyleCop.Analyzers/StyleCop.Analyzers.Test/AnalyzerExtensionsTests.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,9 @@ public AnalyzerExtensionsTests AnalyzerExtensionsTests
6969

7070
public override void Initialize(AnalysisContext context)
7171
{
72+
context.ConfigureGeneratedCodeAnalysis(GeneratedCodeAnalysisFlags.None);
73+
context.EnableConcurrentExecution();
74+
7275
context.RegisterCompilationStartAction(
7376
compilationStartContext =>
7477
{

StyleCop.Analyzers/StyleCop.Analyzers.Test/DocumentationRules/SA1612UnitTests.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ public class ClassName
132132
}";
133133

134134
var diagnostic = Diagnostic()
135-
.WithMessageFormat("The parameter documentation for '{0}' should be at position {1}.");
135+
.WithMessageFormat("The parameter documentation for '{0}' should be at position {1}");
136136

137137
var expected = new[]
138138
{
@@ -215,7 +215,7 @@ public class ClassName
215215
}";
216216

217217
var diagnostic = Diagnostic()
218-
.WithMessageFormat("The parameter documentation for '{0}' should be at position {1}.");
218+
.WithMessageFormat("The parameter documentation for '{0}' should be at position {1}");
219219

220220
var expected = new[]
221221
{
@@ -248,7 +248,7 @@ public class ClassName
248248
}";
249249

250250
var diagnostic = Diagnostic()
251-
.WithMessageFormat("The parameter documentation for '{0}' should be at position {1}.");
251+
.WithMessageFormat("The parameter documentation for '{0}' should be at position {1}");
252252

253253
var expected = diagnostic.WithLocation(13, 22).WithArguments("bar", 2);
254254

@@ -353,7 +353,7 @@ public class ClassName
353353
}";
354354

355355
var diagnostic = Diagnostic()
356-
.WithMessageFormat("The parameter documentation for '{0}' should be at position {1}.");
356+
.WithMessageFormat("The parameter documentation for '{0}' should be at position {1}");
357357

358358
var expected = new[]
359359
{
@@ -400,7 +400,7 @@ public class ClassName
400400
}";
401401

402402
var diagnostic = Diagnostic()
403-
.WithMessageFormat("The parameter documentation for '{0}' should be at position {1}.");
403+
.WithMessageFormat("The parameter documentation for '{0}' should be at position {1}");
404404

405405
var expected = diagnostic.WithLocation(8, 22).WithArguments("bar", 2);
406406

StyleCop.Analyzers/StyleCop.Analyzers.Test/Helpers/ExclusionTestAnalyzer.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ internal class ExclusionTestAnalyzer : DiagnosticAnalyzer
2020
internal const string DiagnosticId = "SA9999";
2121
private const string Title = "Exclusion test";
2222
private const string MessageFormat = "Exclusion test";
23-
private const string Description = "Exclusion test";
23+
private const string Description = "Exclusion test.";
2424
private const string HelpLink = "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA9999.md";
2525

2626
private static readonly DiagnosticDescriptor Descriptor =

0 commit comments

Comments
 (0)