diff --git a/.editorconfig b/.editorconfig
index 939fe68d..60ef73e5 100644
--- a/.editorconfig
+++ b/.editorconfig
@@ -39,10 +39,15 @@ indent_size = 2
insert_final_newline = true
[*.cs]
+dotnet_diagnostic.IDE0058.severity = none
+dotnet_diagnostic.IDE0303.severity = none
+dotnet_diagnostic.CA1508.severity = none
+dotnet_diagnostic.CA2000.severity = none
dotnet_diagnostic.RS1041.severity = none
dotnet_diagnostic.RS2008.severity = none
-dotnet_diagnostic.CA1508.severity = none
[src/ListDotNetTypes/*.cs]
dotnet_diagnostic.CA2007.severity = none
-dotnet_diagnostic.MA0004.severity = none
\ No newline at end of file
+dotnet_diagnostic.MA0004.severity = none
+
+
diff --git a/Directory.Build.props b/Directory.Build.props
index 61fb4f16..e174c43e 100644
--- a/Directory.Build.props
+++ b/Directory.Build.props
@@ -34,7 +34,7 @@
-
+
all
runtime; build; native; contentfiles; analyzers
@@ -43,4 +43,9 @@
runtime; build; native; contentfiles; analyzers
+
+
+
+
+
\ No newline at end of file
diff --git a/Directory.Build.targets b/Directory.Build.targets
index 32aa4335..9cc05078 100644
--- a/Directory.Build.targets
+++ b/Directory.Build.targets
@@ -78,10 +78,10 @@
-
-
-
-
+
+
+
+
$(DefineConstants);ROSLYN4_8;ROSLYN_4_2_OR_GREATER;ROSLYN_4_4_OR_GREATER;ROSLYN_4_5_OR_GREATER;ROSLYN_4_6_OR_GREATER;ROSLYN_4_8_OR_GREATER;ROSLYN_4_10_OR_GREATER
diff --git a/global.json b/global.json
index 91a2345c..5b8061cc 100644
--- a/global.json
+++ b/global.json
@@ -1,6 +1,6 @@
{
"sdk": {
- "version": "8.0.303",
- "rollForward": "latestMajor"
+ "version": "9.0.100",
+ "rollForward": "latestPatch"
}
}
\ No newline at end of file
diff --git a/src/DocumentationGenerator/DocumentationGenerator.csproj b/src/DocumentationGenerator/DocumentationGenerator.csproj
index f97c9d00..e2ccb581 100644
--- a/src/DocumentationGenerator/DocumentationGenerator.csproj
+++ b/src/DocumentationGenerator/DocumentationGenerator.csproj
@@ -2,7 +2,7 @@
Exe
- net8.0
+ net9.0
false
true
enable
diff --git a/src/ListDotNetTypes/ListDotNetTypes.csproj b/src/ListDotNetTypes/ListDotNetTypes.csproj
index 387f0dc3..a22c3d89 100644
--- a/src/ListDotNetTypes/ListDotNetTypes.csproj
+++ b/src/ListDotNetTypes/ListDotNetTypes.csproj
@@ -1,15 +1,15 @@
-
+
Exe
- net8.0
+ net9.0
enable
false
true
-
+
diff --git a/src/ListDotNetTypes/Program.cs b/src/ListDotNetTypes/Program.cs
index 64543942..e8fa8253 100644
--- a/src/ListDotNetTypes/Program.cs
+++ b/src/ListDotNetTypes/Program.cs
@@ -27,7 +27,9 @@
Console.WriteLine(packageName + "@" + latestVersion);
using var packageStream = new MemoryStream();
- await resource.CopyNupkgToStreamAsync(packageName, latestVersion, packageStream, cache, NullLogger.Instance, CancellationToken.None);
+ if (!await resource.CopyNupkgToStreamAsync(packageName, latestVersion, packageStream, cache, NullLogger.Instance, CancellationToken.None))
+ throw new InvalidOperationException("Cannot copy NuGet package");
+
packageStream.Seek(0, SeekOrigin.Begin);
using var zipArchive = new ZipArchive(packageStream, ZipArchiveMode.Read);
diff --git a/src/Meziantou.Analyzer.Annotations/RequireNamedArgumentAttribute.cs b/src/Meziantou.Analyzer.Annotations/RequireNamedArgumentAttribute.cs
index 08b1f09d..4d308f07 100644
--- a/src/Meziantou.Analyzer.Annotations/RequireNamedArgumentAttribute.cs
+++ b/src/Meziantou.Analyzer.Annotations/RequireNamedArgumentAttribute.cs
@@ -1,7 +1,6 @@
#pragma warning disable CS1591
#pragma warning disable IDE0060
#pragma warning disable CA1019
-#nullable disable
namespace Meziantou.Analyzer.Annotations;
diff --git a/src/Meziantou.Analyzer.Annotations/StructuredLogFieldAttribute.cs b/src/Meziantou.Analyzer.Annotations/StructuredLogFieldAttribute.cs
index f4ad4feb..cc103432 100644
--- a/src/Meziantou.Analyzer.Annotations/StructuredLogFieldAttribute.cs
+++ b/src/Meziantou.Analyzer.Annotations/StructuredLogFieldAttribute.cs
@@ -2,7 +2,6 @@
#pragma warning disable IDE0060
#pragma warning disable IDE0290
#pragma warning disable CA1019
-#nullable disable
namespace Meziantou.Analyzer.Annotations;
diff --git a/src/Meziantou.Analyzer.CodeFixers/Internals/DocumentBasedFixAllProvider.cs b/src/Meziantou.Analyzer.CodeFixers/Internals/DocumentBasedFixAllProvider.cs
index 97adf888..15d9a919 100644
--- a/src/Meziantou.Analyzer.CodeFixers/Internals/DocumentBasedFixAllProvider.cs
+++ b/src/Meziantou.Analyzer.CodeFixers/Internals/DocumentBasedFixAllProvider.cs
@@ -1,4 +1,6 @@
-// File initially copied from
+#if ROSLYN_3_8
+#pragma warning disable IDE0130 // Namespace does not match folder structure
+// File initially copied from
// https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/4d9b3e3bb785a55f73b3029a843f0c0b73cc9ea7/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/Helpers/DocumentBasedFixAllProvider.cs
// Original copyright statement:
// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved.
@@ -7,6 +9,7 @@
using System.Collections.Immutable;
using System.Linq;
using System.Threading.Tasks;
+using Meziantou.Analyzer.Internals;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CodeActions;
using Microsoft.CodeAnalysis.CodeFixes;
@@ -18,22 +21,22 @@ namespace Meziantou.Analyzer;
///
internal abstract class DocumentBasedFixAllProvider : FixAllProvider
{
- protected abstract string CodeActionTitle { get; }
+ protected abstract string GetFixAllTitle(FixAllContext fixAllContext);
public override Task GetFixAsync(FixAllContext fixAllContext)
{
return Task.FromResult(fixAllContext.Scope switch
{
FixAllScope.Document => CodeAction.Create(
- CodeActionTitle,
+ GetFixAllTitle(fixAllContext),
cancellationToken => GetDocumentFixesAsync(fixAllContext.WithCancellationToken(cancellationToken)),
nameof(DocumentBasedFixAllProvider)),
FixAllScope.Project => CodeAction.Create(
- CodeActionTitle,
+ GetFixAllTitle(fixAllContext),
cancellationToken => GetProjectFixesAsync(fixAllContext.WithCancellationToken(cancellationToken), fixAllContext.Project),
nameof(DocumentBasedFixAllProvider)),
FixAllScope.Solution => CodeAction.Create(
- CodeActionTitle,
+ GetFixAllTitle(fixAllContext),
cancellationToken => GetSolutionFixesAsync(fixAllContext.WithCancellationToken(cancellationToken)),
nameof(DocumentBasedFixAllProvider)),
_ => null,
@@ -47,11 +50,11 @@ internal abstract class DocumentBasedFixAllProvider : FixAllProvider
/// The document to fix.
/// The diagnostics to fix in the document.
///
- /// The new representing the root of the fixed document.
+ /// The new representing the root of the fixed document.
/// -or-
/// , if no changes were made to the document.
///
- protected abstract Task FixAllInDocumentAsync(FixAllContext fixAllContext, Document document, ImmutableArray diagnostics);
+ protected abstract Task FixAllAsync(FixAllContext fixAllContext, Document document, ImmutableArray diagnostics);
private async Task GetDocumentFixesAsync(FixAllContext fixAllContext)
{
@@ -62,13 +65,8 @@ private async Task GetDocumentFixesAsync(FixAllContext fixAllContext)
return document;
}
- var newRoot = await FixAllInDocumentAsync(fixAllContext, document, diagnostics).ConfigureAwait(false);
- if (newRoot is null)
- {
- return document;
- }
-
- return document.WithSyntaxRoot(newRoot);
+ var newDocument = await FixAllAsync(fixAllContext, document, diagnostics).ConfigureAwait(false);
+ return newDocument ?? document;
}
private async Task GetSolutionFixesAsync(FixAllContext fixAllContext, ImmutableArray documents)
@@ -76,16 +74,16 @@ private async Task GetSolutionFixesAsync(FixAllContext fixAllContext,
var documentDiagnosticsToFix = await FixAllContextHelper.GetDocumentDiagnosticsToFixAsync(fixAllContext).ConfigureAwait(false);
var solution = fixAllContext.Solution;
- var newDocuments = new List>(documents.Length);
+ var newDocuments = new List>(documents.Length);
foreach (var document in documents)
{
if (!documentDiagnosticsToFix.TryGetValue(document, out var diagnostics))
{
- newDocuments.Add(document.GetSyntaxRootAsync(fixAllContext.CancellationToken));
+ newDocuments.Add(Task.FromResult(document));
continue;
}
- newDocuments.Add(FixAllInDocumentAsync(fixAllContext, document, diagnostics));
+ newDocuments.Add(FixAllAsync(fixAllContext, document, diagnostics));
}
for (var i = 0; i < documents.Length; i++)
@@ -94,7 +92,7 @@ private async Task GetSolutionFixesAsync(FixAllContext fixAllContext,
if (newDocumentRoot is null)
continue;
- solution = solution.WithDocumentSyntaxRoot(documents[i].Id, newDocumentRoot);
+ //solution = solution.WithDocumentSyntaxRoot(documents[i].Id, newDocumentRoot);
}
return solution;
@@ -111,3 +109,4 @@ private Task GetSolutionFixesAsync(FixAllContext fixAllContext)
return GetSolutionFixesAsync(fixAllContext, documents);
}
}
+#endif
diff --git a/src/Meziantou.Analyzer.CodeFixers/Internals/FixAllContextHelper.cs b/src/Meziantou.Analyzer.CodeFixers/Internals/FixAllContextHelper.cs
index 7ce01600..05507550 100644
--- a/src/Meziantou.Analyzer.CodeFixers/Internals/FixAllContextHelper.cs
+++ b/src/Meziantou.Analyzer.CodeFixers/Internals/FixAllContextHelper.cs
@@ -11,7 +11,7 @@
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CodeFixes;
-namespace Meziantou.Analyzer;
+namespace Meziantou.Analyzer.Internals;
internal static class FixAllContextHelper
{
diff --git a/src/Meziantou.Analyzer.CodeFixers/Meziantou.Analyzer.CodeFixers.csproj b/src/Meziantou.Analyzer.CodeFixers/Meziantou.Analyzer.CodeFixers.csproj
index f390fdf5..c125d9db 100644
--- a/src/Meziantou.Analyzer.CodeFixers/Meziantou.Analyzer.CodeFixers.csproj
+++ b/src/Meziantou.Analyzer.CodeFixers/Meziantou.Analyzer.CodeFixers.csproj
@@ -1,6 +1,6 @@
- net8.0;netstandard2.0
+ net9.0;netstandard2.0
false
1.0.1
enable
diff --git a/src/Meziantou.Analyzer.CodeFixers/Rules/AvoidUsingRedundantElseFixAllProvider.cs b/src/Meziantou.Analyzer.CodeFixers/Rules/AvoidUsingRedundantElseFixAllProvider.cs
index 0b4666a0..fbea5985 100644
--- a/src/Meziantou.Analyzer.CodeFixers/Rules/AvoidUsingRedundantElseFixAllProvider.cs
+++ b/src/Meziantou.Analyzer.CodeFixers/Rules/AvoidUsingRedundantElseFixAllProvider.cs
@@ -9,16 +9,14 @@ internal sealed class AvoidUsingRedundantElseFixAllProvider : DocumentBasedFixAl
{
public static AvoidUsingRedundantElseFixAllProvider Instance { get; } = new AvoidUsingRedundantElseFixAllProvider();
- protected override string CodeActionTitle => "Remove redundant else";
+ protected override string GetFixAllTitle(FixAllContext fixAllContext) => "Remove redundant else";
- ///
- protected override async Task FixAllInDocumentAsync(FixAllContext fixAllContext, Document document, ImmutableArray diagnostics)
+ protected override async Task FixAllAsync(FixAllContext fixAllContext, Document document, ImmutableArray diagnostics)
{
if (diagnostics.IsEmpty)
return null;
var newDocument = await AvoidUsingRedundantElseFixer.RemoveRedundantElseClausesInDocument(document, diagnostics, fixAllContext.CancellationToken).ConfigureAwait(false);
-
- return await newDocument.GetSyntaxRootAsync(fixAllContext.CancellationToken).ConfigureAwait(false);
+ return newDocument;
}
}
diff --git a/src/Meziantou.Analyzer.CodeFixers/Rules/ClassMustBeSealedFixer.cs b/src/Meziantou.Analyzer.CodeFixers/Rules/ClassMustBeSealedFixer.cs
index 32c553ea..5a62796e 100644
--- a/src/Meziantou.Analyzer.CodeFixers/Rules/ClassMustBeSealedFixer.cs
+++ b/src/Meziantou.Analyzer.CodeFixers/Rules/ClassMustBeSealedFixer.cs
@@ -2,6 +2,7 @@
using System.Composition;
using System.Threading;
using System.Threading.Tasks;
+using Meziantou.Analyzer.Internals;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CodeActions;
using Microsoft.CodeAnalysis.CodeFixes;
@@ -46,5 +47,4 @@ private static async Task AddSealedModifier(Document document, SyntaxN
editor.ReplaceNode(classNode, classNode.WithModifiers(modifiers).WithAdditionalAnnotations(Formatter.Annotation));
return editor.GetChangedDocument();
}
-
}
diff --git a/src/Meziantou.Analyzer.CodeFixers/Rules/DoNotUseBlockingCallInAsyncContextFixer.cs b/src/Meziantou.Analyzer.CodeFixers/Rules/DoNotUseBlockingCallInAsyncContextFixer.cs
index 3b85c56d..38e9eacc 100644
--- a/src/Meziantou.Analyzer.CodeFixers/Rules/DoNotUseBlockingCallInAsyncContextFixer.cs
+++ b/src/Meziantou.Analyzer.CodeFixers/Rules/DoNotUseBlockingCallInAsyncContextFixer.cs
@@ -3,6 +3,7 @@
using System.Composition;
using System.Threading;
using System.Threading.Tasks;
+using Meziantou.Analyzer.Internals;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CodeActions;
using Microsoft.CodeAnalysis.CodeFixes;
@@ -40,8 +41,8 @@ public override async Task RegisterCodeFixesAsync(CodeFixContext context)
equivalenceKey: "Thread_Sleep");
context.RegisterCodeFix(codeAction, context.Diagnostics);
+ break;
}
- break;
case DoNotUseBlockingCallInAsyncContextData.Task_Wait:
{
@@ -51,8 +52,8 @@ public override async Task RegisterCodeFixesAsync(CodeFixContext context)
equivalenceKey: "Task_Wait");
context.RegisterCodeFix(codeAction, context.Diagnostics);
+ break;
}
- break;
case DoNotUseBlockingCallInAsyncContextData.Task_Result:
{
@@ -62,8 +63,8 @@ public override async Task RegisterCodeFixesAsync(CodeFixContext context)
equivalenceKey: "Task_Result");
context.RegisterCodeFix(codeAction, context.Diagnostics);
+ break;
}
- break;
case DoNotUseBlockingCallInAsyncContextData.Overload:
{
@@ -76,8 +77,8 @@ public override async Task RegisterCodeFixesAsync(CodeFixContext context)
equivalenceKey: "Overload");
context.RegisterCodeFix(codeAction, context.Diagnostics);
+ break;
}
- break;
case DoNotUseBlockingCallInAsyncContextData.Using:
case DoNotUseBlockingCallInAsyncContextData.UsingDeclarator:
@@ -88,8 +89,8 @@ public override async Task RegisterCodeFixesAsync(CodeFixContext context)
equivalenceKey: "Overload");
context.RegisterCodeFix(codeAction, context.Diagnostics);
+ break;
}
- break;
}
}
diff --git a/src/Meziantou.Analyzer.CodeFixers/Rules/DoNotUseEqualityComparerDefaultOfStringFixer.cs b/src/Meziantou.Analyzer.CodeFixers/Rules/DoNotUseEqualityComparerDefaultOfStringFixer.cs
index a55b1a90..c2b7abbe 100644
--- a/src/Meziantou.Analyzer.CodeFixers/Rules/DoNotUseEqualityComparerDefaultOfStringFixer.cs
+++ b/src/Meziantou.Analyzer.CodeFixers/Rules/DoNotUseEqualityComparerDefaultOfStringFixer.cs
@@ -3,6 +3,7 @@
using System.Composition;
using System.Threading;
using System.Threading.Tasks;
+using Meziantou.Analyzer.Internals;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CodeActions;
using Microsoft.CodeAnalysis.CodeFixes;
diff --git a/src/Meziantou.Analyzer.CodeFixers/Rules/DoNotUseStringGetHashCodeFixer.cs b/src/Meziantou.Analyzer.CodeFixers/Rules/DoNotUseStringGetHashCodeFixer.cs
index 46a90bac..b3090704 100644
--- a/src/Meziantou.Analyzer.CodeFixers/Rules/DoNotUseStringGetHashCodeFixer.cs
+++ b/src/Meziantou.Analyzer.CodeFixers/Rules/DoNotUseStringGetHashCodeFixer.cs
@@ -3,6 +3,7 @@
using System.Composition;
using System.Threading;
using System.Threading.Tasks;
+using Meziantou.Analyzer.Internals;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CodeActions;
using Microsoft.CodeAnalysis.CodeFixes;
diff --git a/src/Meziantou.Analyzer.CodeFixers/Rules/EqualityShouldBeCorrectlyImplementedFixer.cs b/src/Meziantou.Analyzer.CodeFixers/Rules/EqualityShouldBeCorrectlyImplementedFixer.cs
index 2bc118b8..d5bf6ae5 100755
--- a/src/Meziantou.Analyzer.CodeFixers/Rules/EqualityShouldBeCorrectlyImplementedFixer.cs
+++ b/src/Meziantou.Analyzer.CodeFixers/Rules/EqualityShouldBeCorrectlyImplementedFixer.cs
@@ -3,6 +3,7 @@
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
+using Meziantou.Analyzer.Internals;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CodeActions;
using Microsoft.CodeAnalysis.CodeFixes;
diff --git a/src/Meziantou.Analyzer.CodeFixers/Rules/MakeClassStaticFixer.cs b/src/Meziantou.Analyzer.CodeFixers/Rules/MakeClassStaticFixer.cs
index 91bd885a..bb33b0e1 100644
--- a/src/Meziantou.Analyzer.CodeFixers/Rules/MakeClassStaticFixer.cs
+++ b/src/Meziantou.Analyzer.CodeFixers/Rules/MakeClassStaticFixer.cs
@@ -2,6 +2,7 @@
using System.Composition;
using System.Threading;
using System.Threading.Tasks;
+using Meziantou.Analyzer.Internals;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CodeActions;
using Microsoft.CodeAnalysis.CodeFixes;
diff --git a/src/Meziantou.Analyzer.CodeFixers/Rules/MakeMemberReadOnlyFixer.cs b/src/Meziantou.Analyzer.CodeFixers/Rules/MakeMemberReadOnlyFixer.cs
index 8cdc1239..aadb5961 100644
--- a/src/Meziantou.Analyzer.CodeFixers/Rules/MakeMemberReadOnlyFixer.cs
+++ b/src/Meziantou.Analyzer.CodeFixers/Rules/MakeMemberReadOnlyFixer.cs
@@ -3,6 +3,7 @@
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
+using Meziantou.Analyzer.Internals;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CodeActions;
using Microsoft.CodeAnalysis.CodeFixes;
@@ -102,16 +103,15 @@ internal sealed class MakeMemberReadOnlyFixAllProvider : DocumentBasedFixAllProv
{
public static MakeMemberReadOnlyFixAllProvider Instance { get; } = new MakeMemberReadOnlyFixAllProvider();
- protected override string CodeActionTitle => "Add readonly";
+ protected override string GetFixAllTitle(FixAllContext fixAllContext) => "Add readonly";
- ///
- protected override async Task FixAllInDocumentAsync(FixAllContext fixAllContext, Document document, ImmutableArray diagnostics)
+ protected override async Task FixAllAsync(FixAllContext fixAllContext, Document document, ImmutableArray diagnostics)
{
if (diagnostics.IsEmpty)
return null;
var newDocument = await MakeReadOnly(document, diagnostics, fixAllContext.CancellationToken).ConfigureAwait(false);
- return await newDocument.GetSyntaxRootAsync(fixAllContext.CancellationToken).ConfigureAwait(false);
+ return newDocument;
}
internal static async Task MakeReadOnly(Document document, ImmutableArray diagnostics, CancellationToken cancellationToken)
diff --git a/src/Meziantou.Analyzer.CodeFixers/Rules/MakeMethodStaticFixer.cs b/src/Meziantou.Analyzer.CodeFixers/Rules/MakeMethodStaticFixer.cs
index 0bfa3cc2..61377f1c 100644
--- a/src/Meziantou.Analyzer.CodeFixers/Rules/MakeMethodStaticFixer.cs
+++ b/src/Meziantou.Analyzer.CodeFixers/Rules/MakeMethodStaticFixer.cs
@@ -2,6 +2,7 @@
using System.Composition;
using System.Threading;
using System.Threading.Tasks;
+using Meziantou.Analyzer.Internals;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CodeActions;
using Microsoft.CodeAnalysis.CodeFixes;
diff --git a/src/Meziantou.Analyzer.CodeFixers/Rules/MarkAttributesWithAttributeUsageAttributeFixer.cs b/src/Meziantou.Analyzer.CodeFixers/Rules/MarkAttributesWithAttributeUsageAttributeFixer.cs
index a9d71c8f..1b65d702 100644
--- a/src/Meziantou.Analyzer.CodeFixers/Rules/MarkAttributesWithAttributeUsageAttributeFixer.cs
+++ b/src/Meziantou.Analyzer.CodeFixers/Rules/MarkAttributesWithAttributeUsageAttributeFixer.cs
@@ -3,6 +3,7 @@
using System.Composition;
using System.Threading;
using System.Threading.Tasks;
+using Meziantou.Analyzer.Internals;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CodeActions;
using Microsoft.CodeAnalysis.CodeFixes;
@@ -53,13 +54,12 @@ private static async Task Refactor(Document document, SyntaxNode nodeT
var attribute = editor.Generator.Attribute(
generator.TypeExpression(attributeUsageAttribute, addImport: true),
- new[]
- {
+ [
generator.AttributeArgument(
generator.MemberAccessExpression(
generator.TypeExpression(attributeTargets, addImport: true),
nameof(AttributeTargets.All))),
- });
+ ]);
editor.AddAttribute(classNode, attribute);
return editor.GetChangedDocument();
diff --git a/src/Meziantou.Analyzer.CodeFixers/Rules/NotPatternShouldBeParenthesizedCodeFixer.cs b/src/Meziantou.Analyzer.CodeFixers/Rules/NotPatternShouldBeParenthesizedCodeFixer.cs
index e1d3325e..7723ec7d 100644
--- a/src/Meziantou.Analyzer.CodeFixers/Rules/NotPatternShouldBeParenthesizedCodeFixer.cs
+++ b/src/Meziantou.Analyzer.CodeFixers/Rules/NotPatternShouldBeParenthesizedCodeFixer.cs
@@ -34,6 +34,7 @@ public override async Task RegisterCodeFixesAsync(CodeFixContext context)
equivalenceKey: title);
context.RegisterCodeFix(codeAction, context.Diagnostics);
}
+
{
var title = "Negate all or patterns";
var codeAction = CodeAction.Create(
@@ -58,7 +59,6 @@ private static async Task ParenthesizeOrPattern(Document document, Syn
if (nodeToFix is not UnaryPatternSyntax unary)
return document;
-
var root = unary.Ancestors().TakeWhile(IsOrPattern).LastOrDefault();
if (root is null)
return document;
diff --git a/src/Meziantou.Analyzer.CodeFixers/Rules/OptimizeLinqUsageFixer.cs b/src/Meziantou.Analyzer.CodeFixers/Rules/OptimizeLinqUsageFixer.cs
index 3ca5523c..f120f2ad 100644
--- a/src/Meziantou.Analyzer.CodeFixers/Rules/OptimizeLinqUsageFixer.cs
+++ b/src/Meziantou.Analyzer.CodeFixers/Rules/OptimizeLinqUsageFixer.cs
@@ -5,6 +5,7 @@
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
+using Meziantou.Analyzer.Internals;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CodeActions;
using Microsoft.CodeAnalysis.CodeFixes;
@@ -164,8 +165,10 @@ private static bool TryGetInvocationExpressionAncestor(ref SyntaxNode nodeToFix)
nodeToFix = node;
return true;
}
+
node = node.Parent;
}
+
return false;
}
@@ -474,7 +477,6 @@ private static async Task UseIndexer(Document document, SyntaxNode nod
if (semanticModel.GetOperation(nodeToFix, cancellationToken) is not IInvocationOperation operation)
return document;
-
var newExpression = generator.ElementAccessExpression(operation.Arguments[0].Syntax, operation.Arguments[1].Syntax);
editor.ReplaceNode(nodeToFix, newExpression);
diff --git a/src/Meziantou.Analyzer.CodeFixers/Rules/OptimizeStartsWithFixer.cs b/src/Meziantou.Analyzer.CodeFixers/Rules/OptimizeStartsWithFixer.cs
index 4642c669..c45b71c8 100644
--- a/src/Meziantou.Analyzer.CodeFixers/Rules/OptimizeStartsWithFixer.cs
+++ b/src/Meziantou.Analyzer.CodeFixers/Rules/OptimizeStartsWithFixer.cs
@@ -3,6 +3,7 @@
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
+using Meziantou.Analyzer.Internals;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CodeActions;
using Microsoft.CodeAnalysis.CodeFixes;
diff --git a/src/Meziantou.Analyzer.CodeFixers/Rules/OptimizeStringBuilderUsageFixer.cs b/src/Meziantou.Analyzer.CodeFixers/Rules/OptimizeStringBuilderUsageFixer.cs
index b1c9df2d..2802ed8e 100644
--- a/src/Meziantou.Analyzer.CodeFixers/Rules/OptimizeStringBuilderUsageFixer.cs
+++ b/src/Meziantou.Analyzer.CodeFixers/Rules/OptimizeStringBuilderUsageFixer.cs
@@ -6,6 +6,7 @@
using System.Text;
using System.Threading;
using System.Threading.Tasks;
+using Meziantou.Analyzer.Internals;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CodeActions;
using Microsoft.CodeAnalysis.CodeFixes;
diff --git a/src/Meziantou.Analyzer.CodeFixers/Rules/ReturnTaskFromResultInsteadOfReturningNullFixer.cs b/src/Meziantou.Analyzer.CodeFixers/Rules/ReturnTaskFromResultInsteadOfReturningNullFixer.cs
index 68c51f61..c65422c6 100644
--- a/src/Meziantou.Analyzer.CodeFixers/Rules/ReturnTaskFromResultInsteadOfReturningNullFixer.cs
+++ b/src/Meziantou.Analyzer.CodeFixers/Rules/ReturnTaskFromResultInsteadOfReturningNullFixer.cs
@@ -2,6 +2,7 @@
using System.Composition;
using System.Threading;
using System.Threading.Tasks;
+using Meziantou.Analyzer.Internals;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CodeActions;
using Microsoft.CodeAnalysis.CodeFixes;
diff --git a/src/Meziantou.Analyzer.CodeFixers/Rules/UseAnOverloadThatHasCancellationTokenFixer_Argument.cs b/src/Meziantou.Analyzer.CodeFixers/Rules/UseAnOverloadThatHasCancellationTokenFixer_Argument.cs
index 72e27ad8..1212d8ca 100644
--- a/src/Meziantou.Analyzer.CodeFixers/Rules/UseAnOverloadThatHasCancellationTokenFixer_Argument.cs
+++ b/src/Meziantou.Analyzer.CodeFixers/Rules/UseAnOverloadThatHasCancellationTokenFixer_Argument.cs
@@ -98,7 +98,6 @@ private static async Task FixInvocation(Document document, InvocationE
editor.ReplaceNode(nodeToFix, newInvocation);
}
-
return editor.GetChangedDocument();
}
}
diff --git a/src/Meziantou.Analyzer.CodeFixers/Rules/UseDateTimeUnixEpochFixer.cs b/src/Meziantou.Analyzer.CodeFixers/Rules/UseDateTimeUnixEpochFixer.cs
index 8858abce..416e70d7 100644
--- a/src/Meziantou.Analyzer.CodeFixers/Rules/UseDateTimeUnixEpochFixer.cs
+++ b/src/Meziantou.Analyzer.CodeFixers/Rules/UseDateTimeUnixEpochFixer.cs
@@ -2,6 +2,7 @@
using System.Composition;
using System.Threading;
using System.Threading.Tasks;
+using Meziantou.Analyzer.Internals;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CodeActions;
using Microsoft.CodeAnalysis.CodeFixes;
diff --git a/src/Meziantou.Analyzer.CodeFixers/Rules/UseEventArgsEmptyFixer.cs b/src/Meziantou.Analyzer.CodeFixers/Rules/UseEventArgsEmptyFixer.cs
index 95b6cd29..b2b152ba 100644
--- a/src/Meziantou.Analyzer.CodeFixers/Rules/UseEventArgsEmptyFixer.cs
+++ b/src/Meziantou.Analyzer.CodeFixers/Rules/UseEventArgsEmptyFixer.cs
@@ -3,6 +3,7 @@
using System.Composition;
using System.Threading;
using System.Threading.Tasks;
+using Meziantou.Analyzer.Internals;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CodeActions;
using Microsoft.CodeAnalysis.CodeFixes;
diff --git a/src/Meziantou.Analyzer.CodeFixers/Rules/UseGuidEmptyFixer.cs b/src/Meziantou.Analyzer.CodeFixers/Rules/UseGuidEmptyFixer.cs
index a32685a8..218771a2 100644
--- a/src/Meziantou.Analyzer.CodeFixers/Rules/UseGuidEmptyFixer.cs
+++ b/src/Meziantou.Analyzer.CodeFixers/Rules/UseGuidEmptyFixer.cs
@@ -3,6 +3,7 @@
using System.Composition;
using System.Threading;
using System.Threading.Tasks;
+using Meziantou.Analyzer.Internals;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CodeActions;
using Microsoft.CodeAnalysis.CodeFixes;
diff --git a/src/Meziantou.Analyzer.CodeFixers/Rules/UseRegexSourceGeneratorFixer.cs b/src/Meziantou.Analyzer.CodeFixers/Rules/UseRegexSourceGeneratorFixer.cs
index 698777dd..d6e93ba2 100644
--- a/src/Meziantou.Analyzer.CodeFixers/Rules/UseRegexSourceGeneratorFixer.cs
+++ b/src/Meziantou.Analyzer.CodeFixers/Rules/UseRegexSourceGeneratorFixer.cs
@@ -5,6 +5,7 @@
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
+using Meziantou.Analyzer.Internals;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CodeActions;
using Microsoft.CodeAnalysis.CodeFixes;
diff --git a/src/Meziantou.Analyzer.CodeFixers/Rules/UseStringComparerFixer.cs b/src/Meziantou.Analyzer.CodeFixers/Rules/UseStringComparerFixer.cs
index 2d0926e2..e101c81e 100644
--- a/src/Meziantou.Analyzer.CodeFixers/Rules/UseStringComparerFixer.cs
+++ b/src/Meziantou.Analyzer.CodeFixers/Rules/UseStringComparerFixer.cs
@@ -3,6 +3,7 @@
using System.Composition;
using System.Threading;
using System.Threading.Tasks;
+using Meziantou.Analyzer.Internals;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CodeActions;
using Microsoft.CodeAnalysis.CodeFixes;
diff --git a/src/Meziantou.Analyzer.CodeFixers/Rules/UseStringComparisonFixer.cs b/src/Meziantou.Analyzer.CodeFixers/Rules/UseStringComparisonFixer.cs
index 20456d6b..d16eb0c1 100644
--- a/src/Meziantou.Analyzer.CodeFixers/Rules/UseStringComparisonFixer.cs
+++ b/src/Meziantou.Analyzer.CodeFixers/Rules/UseStringComparisonFixer.cs
@@ -3,6 +3,7 @@
using System.Composition;
using System.Threading;
using System.Threading.Tasks;
+using Meziantou.Analyzer.Internals;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CodeActions;
using Microsoft.CodeAnalysis.CodeFixes;
diff --git a/src/Meziantou.Analyzer.CodeFixers/Rules/UseStringCreateInsteadOfFormattableStringFixer.cs b/src/Meziantou.Analyzer.CodeFixers/Rules/UseStringCreateInsteadOfFormattableStringFixer.cs
index de1ab61b..1d180379 100644
--- a/src/Meziantou.Analyzer.CodeFixers/Rules/UseStringCreateInsteadOfFormattableStringFixer.cs
+++ b/src/Meziantou.Analyzer.CodeFixers/Rules/UseStringCreateInsteadOfFormattableStringFixer.cs
@@ -2,6 +2,7 @@
using System.Composition;
using System.Threading;
using System.Threading.Tasks;
+using Meziantou.Analyzer.Internals;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CodeActions;
using Microsoft.CodeAnalysis.CodeFixes;
diff --git a/src/Meziantou.Analyzer.CodeFixers/Rules/UseStringEqualsFixer.cs b/src/Meziantou.Analyzer.CodeFixers/Rules/UseStringEqualsFixer.cs
index efa7d87a..ea8e163a 100644
--- a/src/Meziantou.Analyzer.CodeFixers/Rules/UseStringEqualsFixer.cs
+++ b/src/Meziantou.Analyzer.CodeFixers/Rules/UseStringEqualsFixer.cs
@@ -3,6 +3,7 @@
using System.Composition;
using System.Threading;
using System.Threading.Tasks;
+using Meziantou.Analyzer.Internals;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CodeActions;
using Microsoft.CodeAnalysis.CodeFixes;
diff --git a/src/Meziantou.Analyzer.CodeFixers/Rules/UseStructLayoutAttributeFixer.cs b/src/Meziantou.Analyzer.CodeFixers/Rules/UseStructLayoutAttributeFixer.cs
index c03d2be0..9cc33dcd 100644
--- a/src/Meziantou.Analyzer.CodeFixers/Rules/UseStructLayoutAttributeFixer.cs
+++ b/src/Meziantou.Analyzer.CodeFixers/Rules/UseStructLayoutAttributeFixer.cs
@@ -3,6 +3,7 @@
using System.Runtime.InteropServices;
using System.Threading;
using System.Threading.Tasks;
+using Meziantou.Analyzer.Internals;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CodeActions;
using Microsoft.CodeAnalysis.CodeFixes;
@@ -26,7 +27,7 @@ public override async Task RegisterCodeFixesAsync(CodeFixContext context)
{
var root = await context.Document.GetSyntaxRootAsync(context.CancellationToken).ConfigureAwait(false);
var nodeToFix = root?.FindNode(context.Span, getInnermostNodeForTie: true);
- if (nodeToFix is null || nodeToFix is not TypeDeclarationSyntax)
+ if (nodeToFix is null or not TypeDeclarationSyntax)
return;
context.RegisterCodeFix(
@@ -57,13 +58,12 @@ private static async Task Refactor(Document document, SyntaxNode nodeT
var attribute = editor.Generator.Attribute(
generator.TypeExpression(structLayoutAttribute).WithAdditionalAnnotations(Simplifier.AddImportsAnnotation),
- new[]
- {
+ [
generator.AttributeArgument(
generator.MemberAccessExpression(
generator.TypeExpression(layoutKindEnum).WithAdditionalAnnotations(Simplifier.AddImportsAnnotation),
layoutKind.ToString())),
- });
+ ]);
editor.AddAttribute(nodeToFix, attribute);
return editor.GetChangedDocument();
diff --git a/src/Meziantou.Analyzer.CodeFixers/Rules/ValidateArgumentsCorrectlyFixer.cs b/src/Meziantou.Analyzer.CodeFixers/Rules/ValidateArgumentsCorrectlyFixer.cs
index b6ae3c91..58f24c40 100755
--- a/src/Meziantou.Analyzer.CodeFixers/Rules/ValidateArgumentsCorrectlyFixer.cs
+++ b/src/Meziantou.Analyzer.CodeFixers/Rules/ValidateArgumentsCorrectlyFixer.cs
@@ -5,6 +5,7 @@
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
+using Meziantou.Analyzer.Internals;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CodeActions;
using Microsoft.CodeAnalysis.CodeFixes;
diff --git a/src/Meziantou.Analyzer/Internals/CompilationExtensions.cs b/src/Meziantou.Analyzer/Internals/CompilationExtensions.cs
index 45165810..a8632b95 100644
--- a/src/Meziantou.Analyzer/Internals/CompilationExtensions.cs
+++ b/src/Meziantou.Analyzer/Internals/CompilationExtensions.cs
@@ -4,7 +4,7 @@
using System.Diagnostics;
using Microsoft.CodeAnalysis;
-namespace Meziantou.Analyzer;
+namespace Meziantou.Analyzer.Internals;
internal static class CompilationExtensions
{
@@ -120,6 +120,7 @@ private static SymbolVisibility GetResultantVisibility(this ISymbol symbol)
// Type Parameters are private.
return SymbolVisibility.Private;
}
+
while (symbol is not null && symbol.Kind != SymbolKind.Namespace)
{
switch (symbol.DeclaredAccessibility)
@@ -137,8 +138,10 @@ private static SymbolVisibility GetResultantVisibility(this ISymbol symbol)
// For anything else (Public, Protected, ProtectedOrInternal), the
// symbol stays at the level we've gotten so far.
}
+
symbol = symbol.ContainingSymbol;
}
+
return visibility;
}
diff --git a/src/Meziantou.Analyzer/Internals/ContextExtensions.cs b/src/Meziantou.Analyzer/Internals/ContextExtensions.cs
index f40e3144..9caf0d52 100755
--- a/src/Meziantou.Analyzer/Internals/ContextExtensions.cs
+++ b/src/Meziantou.Analyzer/Internals/ContextExtensions.cs
@@ -1,10 +1,11 @@
using System.Collections.Immutable;
using System.Linq;
+using Meziantou.Analyzer.Internals;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Microsoft.CodeAnalysis.Operations;
-namespace Meziantou.Analyzer;
+namespace Meziantou.Analyzer.Internals;
internal static partial class ContextExtensions
{
diff --git a/src/Meziantou.Analyzer/Internals/ContextExtensions.g.cs b/src/Meziantou.Analyzer/Internals/ContextExtensions.g.cs
index ba66016f..f419ec92 100644
--- a/src/Meziantou.Analyzer/Internals/ContextExtensions.g.cs
+++ b/src/Meziantou.Analyzer/Internals/ContextExtensions.g.cs
@@ -5,7 +5,7 @@
using Microsoft.CodeAnalysis.Diagnostics;
using Microsoft.CodeAnalysis.Operations;
-namespace Meziantou.Analyzer;
+namespace Meziantou.Analyzer.Internals;
internal static partial class ContextExtensions
{
diff --git a/src/Meziantou.Analyzer/Internals/ContextExtensions.tt b/src/Meziantou.Analyzer/Internals/ContextExtensions.tt
index 33278aae..b9d7b38c 100644
--- a/src/Meziantou.Analyzer/Internals/ContextExtensions.tt
+++ b/src/Meziantou.Analyzer/Internals/ContextExtensions.tt
@@ -9,7 +9,7 @@ using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.Diagnostics;
using Microsoft.CodeAnalysis.Operations;
-namespace Meziantou.Analyzer;
+namespace Meziantou.Analyzer.Internals;
internal static partial class ContextExtensions
{
diff --git a/src/Meziantou.Analyzer/Internals/DiagnosticFieldReportOptions.cs b/src/Meziantou.Analyzer/Internals/DiagnosticFieldReportOptions.cs
index fd809784..5d63e67b 100644
--- a/src/Meziantou.Analyzer/Internals/DiagnosticFieldReportOptions.cs
+++ b/src/Meziantou.Analyzer/Internals/DiagnosticFieldReportOptions.cs
@@ -1,6 +1,6 @@
using System;
-namespace Meziantou.Analyzer;
+namespace Meziantou.Analyzer.Internals;
[Flags]
public enum DiagnosticFieldReportOptions
diff --git a/src/Meziantou.Analyzer/Internals/DiagnosticInvocationReportOptions.cs b/src/Meziantou.Analyzer/Internals/DiagnosticInvocationReportOptions.cs
index 79c8e411..fd123ba4 100644
--- a/src/Meziantou.Analyzer/Internals/DiagnosticInvocationReportOptions.cs
+++ b/src/Meziantou.Analyzer/Internals/DiagnosticInvocationReportOptions.cs
@@ -1,6 +1,6 @@
using System;
-namespace Meziantou.Analyzer;
+namespace Meziantou.Analyzer.Internals;
[Flags]
public enum DiagnosticInvocationReportOptions
diff --git a/src/Meziantou.Analyzer/Internals/DiagnosticMethodReportOptions.cs b/src/Meziantou.Analyzer/Internals/DiagnosticMethodReportOptions.cs
index 59ee4870..71c28384 100644
--- a/src/Meziantou.Analyzer/Internals/DiagnosticMethodReportOptions.cs
+++ b/src/Meziantou.Analyzer/Internals/DiagnosticMethodReportOptions.cs
@@ -1,6 +1,6 @@
using System;
-namespace Meziantou.Analyzer;
+namespace Meziantou.Analyzer.Internals;
[Flags]
public enum DiagnosticMethodReportOptions
diff --git a/src/Meziantou.Analyzer/Internals/DiagnosticParameterReportOptions.cs b/src/Meziantou.Analyzer/Internals/DiagnosticParameterReportOptions.cs
index 5b32d7d0..8d05bac6 100644
--- a/src/Meziantou.Analyzer/Internals/DiagnosticParameterReportOptions.cs
+++ b/src/Meziantou.Analyzer/Internals/DiagnosticParameterReportOptions.cs
@@ -1,6 +1,6 @@
using System;
-namespace Meziantou.Analyzer;
+namespace Meziantou.Analyzer.Internals;
[Flags]
public enum DiagnosticParameterReportOptions
diff --git a/src/Meziantou.Analyzer/Internals/DiagnosticPropertyReportOptions.cs b/src/Meziantou.Analyzer/Internals/DiagnosticPropertyReportOptions.cs
index 6fe4c897..135b05bf 100644
--- a/src/Meziantou.Analyzer/Internals/DiagnosticPropertyReportOptions.cs
+++ b/src/Meziantou.Analyzer/Internals/DiagnosticPropertyReportOptions.cs
@@ -1,6 +1,6 @@
using System;
-namespace Meziantou.Analyzer;
+namespace Meziantou.Analyzer.Internals;
[Flags]
public enum DiagnosticPropertyReportOptions
diff --git a/src/Meziantou.Analyzer/Internals/DiagnosticReporter.cs b/src/Meziantou.Analyzer/Internals/DiagnosticReporter.cs
index 719ea261..c9f275f9 100644
--- a/src/Meziantou.Analyzer/Internals/DiagnosticReporter.cs
+++ b/src/Meziantou.Analyzer/Internals/DiagnosticReporter.cs
@@ -3,7 +3,7 @@
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.Diagnostics;
-namespace Meziantou.Analyzer;
+namespace Meziantou.Analyzer.Internals;
internal readonly struct DiagnosticReporter
{
diff --git a/src/Meziantou.Analyzer/Internals/EnumerableExtensions.cs b/src/Meziantou.Analyzer/Internals/EnumerableExtensions.cs
index 292119c2..c9675124 100644
--- a/src/Meziantou.Analyzer/Internals/EnumerableExtensions.cs
+++ b/src/Meziantou.Analyzer/Internals/EnumerableExtensions.cs
@@ -2,7 +2,7 @@
using System.Diagnostics.CodeAnalysis;
using System.Linq;
-namespace Meziantou.Analyzer;
+namespace Meziantou.Analyzer.Internals;
internal static class EnumerableExtensions
{
diff --git a/src/Meziantou.Analyzer/Internals/LanguageVersionExtensions.cs b/src/Meziantou.Analyzer/Internals/LanguageVersionExtensions.cs
index cd9cac8c..294ab82e 100644
--- a/src/Meziantou.Analyzer/Internals/LanguageVersionExtensions.cs
+++ b/src/Meziantou.Analyzer/Internals/LanguageVersionExtensions.cs
@@ -1,6 +1,6 @@
using Microsoft.CodeAnalysis.CSharp;
-namespace Meziantou.Analyzer;
+namespace Meziantou.Analyzer.Internals;
internal static class LanguageVersionExtensions
{
diff --git a/src/Meziantou.Analyzer/Internals/ListExtensions.cs b/src/Meziantou.Analyzer/Internals/ListExtensions.cs
index 40cee528..bf5425f5 100644
--- a/src/Meziantou.Analyzer/Internals/ListExtensions.cs
+++ b/src/Meziantou.Analyzer/Internals/ListExtensions.cs
@@ -1,6 +1,6 @@
using System.Collections.Generic;
-namespace Meziantou.Analyzer;
+namespace Meziantou.Analyzer.Internals;
internal static class ListExtensions
{
@@ -8,7 +8,7 @@ public static void AddIfNotNull(this IList list, IEnumerable items) whe
{
foreach (var item in items)
{
- AddIfNotNull(list, item);
+ list.AddIfNotNull(item);
}
}
diff --git a/src/Meziantou.Analyzer/Internals/MethodSymbolExtensions.cs b/src/Meziantou.Analyzer/Internals/MethodSymbolExtensions.cs
index 8fd9fa7b..8018c5c9 100755
--- a/src/Meziantou.Analyzer/Internals/MethodSymbolExtensions.cs
+++ b/src/Meziantou.Analyzer/Internals/MethodSymbolExtensions.cs
@@ -1,7 +1,7 @@
using System.Linq;
using Microsoft.CodeAnalysis;
-namespace Meziantou.Analyzer;
+namespace Meziantou.Analyzer.Internals;
internal static class MethodSymbolExtensions
{
diff --git a/src/Meziantou.Analyzer/Internals/NamespaceSymbolExtensions.cs b/src/Meziantou.Analyzer/Internals/NamespaceSymbolExtensions.cs
index 58a6aa57..1dcd71c0 100644
--- a/src/Meziantou.Analyzer/Internals/NamespaceSymbolExtensions.cs
+++ b/src/Meziantou.Analyzer/Internals/NamespaceSymbolExtensions.cs
@@ -1,6 +1,6 @@
using Microsoft.CodeAnalysis;
-namespace Meziantou.Analyzer;
+namespace Meziantou.Analyzer.Internals;
internal static class NamespaceSymbolExtensions
{
diff --git a/src/Meziantou.Analyzer/Internals/ObjectPool.cs b/src/Meziantou.Analyzer/Internals/ObjectPool.cs
index a61d5b5a..3803d4b4 100644
--- a/src/Meziantou.Analyzer/Internals/ObjectPool.cs
+++ b/src/Meziantou.Analyzer/Internals/ObjectPool.cs
@@ -7,7 +7,6 @@
namespace Meziantou.Analyzer.Internals;
-
///
/// A pool of objects.
///
diff --git a/src/Meziantou.Analyzer/Internals/OperationExtensions.cs b/src/Meziantou.Analyzer/Internals/OperationExtensions.cs
index 6dec93da..e18a942c 100644
--- a/src/Meziantou.Analyzer/Internals/OperationExtensions.cs
+++ b/src/Meziantou.Analyzer/Internals/OperationExtensions.cs
@@ -1,12 +1,13 @@
using System.Collections.Generic;
using System.Linq;
using System.Threading;
+using Meziantou.Analyzer.Internals;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Microsoft.CodeAnalysis.Operations;
-namespace Meziantou.Analyzer;
+namespace Meziantou.Analyzer.Internals;
internal static class OperationExtensions
{
diff --git a/src/Meziantou.Analyzer/Internals/OperationUtilities.cs b/src/Meziantou.Analyzer/Internals/OperationUtilities.cs
index 66d2deef..ff80e32f 100644
--- a/src/Meziantou.Analyzer/Internals/OperationUtilities.cs
+++ b/src/Meziantou.Analyzer/Internals/OperationUtilities.cs
@@ -1,7 +1,7 @@
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.Operations;
-namespace Meziantou.Analyzer;
+namespace Meziantou.Analyzer.Internals;
internal sealed class OperationUtilities(Compilation compilation)
{
@@ -36,5 +36,4 @@ public bool IsInExpressionContext(IOperation operation)
return false;
}
-
}
diff --git a/src/Meziantou.Analyzer/Internals/StringExtensions.cs b/src/Meziantou.Analyzer/Internals/StringExtensions.cs
index 0264027b..1b3a2b5f 100644
--- a/src/Meziantou.Analyzer/Internals/StringExtensions.cs
+++ b/src/Meziantou.Analyzer/Internals/StringExtensions.cs
@@ -1,7 +1,7 @@
using System;
using System.Runtime.InteropServices;
-namespace Meziantou.Analyzer.Rules;
+namespace Meziantou.Analyzer.Internals;
internal static partial class StringExtensions
{
diff --git a/src/Meziantou.Analyzer/Internals/SymbolExtensions.cs b/src/Meziantou.Analyzer/Internals/SymbolExtensions.cs
index 0bf3f4a0..1108f55e 100644
--- a/src/Meziantou.Analyzer/Internals/SymbolExtensions.cs
+++ b/src/Meziantou.Analyzer/Internals/SymbolExtensions.cs
@@ -3,7 +3,7 @@
using System.Threading;
using Microsoft.CodeAnalysis;
-namespace Meziantou.Analyzer;
+namespace Meziantou.Analyzer.Internals;
internal static class SymbolExtensions
{
diff --git a/src/Meziantou.Analyzer/Internals/SyntaxTokenListExtensions.cs b/src/Meziantou.Analyzer/Internals/SyntaxTokenListExtensions.cs
index 56082226..486dcbf6 100644
--- a/src/Meziantou.Analyzer/Internals/SyntaxTokenListExtensions.cs
+++ b/src/Meziantou.Analyzer/Internals/SyntaxTokenListExtensions.cs
@@ -2,7 +2,7 @@
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp;
-namespace Meziantou.Analyzer;
+namespace Meziantou.Analyzer.Internals;
internal static class SyntaxTokenListExtensions
{
diff --git a/src/Meziantou.Analyzer/Internals/TypeSymbolExtensions.cs b/src/Meziantou.Analyzer/Internals/TypeSymbolExtensions.cs
index c59be90e..805f0805 100755
--- a/src/Meziantou.Analyzer/Internals/TypeSymbolExtensions.cs
+++ b/src/Meziantou.Analyzer/Internals/TypeSymbolExtensions.cs
@@ -3,7 +3,7 @@
using System.Linq;
using Microsoft.CodeAnalysis;
-namespace Meziantou.Analyzer;
+namespace Meziantou.Analyzer.Internals;
// http://source.roslyn.io/#Microsoft.CodeAnalysis.Workspaces/Shared/Extensions/ITypeSymbolExtensions.cs,190b4ed0932458fd,references
internal static class TypeSymbolExtensions
diff --git a/src/Meziantou.Analyzer/Meziantou.Analyzer.csproj b/src/Meziantou.Analyzer/Meziantou.Analyzer.csproj
index 5c1dbf0b..390a2aae 100644
--- a/src/Meziantou.Analyzer/Meziantou.Analyzer.csproj
+++ b/src/Meziantou.Analyzer/Meziantou.Analyzer.csproj
@@ -1,6 +1,6 @@
- net8.0;netstandard2.0
+ net9.0;netstandard2.0
false
1.0.1
diff --git a/src/Meziantou.Analyzer/Rules/AbstractTypesShouldNotHaveConstructorsAnalyzer.cs b/src/Meziantou.Analyzer/Rules/AbstractTypesShouldNotHaveConstructorsAnalyzer.cs
index 5af2a633..077d15fe 100755
--- a/src/Meziantou.Analyzer/Rules/AbstractTypesShouldNotHaveConstructorsAnalyzer.cs
+++ b/src/Meziantou.Analyzer/Rules/AbstractTypesShouldNotHaveConstructorsAnalyzer.cs
@@ -1,4 +1,5 @@
using System.Collections.Immutable;
+using Meziantou.Analyzer.Internals;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.Diagnostics;
diff --git a/src/Meziantou.Analyzer/Rules/AddOverloadWithSpanOrMemoryAnalyzer.cs b/src/Meziantou.Analyzer/Rules/AddOverloadWithSpanOrMemoryAnalyzer.cs
index 4b4553bc..cfe6041f 100644
--- a/src/Meziantou.Analyzer/Rules/AddOverloadWithSpanOrMemoryAnalyzer.cs
+++ b/src/Meziantou.Analyzer/Rules/AddOverloadWithSpanOrMemoryAnalyzer.cs
@@ -1,5 +1,6 @@
using System.Collections.Immutable;
using System.Linq;
+using Meziantou.Analyzer.Internals;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.Diagnostics;
@@ -40,7 +41,7 @@ private static void AnalyzeMethod(SymbolAnalysisContext context)
if (method.MethodKind is not MethodKind.Ordinary and not MethodKind.Constructor)
return;
- if (!method.Parameters.Any(p => IsCandidateForSpanOrMemory(p)))
+ if (!method.Parameters.Any(IsCandidateForSpanOrMemory))
return;
var overloads = method.ContainingType.GetMembers(method.Name);
diff --git a/src/Meziantou.Analyzer/Rules/AnonymousDelegatesShouldNotBeUsedToUnsubscribeFromEventsAnalyzer.cs b/src/Meziantou.Analyzer/Rules/AnonymousDelegatesShouldNotBeUsedToUnsubscribeFromEventsAnalyzer.cs
index 8b30fad0..b810da36 100755
--- a/src/Meziantou.Analyzer/Rules/AnonymousDelegatesShouldNotBeUsedToUnsubscribeFromEventsAnalyzer.cs
+++ b/src/Meziantou.Analyzer/Rules/AnonymousDelegatesShouldNotBeUsedToUnsubscribeFromEventsAnalyzer.cs
@@ -1,4 +1,5 @@
using System.Collections.Immutable;
+using Meziantou.Analyzer.Internals;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.Diagnostics;
using Microsoft.CodeAnalysis.Operations;
diff --git a/src/Meziantou.Analyzer/Rules/ArgumentExceptionShouldSpecifyArgumentNameAnalyzer.cs b/src/Meziantou.Analyzer/Rules/ArgumentExceptionShouldSpecifyArgumentNameAnalyzer.cs
index d425e106..c7e3e597 100644
--- a/src/Meziantou.Analyzer/Rules/ArgumentExceptionShouldSpecifyArgumentNameAnalyzer.cs
+++ b/src/Meziantou.Analyzer/Rules/ArgumentExceptionShouldSpecifyArgumentNameAnalyzer.cs
@@ -3,6 +3,7 @@
using System.Collections.Immutable;
using System.Linq;
using System.Threading;
+using Meziantou.Analyzer.Internals;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Microsoft.CodeAnalysis.Diagnostics;
diff --git a/src/Meziantou.Analyzer/Rules/AttributeNameShouldEndWithAttributeAnalyzer.cs b/src/Meziantou.Analyzer/Rules/AttributeNameShouldEndWithAttributeAnalyzer.cs
index 986eb3f8..d0706beb 100644
--- a/src/Meziantou.Analyzer/Rules/AttributeNameShouldEndWithAttributeAnalyzer.cs
+++ b/src/Meziantou.Analyzer/Rules/AttributeNameShouldEndWithAttributeAnalyzer.cs
@@ -1,4 +1,5 @@
using System.Collections.Immutable;
+using Meziantou.Analyzer.Internals;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.Diagnostics;
diff --git a/src/Meziantou.Analyzer/Rules/AvoidClosureWhenUsingConcurrentDictionaryAnalyzer.cs b/src/Meziantou.Analyzer/Rules/AvoidClosureWhenUsingConcurrentDictionaryAnalyzer.cs
index 48bdb9ab..a4e7e39e 100644
--- a/src/Meziantou.Analyzer/Rules/AvoidClosureWhenUsingConcurrentDictionaryAnalyzer.cs
+++ b/src/Meziantou.Analyzer/Rules/AvoidClosureWhenUsingConcurrentDictionaryAnalyzer.cs
@@ -2,6 +2,7 @@
using System.Collections.Immutable;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
+using Meziantou.Analyzer.Internals;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Microsoft.CodeAnalysis.Diagnostics;
@@ -95,7 +96,6 @@ public void AnalyzeInvocation(OperationAnalysisContext context)
handled |= DetectPotentialUsageOfLambdaParameter(context, op.Arguments[1].Value, op.Arguments[0]);
handled |= DetectPotentialUsageOfLambdaParameter(context, op.Arguments[1].Value, op.Arguments[2]);
}
-
}
else if (op.TargetMethod.Name is "AddOrUpdate")
{
@@ -121,7 +121,7 @@ public void AnalyzeInvocation(OperationAnalysisContext context)
}
}
- if (!handled && (GetOrAddHasOverloadWithArg && op.TargetMethod.Name is "GetOrAdd") || (AddOrUpdateHasOverloadWithArg && op.TargetMethod.Name is "AddOrUpdate"))
+ if ((!handled && GetOrAddHasOverloadWithArg && op.TargetMethod.Name is "GetOrAdd") || (AddOrUpdateHasOverloadWithArg && op.TargetMethod.Name is "AddOrUpdate"))
{
foreach (var arg in op.Arguments)
{
@@ -205,7 +205,7 @@ static IEnumerable GetParameters(IOperation operation)
return GetParameters(delegateCreation.Target);
}
- return Enumerable.Empty();
+ return [];
}
}
diff --git a/src/Meziantou.Analyzer/Rules/AvoidComparisonWithBoolConstantAnalyzer.cs b/src/Meziantou.Analyzer/Rules/AvoidComparisonWithBoolConstantAnalyzer.cs
index cd940b62..e796aff5 100644
--- a/src/Meziantou.Analyzer/Rules/AvoidComparisonWithBoolConstantAnalyzer.cs
+++ b/src/Meziantou.Analyzer/Rules/AvoidComparisonWithBoolConstantAnalyzer.cs
@@ -1,5 +1,6 @@
using System.Collections.Immutable;
using System.Globalization;
+using Meziantou.Analyzer.Internals;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Microsoft.CodeAnalysis.Diagnostics;
@@ -34,8 +35,7 @@ private static void AnalyzeBinaryOperation(OperationAnalysisContext context)
{
var binaryOperation = (IBinaryOperation)context.Operation;
- if (binaryOperation.OperatorKind != BinaryOperatorKind.Equals &&
- binaryOperation.OperatorKind != BinaryOperatorKind.NotEquals)
+ if (binaryOperation.OperatorKind is not BinaryOperatorKind.Equals and not BinaryOperatorKind.NotEquals)
{
return;
}
diff --git a/src/Meziantou.Analyzer/Rules/AvoidLockingOnPubliclyAccessibleInstanceAnalyzer.cs b/src/Meziantou.Analyzer/Rules/AvoidLockingOnPubliclyAccessibleInstanceAnalyzer.cs
index f12adf66..9fae6e91 100644
--- a/src/Meziantou.Analyzer/Rules/AvoidLockingOnPubliclyAccessibleInstanceAnalyzer.cs
+++ b/src/Meziantou.Analyzer/Rules/AvoidLockingOnPubliclyAccessibleInstanceAnalyzer.cs
@@ -1,4 +1,5 @@
using System.Collections.Immutable;
+using Meziantou.Analyzer.Internals;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.Diagnostics;
using Microsoft.CodeAnalysis.Operations;
diff --git a/src/Meziantou.Analyzer/Rules/AvoidUsingRedundantElseAnalyzer.cs b/src/Meziantou.Analyzer/Rules/AvoidUsingRedundantElseAnalyzer.cs
index f21f2bb1..aa8978e5 100644
--- a/src/Meziantou.Analyzer/Rules/AvoidUsingRedundantElseAnalyzer.cs
+++ b/src/Meziantou.Analyzer/Rules/AvoidUsingRedundantElseAnalyzer.cs
@@ -1,6 +1,7 @@
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Linq;
+using Meziantou.Analyzer.Internals;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp;
using Microsoft.CodeAnalysis.CSharp.Syntax;
@@ -75,6 +76,7 @@ private static IEnumerable FindLocalIdentifiersIn(SyntaxNode node)
{
foreach (var child in node.DescendantNodes())
{
+#pragma warning disable
switch (child)
{
case VariableDeclaratorSyntax variableDeclarator:
@@ -89,6 +91,7 @@ private static IEnumerable FindLocalIdentifiersIn(SyntaxNode node)
yield return singleVariableDesignation.Identifier.Text;
break;
}
+#pragma warning restore IDE0010 // Add missing cases
}
}
}
diff --git a/src/Meziantou.Analyzer/Rules/AvoidUsingRedundantElseAnalyzerCommon.cs b/src/Meziantou.Analyzer/Rules/AvoidUsingRedundantElseAnalyzerCommon.cs
index d2a75693..90a6f036 100644
--- a/src/Meziantou.Analyzer/Rules/AvoidUsingRedundantElseAnalyzerCommon.cs
+++ b/src/Meziantou.Analyzer/Rules/AvoidUsingRedundantElseAnalyzerCommon.cs
@@ -10,6 +10,6 @@ internal static IEnumerable GetElseClauseChildren(ElseClauseSyntax e
{
return elseClauseSyntax.Statement is BlockSyntax elseBlockSyntax ?
elseBlockSyntax.ChildNodes() :
- new[] { elseClauseSyntax.Statement };
+ [elseClauseSyntax.Statement];
}
}
diff --git a/src/Meziantou.Analyzer/Rules/ConstructorArgumentParametersShouldExistInConstructorsAnalyzer.cs b/src/Meziantou.Analyzer/Rules/ConstructorArgumentParametersShouldExistInConstructorsAnalyzer.cs
index dadca717..c2bd3d39 100644
--- a/src/Meziantou.Analyzer/Rules/ConstructorArgumentParametersShouldExistInConstructorsAnalyzer.cs
+++ b/src/Meziantou.Analyzer/Rules/ConstructorArgumentParametersShouldExistInConstructorsAnalyzer.cs
@@ -1,5 +1,6 @@
using System;
using System.Collections.Immutable;
+using Meziantou.Analyzer.Internals;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.Diagnostics;
diff --git a/src/Meziantou.Analyzer/Rules/DebuggerDisplayAttributeShouldContainValidExpressionsAnalyzer.cs b/src/Meziantou.Analyzer/Rules/DebuggerDisplayAttributeShouldContainValidExpressionsAnalyzer.cs
index 8ad296aa..558d181c 100644
--- a/src/Meziantou.Analyzer/Rules/DebuggerDisplayAttributeShouldContainValidExpressionsAnalyzer.cs
+++ b/src/Meziantou.Analyzer/Rules/DebuggerDisplayAttributeShouldContainValidExpressionsAnalyzer.cs
@@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Diagnostics;
+using Meziantou.Analyzer.Internals;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.Diagnostics;
diff --git a/src/Meziantou.Analyzer/Rules/DeclareTypesInNamespacesAnalyzer.cs b/src/Meziantou.Analyzer/Rules/DeclareTypesInNamespacesAnalyzer.cs
index 1041981f..49b0fbd9 100644
--- a/src/Meziantou.Analyzer/Rules/DeclareTypesInNamespacesAnalyzer.cs
+++ b/src/Meziantou.Analyzer/Rules/DeclareTypesInNamespacesAnalyzer.cs
@@ -1,4 +1,5 @@
using System.Collections.Immutable;
+using Meziantou.Analyzer.Internals;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.Diagnostics;
diff --git a/src/Meziantou.Analyzer/Rules/DoNotCallVirtualMethodInConstructorAnalyzer.cs b/src/Meziantou.Analyzer/Rules/DoNotCallVirtualMethodInConstructorAnalyzer.cs
index 4522d581..62569dac 100644
--- a/src/Meziantou.Analyzer/Rules/DoNotCallVirtualMethodInConstructorAnalyzer.cs
+++ b/src/Meziantou.Analyzer/Rules/DoNotCallVirtualMethodInConstructorAnalyzer.cs
@@ -1,5 +1,6 @@
using System.Collections.Immutable;
using System.Linq;
+using Meziantou.Analyzer.Internals;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.Diagnostics;
using Microsoft.CodeAnalysis.Operations;
diff --git a/src/Meziantou.Analyzer/Rules/DoNotDeclareStaticMembersOnGenericTypes.cs b/src/Meziantou.Analyzer/Rules/DoNotDeclareStaticMembersOnGenericTypes.cs
index 883b0aa3..34309c89 100644
--- a/src/Meziantou.Analyzer/Rules/DoNotDeclareStaticMembersOnGenericTypes.cs
+++ b/src/Meziantou.Analyzer/Rules/DoNotDeclareStaticMembersOnGenericTypes.cs
@@ -1,4 +1,5 @@
using System.Collections.Immutable;
+using Meziantou.Analyzer.Internals;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.Diagnostics;
diff --git a/src/Meziantou.Analyzer/Rules/DoNotImplicitlyConvertDateTimeToDateTimeOffsetAnalyzer.cs b/src/Meziantou.Analyzer/Rules/DoNotImplicitlyConvertDateTimeToDateTimeOffsetAnalyzer.cs
index 548f6975..5f9c77a6 100644
--- a/src/Meziantou.Analyzer/Rules/DoNotImplicitlyConvertDateTimeToDateTimeOffsetAnalyzer.cs
+++ b/src/Meziantou.Analyzer/Rules/DoNotImplicitlyConvertDateTimeToDateTimeOffsetAnalyzer.cs
@@ -1,4 +1,5 @@
using System.Collections.Immutable;
+using Meziantou.Analyzer.Internals;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.Diagnostics;
using Microsoft.CodeAnalysis.Operations;
diff --git a/src/Meziantou.Analyzer/Rules/DoNotLogClassifiedDataAnalyzer.cs b/src/Meziantou.Analyzer/Rules/DoNotLogClassifiedDataAnalyzer.cs
index bcd5c35d..1fd705f3 100644
--- a/src/Meziantou.Analyzer/Rules/DoNotLogClassifiedDataAnalyzer.cs
+++ b/src/Meziantou.Analyzer/Rules/DoNotLogClassifiedDataAnalyzer.cs
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Collections.Immutable;
+using Meziantou.Analyzer.Internals;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.Diagnostics;
using Microsoft.CodeAnalysis.Operations;
diff --git a/src/Meziantou.Analyzer/Rules/DoNotNaNInComparisonsAnalyzer.cs b/src/Meziantou.Analyzer/Rules/DoNotNaNInComparisonsAnalyzer.cs
index 80fd2c2e..8050a42f 100644
--- a/src/Meziantou.Analyzer/Rules/DoNotNaNInComparisonsAnalyzer.cs
+++ b/src/Meziantou.Analyzer/Rules/DoNotNaNInComparisonsAnalyzer.cs
@@ -1,5 +1,6 @@
using System.Collections.Immutable;
using System.Linq;
+using Meziantou.Analyzer.Internals;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.Diagnostics;
using Microsoft.CodeAnalysis.Operations;
diff --git a/src/Meziantou.Analyzer/Rules/DoNotOverwriteRazorComponentParameterValue.cs b/src/Meziantou.Analyzer/Rules/DoNotOverwriteRazorComponentParameterValue.cs
index 46fc59dd..11e6e9fc 100644
--- a/src/Meziantou.Analyzer/Rules/DoNotOverwriteRazorComponentParameterValue.cs
+++ b/src/Meziantou.Analyzer/Rules/DoNotOverwriteRazorComponentParameterValue.cs
@@ -1,4 +1,5 @@
using System.Collections.Immutable;
+using Meziantou.Analyzer.Internals;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.Diagnostics;
using Microsoft.CodeAnalysis.Operations;
diff --git a/src/Meziantou.Analyzer/Rules/DoNotRaiseApplicationExceptionAnalyzer.cs b/src/Meziantou.Analyzer/Rules/DoNotRaiseApplicationExceptionAnalyzer.cs
index 98ac2c4b..14526d80 100644
--- a/src/Meziantou.Analyzer/Rules/DoNotRaiseApplicationExceptionAnalyzer.cs
+++ b/src/Meziantou.Analyzer/Rules/DoNotRaiseApplicationExceptionAnalyzer.cs
@@ -1,4 +1,5 @@
using System.Collections.Immutable;
+using Meziantou.Analyzer.Internals;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.Diagnostics;
using Microsoft.CodeAnalysis.Operations;
diff --git a/src/Meziantou.Analyzer/Rules/DoNotRaiseNotImplementedExceptionAnalyzer.cs b/src/Meziantou.Analyzer/Rules/DoNotRaiseNotImplementedExceptionAnalyzer.cs
index 620a07a0..4c4b7da3 100644
--- a/src/Meziantou.Analyzer/Rules/DoNotRaiseNotImplementedExceptionAnalyzer.cs
+++ b/src/Meziantou.Analyzer/Rules/DoNotRaiseNotImplementedExceptionAnalyzer.cs
@@ -1,4 +1,5 @@
using System.Collections.Immutable;
+using Meziantou.Analyzer.Internals;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.Diagnostics;
using Microsoft.CodeAnalysis.Operations;
diff --git a/src/Meziantou.Analyzer/Rules/DoNotRaiseReservedExceptionTypeAnalyzer.cs b/src/Meziantou.Analyzer/Rules/DoNotRaiseReservedExceptionTypeAnalyzer.cs
index ea8d59ea..1ed5eb93 100644
--- a/src/Meziantou.Analyzer/Rules/DoNotRaiseReservedExceptionTypeAnalyzer.cs
+++ b/src/Meziantou.Analyzer/Rules/DoNotRaiseReservedExceptionTypeAnalyzer.cs
@@ -1,6 +1,7 @@
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Linq;
+using Meziantou.Analyzer.Internals;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.Diagnostics;
using Microsoft.CodeAnalysis.Operations;
diff --git a/src/Meziantou.Analyzer/Rules/DoNotRemoveOriginalExceptionFromThrowStatementAnalyzer.cs b/src/Meziantou.Analyzer/Rules/DoNotRemoveOriginalExceptionFromThrowStatementAnalyzer.cs
index 67dbd956..2aa76ce4 100644
--- a/src/Meziantou.Analyzer/Rules/DoNotRemoveOriginalExceptionFromThrowStatementAnalyzer.cs
+++ b/src/Meziantou.Analyzer/Rules/DoNotRemoveOriginalExceptionFromThrowStatementAnalyzer.cs
@@ -1,5 +1,6 @@
using System.Collections.Immutable;
using System.Linq;
+using Meziantou.Analyzer.Internals;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.Diagnostics;
using Microsoft.CodeAnalysis.Operations;
diff --git a/src/Meziantou.Analyzer/Rules/DoNotThrowFromFinalizerAnalyzer.cs b/src/Meziantou.Analyzer/Rules/DoNotThrowFromFinalizerAnalyzer.cs
index b161d228..8d39c067 100644
--- a/src/Meziantou.Analyzer/Rules/DoNotThrowFromFinalizerAnalyzer.cs
+++ b/src/Meziantou.Analyzer/Rules/DoNotThrowFromFinalizerAnalyzer.cs
@@ -1,5 +1,6 @@
using System.Collections.Immutable;
using System.Linq;
+using Meziantou.Analyzer.Internals;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp;
using Microsoft.CodeAnalysis.CSharp.Syntax;
diff --git a/src/Meziantou.Analyzer/Rules/DoNotThrowFromFinallyBlockAnalyzer.cs b/src/Meziantou.Analyzer/Rules/DoNotThrowFromFinallyBlockAnalyzer.cs
index 6f11d56b..ef0e7cee 100644
--- a/src/Meziantou.Analyzer/Rules/DoNotThrowFromFinallyBlockAnalyzer.cs
+++ b/src/Meziantou.Analyzer/Rules/DoNotThrowFromFinallyBlockAnalyzer.cs
@@ -1,5 +1,6 @@
using System.Collections.Immutable;
using System.Linq;
+using Meziantou.Analyzer.Internals;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp;
using Microsoft.CodeAnalysis.CSharp.Syntax;
diff --git a/src/Meziantou.Analyzer/Rules/DoNotUseAsyncDelegateForSyncDelegateAnalyzer.cs b/src/Meziantou.Analyzer/Rules/DoNotUseAsyncDelegateForSyncDelegateAnalyzer.cs
index e61c1152..5cd2905a 100644
--- a/src/Meziantou.Analyzer/Rules/DoNotUseAsyncDelegateForSyncDelegateAnalyzer.cs
+++ b/src/Meziantou.Analyzer/Rules/DoNotUseAsyncDelegateForSyncDelegateAnalyzer.cs
@@ -1,4 +1,5 @@
using System.Collections.Immutable;
+using Meziantou.Analyzer.Internals;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.Diagnostics;
using Microsoft.CodeAnalysis.Operations;
diff --git a/src/Meziantou.Analyzer/Rules/DoNotUseAsyncVoidAnalyzer.cs b/src/Meziantou.Analyzer/Rules/DoNotUseAsyncVoidAnalyzer.cs
index 39acea08..3bb56083 100755
--- a/src/Meziantou.Analyzer/Rules/DoNotUseAsyncVoidAnalyzer.cs
+++ b/src/Meziantou.Analyzer/Rules/DoNotUseAsyncVoidAnalyzer.cs
@@ -1,4 +1,5 @@
using System.Collections.Immutable;
+using Meziantou.Analyzer.Internals;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.Diagnostics;
using Microsoft.CodeAnalysis.Operations;
diff --git a/src/Meziantou.Analyzer/Rules/DoNotUseDefaultEqualsOnValueTypeAnalyzer.cs b/src/Meziantou.Analyzer/Rules/DoNotUseDefaultEqualsOnValueTypeAnalyzer.cs
index 1dfca0e3..fc27ac15 100644
--- a/src/Meziantou.Analyzer/Rules/DoNotUseDefaultEqualsOnValueTypeAnalyzer.cs
+++ b/src/Meziantou.Analyzer/Rules/DoNotUseDefaultEqualsOnValueTypeAnalyzer.cs
@@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Linq;
+using Meziantou.Analyzer.Internals;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.Diagnostics;
using Microsoft.CodeAnalysis.Operations;
@@ -166,7 +167,7 @@ public void AnalyzeFieldReferenceOperation(OperationAnalysisContext context)
if ((type?.OriginalDefinition) is null)
return;
- if (HashSetSymbols.Any(t => type.OriginalDefinition.IsEqualTo(t)))
+ if (HashSetSymbols.Any(type.OriginalDefinition.IsEqualTo))
{
if (IsStruct(type.TypeArguments[0]) && HasDefaultEqualsOrHashCodeImplementations(type.TypeArguments[0]))
{
@@ -186,7 +187,7 @@ public void AnalyzeObjectCreationOperation(OperationAnalysisContext context)
if (operation.Constructor is null)
return;
- if (HashSetSymbols.Any(t => type.OriginalDefinition.IsEqualTo(t)))
+ if (HashSetSymbols.Any(type.OriginalDefinition.IsEqualTo))
{
if (operation.Constructor.Parameters.Any(arg => arg.Type.IsEqualTo(IEqualityComparerSymbol?.Construct(type.TypeArguments[0]))))
return;
diff --git a/src/Meziantou.Analyzer/Rules/DoNotUseEqualityComparerDefaultOfStringAnalyzer.cs b/src/Meziantou.Analyzer/Rules/DoNotUseEqualityComparerDefaultOfStringAnalyzer.cs
index bb82d02c..f6b659ba 100644
--- a/src/Meziantou.Analyzer/Rules/DoNotUseEqualityComparerDefaultOfStringAnalyzer.cs
+++ b/src/Meziantou.Analyzer/Rules/DoNotUseEqualityComparerDefaultOfStringAnalyzer.cs
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Collections.Immutable;
+using Meziantou.Analyzer.Internals;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.Diagnostics;
using Microsoft.CodeAnalysis.Operations;
diff --git a/src/Meziantou.Analyzer/Rules/DoNotUseEqualityOperatorsForSpanOfCharAnalyzer.cs b/src/Meziantou.Analyzer/Rules/DoNotUseEqualityOperatorsForSpanOfCharAnalyzer.cs
index 954ccd8d..14182096 100644
--- a/src/Meziantou.Analyzer/Rules/DoNotUseEqualityOperatorsForSpanOfCharAnalyzer.cs
+++ b/src/Meziantou.Analyzer/Rules/DoNotUseEqualityOperatorsForSpanOfCharAnalyzer.cs
@@ -1,4 +1,5 @@
using System.Collections.Immutable;
+using Meziantou.Analyzer.Internals;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.Diagnostics;
using Microsoft.CodeAnalysis.Operations;
diff --git a/src/Meziantou.Analyzer/Rules/DoNotUseFinalizerAnalyzer.cs b/src/Meziantou.Analyzer/Rules/DoNotUseFinalizerAnalyzer.cs
index d032d385..bc7397d6 100644
--- a/src/Meziantou.Analyzer/Rules/DoNotUseFinalizerAnalyzer.cs
+++ b/src/Meziantou.Analyzer/Rules/DoNotUseFinalizerAnalyzer.cs
@@ -1,4 +1,5 @@
using System.Collections.Immutable;
+using Meziantou.Analyzer.Internals;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.Diagnostics;
diff --git a/src/Meziantou.Analyzer/Rules/DoNotUseServerCertificateValidationCallbackAnalyzer.cs b/src/Meziantou.Analyzer/Rules/DoNotUseServerCertificateValidationCallbackAnalyzer.cs
index 12ea5901..8872aff5 100644
--- a/src/Meziantou.Analyzer/Rules/DoNotUseServerCertificateValidationCallbackAnalyzer.cs
+++ b/src/Meziantou.Analyzer/Rules/DoNotUseServerCertificateValidationCallbackAnalyzer.cs
@@ -1,6 +1,7 @@
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Linq;
+using Meziantou.Analyzer.Internals;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.Diagnostics;
using Microsoft.CodeAnalysis.Operations;
diff --git a/src/Meziantou.Analyzer/Rules/DoNotUseStringGetHashCodeAnalyzer.cs b/src/Meziantou.Analyzer/Rules/DoNotUseStringGetHashCodeAnalyzer.cs
index 966db9f8..790ed236 100644
--- a/src/Meziantou.Analyzer/Rules/DoNotUseStringGetHashCodeAnalyzer.cs
+++ b/src/Meziantou.Analyzer/Rules/DoNotUseStringGetHashCodeAnalyzer.cs
@@ -1,4 +1,5 @@
using System.Collections.Immutable;
+using Meziantou.Analyzer.Internals;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.Diagnostics;
using Microsoft.CodeAnalysis.Operations;
diff --git a/src/Meziantou.Analyzer/Rules/DoNotUseToStringIfObjectAnalyzer.cs b/src/Meziantou.Analyzer/Rules/DoNotUseToStringIfObjectAnalyzer.cs
index fe5145c8..6cf2a2ab 100644
--- a/src/Meziantou.Analyzer/Rules/DoNotUseToStringIfObjectAnalyzer.cs
+++ b/src/Meziantou.Analyzer/Rules/DoNotUseToStringIfObjectAnalyzer.cs
@@ -1,6 +1,7 @@
using System.Collections.Concurrent;
using System.Collections.Immutable;
using System.Linq;
+using Meziantou.Analyzer.Internals;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.Diagnostics;
using Microsoft.CodeAnalysis.Operations;
diff --git a/src/Meziantou.Analyzer/Rules/DoNotUseUnknownParameterForRazorComponentAnalyzer.cs b/src/Meziantou.Analyzer/Rules/DoNotUseUnknownParameterForRazorComponentAnalyzer.cs
index 4937cebc..2627802d 100644
--- a/src/Meziantou.Analyzer/Rules/DoNotUseUnknownParameterForRazorComponentAnalyzer.cs
+++ b/src/Meziantou.Analyzer/Rules/DoNotUseUnknownParameterForRazorComponentAnalyzer.cs
@@ -4,6 +4,7 @@
using System.Collections.Immutable;
using System.Linq;
using Meziantou.Analyzer.Configurations;
+using Meziantou.Analyzer.Internals;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.Diagnostics;
using Microsoft.CodeAnalysis.Operations;
diff --git a/src/Meziantou.Analyzer/Rules/DoNotUseZeroToInitializeAnEnumValue.cs b/src/Meziantou.Analyzer/Rules/DoNotUseZeroToInitializeAnEnumValue.cs
index 8e3271e8..42e421f2 100644
--- a/src/Meziantou.Analyzer/Rules/DoNotUseZeroToInitializeAnEnumValue.cs
+++ b/src/Meziantou.Analyzer/Rules/DoNotUseZeroToInitializeAnEnumValue.cs
@@ -1,4 +1,5 @@
using System.Collections.Immutable;
+using Meziantou.Analyzer.Internals;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.Diagnostics;
using Microsoft.CodeAnalysis.Operations;
diff --git a/src/Meziantou.Analyzer/Rules/DontTagInstanceFieldsWithThreadStaticAttributeAnalyzer.cs b/src/Meziantou.Analyzer/Rules/DontTagInstanceFieldsWithThreadStaticAttributeAnalyzer.cs
index 0b5ae034..02bfe64f 100644
--- a/src/Meziantou.Analyzer/Rules/DontTagInstanceFieldsWithThreadStaticAttributeAnalyzer.cs
+++ b/src/Meziantou.Analyzer/Rules/DontTagInstanceFieldsWithThreadStaticAttributeAnalyzer.cs
@@ -1,4 +1,5 @@
using System.Collections.Immutable;
+using Meziantou.Analyzer.Internals;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.Diagnostics;
diff --git a/src/Meziantou.Analyzer/Rules/DontUseDangerousThreadingMethodsAnalyzer.cs b/src/Meziantou.Analyzer/Rules/DontUseDangerousThreadingMethodsAnalyzer.cs
index 57afc4ab..692f0ba5 100644
--- a/src/Meziantou.Analyzer/Rules/DontUseDangerousThreadingMethodsAnalyzer.cs
+++ b/src/Meziantou.Analyzer/Rules/DontUseDangerousThreadingMethodsAnalyzer.cs
@@ -1,5 +1,6 @@
using System;
using System.Collections.Immutable;
+using Meziantou.Analyzer.Internals;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.Diagnostics;
using Microsoft.CodeAnalysis.Operations;
diff --git a/src/Meziantou.Analyzer/Rules/DotNotUseNameFromBCLAnalyzer.cs b/src/Meziantou.Analyzer/Rules/DotNotUseNameFromBCLAnalyzer.cs
index f404474a..f68e1ca8 100644
--- a/src/Meziantou.Analyzer/Rules/DotNotUseNameFromBCLAnalyzer.cs
+++ b/src/Meziantou.Analyzer/Rules/DotNotUseNameFromBCLAnalyzer.cs
@@ -5,6 +5,7 @@
using System.Text.RegularExpressions;
using System.Threading;
using Meziantou.Analyzer.Configurations;
+using Meziantou.Analyzer.Internals;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.Diagnostics;
diff --git a/src/Meziantou.Analyzer/Rules/EqualityShouldBeCorrectlyImplementedAnalyzer.cs b/src/Meziantou.Analyzer/Rules/EqualityShouldBeCorrectlyImplementedAnalyzer.cs
index 1ee8a08c..8ec28622 100644
--- a/src/Meziantou.Analyzer/Rules/EqualityShouldBeCorrectlyImplementedAnalyzer.cs
+++ b/src/Meziantou.Analyzer/Rules/EqualityShouldBeCorrectlyImplementedAnalyzer.cs
@@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Linq;
+using Meziantou.Analyzer.Internals;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.Diagnostics;
diff --git a/src/Meziantou.Analyzer/Rules/EqualityShouldBeCorrectlyImplementedAnalyzerCommon.cs b/src/Meziantou.Analyzer/Rules/EqualityShouldBeCorrectlyImplementedAnalyzerCommon.cs
index f462f125..7e641e6c 100644
--- a/src/Meziantou.Analyzer/Rules/EqualityShouldBeCorrectlyImplementedAnalyzerCommon.cs
+++ b/src/Meziantou.Analyzer/Rules/EqualityShouldBeCorrectlyImplementedAnalyzerCommon.cs
@@ -1,4 +1,5 @@
-using Microsoft.CodeAnalysis;
+using Meziantou.Analyzer.Internals;
+using Microsoft.CodeAnalysis;
namespace Meziantou.Analyzer.Rules;
diff --git a/src/Meziantou.Analyzer/Rules/EventArgsNameShouldEndWithEventArgsAnalyzer.cs b/src/Meziantou.Analyzer/Rules/EventArgsNameShouldEndWithEventArgsAnalyzer.cs
index 8a5e7277..c40b2ef6 100644
--- a/src/Meziantou.Analyzer/Rules/EventArgsNameShouldEndWithEventArgsAnalyzer.cs
+++ b/src/Meziantou.Analyzer/Rules/EventArgsNameShouldEndWithEventArgsAnalyzer.cs
@@ -1,4 +1,5 @@
using System.Collections.Immutable;
+using Meziantou.Analyzer.Internals;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.Diagnostics;
diff --git a/src/Meziantou.Analyzer/Rules/EventsShouldHaveProperArgumentsAnalyzer.cs b/src/Meziantou.Analyzer/Rules/EventsShouldHaveProperArgumentsAnalyzer.cs
index b0da9cb3..9ad51062 100644
--- a/src/Meziantou.Analyzer/Rules/EventsShouldHaveProperArgumentsAnalyzer.cs
+++ b/src/Meziantou.Analyzer/Rules/EventsShouldHaveProperArgumentsAnalyzer.cs
@@ -1,6 +1,7 @@
using System;
using System.Collections.Immutable;
using System.Threading;
+using Meziantou.Analyzer.Internals;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.Diagnostics;
using Microsoft.CodeAnalysis.Operations;
diff --git a/src/Meziantou.Analyzer/Rules/ExceptionNameShouldEndWithExceptionAnalyzer.cs b/src/Meziantou.Analyzer/Rules/ExceptionNameShouldEndWithExceptionAnalyzer.cs
index c70418c8..644c0977 100644
--- a/src/Meziantou.Analyzer/Rules/ExceptionNameShouldEndWithExceptionAnalyzer.cs
+++ b/src/Meziantou.Analyzer/Rules/ExceptionNameShouldEndWithExceptionAnalyzer.cs
@@ -1,4 +1,5 @@
using System.Collections.Immutable;
+using Meziantou.Analyzer.Internals;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.Diagnostics;
diff --git a/src/Meziantou.Analyzer/Rules/FileNameMustMatchTypeNameAnalyzer.cs b/src/Meziantou.Analyzer/Rules/FileNameMustMatchTypeNameAnalyzer.cs
index 017f6581..189dc00d 100644
--- a/src/Meziantou.Analyzer/Rules/FileNameMustMatchTypeNameAnalyzer.cs
+++ b/src/Meziantou.Analyzer/Rules/FileNameMustMatchTypeNameAnalyzer.cs
@@ -7,6 +7,7 @@
using Microsoft.CodeAnalysis.Diagnostics;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Meziantou.Analyzer.Configurations;
+using Meziantou.Analyzer.Internals;
namespace Meziantou.Analyzer.Rules;
diff --git a/src/Meziantou.Analyzer/Rules/FixToDoAnalyzer.cs b/src/Meziantou.Analyzer/Rules/FixToDoAnalyzer.cs
index 78377ffe..8756ae24 100644
--- a/src/Meziantou.Analyzer/Rules/FixToDoAnalyzer.cs
+++ b/src/Meziantou.Analyzer/Rules/FixToDoAnalyzer.cs
@@ -1,6 +1,7 @@
using System;
using System.Collections.Immutable;
using System.Linq;
+using Meziantou.Analyzer.Internals;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp;
using Microsoft.CodeAnalysis.Diagnostics;
diff --git a/src/Meziantou.Analyzer/Rules/IfElseBranchesAreIdenticalAnalyzer.cs b/src/Meziantou.Analyzer/Rules/IfElseBranchesAreIdenticalAnalyzer.cs
index df01258d..f8abf2ab 100644
--- a/src/Meziantou.Analyzer/Rules/IfElseBranchesAreIdenticalAnalyzer.cs
+++ b/src/Meziantou.Analyzer/Rules/IfElseBranchesAreIdenticalAnalyzer.cs
@@ -1,4 +1,5 @@
using System.Collections.Immutable;
+using Meziantou.Analyzer.Internals;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.Diagnostics;
using Microsoft.CodeAnalysis.Operations;
diff --git a/src/Meziantou.Analyzer/Rules/JSInteropMustNotBeUsedInOnInitializedAnalyzer.cs b/src/Meziantou.Analyzer/Rules/JSInteropMustNotBeUsedInOnInitializedAnalyzer.cs
index 1fc4e1db..65486592 100755
--- a/src/Meziantou.Analyzer/Rules/JSInteropMustNotBeUsedInOnInitializedAnalyzer.cs
+++ b/src/Meziantou.Analyzer/Rules/JSInteropMustNotBeUsedInOnInitializedAnalyzer.cs
@@ -1,4 +1,5 @@
using System.Collections.Immutable;
+using Meziantou.Analyzer.Internals;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.Diagnostics;
using Microsoft.CodeAnalysis.Operations;
diff --git a/src/Meziantou.Analyzer/Rules/JSInvokableMethodsMustBePublicAnalyzer.cs b/src/Meziantou.Analyzer/Rules/JSInvokableMethodsMustBePublicAnalyzer.cs
index a60942a6..9a637a31 100644
--- a/src/Meziantou.Analyzer/Rules/JSInvokableMethodsMustBePublicAnalyzer.cs
+++ b/src/Meziantou.Analyzer/Rules/JSInvokableMethodsMustBePublicAnalyzer.cs
@@ -1,4 +1,5 @@
using System.Collections.Immutable;
+using Meziantou.Analyzer.Internals;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.Diagnostics;
diff --git a/src/Meziantou.Analyzer/Rules/LocalVariablesShouldNotHideSymbolsAnalyzer.cs b/src/Meziantou.Analyzer/Rules/LocalVariablesShouldNotHideSymbolsAnalyzer.cs
index f7a3d391..bf71d28d 100644
--- a/src/Meziantou.Analyzer/Rules/LocalVariablesShouldNotHideSymbolsAnalyzer.cs
+++ b/src/Meziantou.Analyzer/Rules/LocalVariablesShouldNotHideSymbolsAnalyzer.cs
@@ -1,6 +1,7 @@
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Threading;
+using Meziantou.Analyzer.Internals;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp;
using Microsoft.CodeAnalysis.CSharp.Syntax;
diff --git a/src/Meziantou.Analyzer/Rules/LoggerParameterTypeAnalyzer.cs b/src/Meziantou.Analyzer/Rules/LoggerParameterTypeAnalyzer.cs
index a87d84b8..c0a463b5 100644
--- a/src/Meziantou.Analyzer/Rules/LoggerParameterTypeAnalyzer.cs
+++ b/src/Meziantou.Analyzer/Rules/LoggerParameterTypeAnalyzer.cs
@@ -198,7 +198,6 @@ LoggerConfigurationFile LoadConfiguration()
{
configuration[keyName] = [];
}
-
}
}
diff --git a/src/Meziantou.Analyzer/Rules/MakeClassStaticAnalyzer.cs b/src/Meziantou.Analyzer/Rules/MakeClassStaticAnalyzer.cs
index ae65fc59..f9ac2585 100644
--- a/src/Meziantou.Analyzer/Rules/MakeClassStaticAnalyzer.cs
+++ b/src/Meziantou.Analyzer/Rules/MakeClassStaticAnalyzer.cs
@@ -2,6 +2,7 @@
using System.Collections.Immutable;
using System.Linq;
using System.Threading;
+using Meziantou.Analyzer.Internals;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.Diagnostics;
using Microsoft.CodeAnalysis.Operations;
diff --git a/src/Meziantou.Analyzer/Rules/MakeInterpolatedStringAnalyzer.cs b/src/Meziantou.Analyzer/Rules/MakeInterpolatedStringAnalyzer.cs
index adc4fa09..c0b0970d 100644
--- a/src/Meziantou.Analyzer/Rules/MakeInterpolatedStringAnalyzer.cs
+++ b/src/Meziantou.Analyzer/Rules/MakeInterpolatedStringAnalyzer.cs
@@ -1,5 +1,6 @@
using System;
using System.Collections.Immutable;
+using Meziantou.Analyzer.Internals;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp;
using Microsoft.CodeAnalysis.CSharp.Syntax;
diff --git a/src/Meziantou.Analyzer/Rules/MakeMemberReadOnlyAnalyzer.cs b/src/Meziantou.Analyzer/Rules/MakeMemberReadOnlyAnalyzer.cs
index eb5644a6..e8428ad9 100644
--- a/src/Meziantou.Analyzer/Rules/MakeMemberReadOnlyAnalyzer.cs
+++ b/src/Meziantou.Analyzer/Rules/MakeMemberReadOnlyAnalyzer.cs
@@ -1,5 +1,6 @@
using System.Collections.Immutable;
using System.Linq;
+using Meziantou.Analyzer.Internals;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp;
using Microsoft.CodeAnalysis.CSharp.Syntax;
diff --git a/src/Meziantou.Analyzer/Rules/MarkAttributesWithAttributeUsageAttributeAnalyzer.cs b/src/Meziantou.Analyzer/Rules/MarkAttributesWithAttributeUsageAttributeAnalyzer.cs
index 39fb4bb1..fed834f4 100644
--- a/src/Meziantou.Analyzer/Rules/MarkAttributesWithAttributeUsageAttributeAnalyzer.cs
+++ b/src/Meziantou.Analyzer/Rules/MarkAttributesWithAttributeUsageAttributeAnalyzer.cs
@@ -1,4 +1,5 @@
using System.Collections.Immutable;
+using Meziantou.Analyzer.Internals;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.Diagnostics;
diff --git a/src/Meziantou.Analyzer/Rules/MethodOverridesShouldNotChangeParameterDefaultsAnalyzer.cs b/src/Meziantou.Analyzer/Rules/MethodOverridesShouldNotChangeParameterDefaultsAnalyzer.cs
index 6386770a..fc6b663a 100644
--- a/src/Meziantou.Analyzer/Rules/MethodOverridesShouldNotChangeParameterDefaultsAnalyzer.cs
+++ b/src/Meziantou.Analyzer/Rules/MethodOverridesShouldNotChangeParameterDefaultsAnalyzer.cs
@@ -1,6 +1,7 @@
using System;
using System.Collections.Immutable;
using System.Threading;
+using Meziantou.Analyzer.Internals;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Microsoft.CodeAnalysis.Diagnostics;
diff --git a/src/Meziantou.Analyzer/Rules/MethodShouldNotBeTooLongAnalyzer.cs b/src/Meziantou.Analyzer/Rules/MethodShouldNotBeTooLongAnalyzer.cs
index 472d3501..d24fbe85 100644
--- a/src/Meziantou.Analyzer/Rules/MethodShouldNotBeTooLongAnalyzer.cs
+++ b/src/Meziantou.Analyzer/Rules/MethodShouldNotBeTooLongAnalyzer.cs
@@ -2,6 +2,7 @@
using System.Globalization;
using System.Linq;
using Meziantou.Analyzer.Configurations;
+using Meziantou.Analyzer.Internals;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp;
using Microsoft.CodeAnalysis.CSharp.Syntax;
diff --git a/src/Meziantou.Analyzer/Rules/NamedParameterAnalyzer.cs b/src/Meziantou.Analyzer/Rules/NamedParameterAnalyzer.cs
index 622db187..42d6ba15 100644
--- a/src/Meziantou.Analyzer/Rules/NamedParameterAnalyzer.cs
+++ b/src/Meziantou.Analyzer/Rules/NamedParameterAnalyzer.cs
@@ -7,6 +7,7 @@
using System.Threading;
using System.Threading.Tasks;
using Meziantou.Analyzer.Configurations;
+using Meziantou.Analyzer.Internals;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp;
using Microsoft.CodeAnalysis.CSharp.Syntax;
diff --git a/src/Meziantou.Analyzer/Rules/NonConstantStaticFieldsShouldNotBeVisibleAnalyzer.cs b/src/Meziantou.Analyzer/Rules/NonConstantStaticFieldsShouldNotBeVisibleAnalyzer.cs
index 36249f54..47cc84e5 100644
--- a/src/Meziantou.Analyzer/Rules/NonConstantStaticFieldsShouldNotBeVisibleAnalyzer.cs
+++ b/src/Meziantou.Analyzer/Rules/NonConstantStaticFieldsShouldNotBeVisibleAnalyzer.cs
@@ -1,4 +1,5 @@
using System.Collections.Immutable;
+using Meziantou.Analyzer.Internals;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.Diagnostics;
diff --git a/src/Meziantou.Analyzer/Rules/NonFlagsEnumsShouldNotBeMarkedWithFlagsAttributeAnalyzer.cs b/src/Meziantou.Analyzer/Rules/NonFlagsEnumsShouldNotBeMarkedWithFlagsAttributeAnalyzer.cs
index 96499d77..337ba18b 100644
--- a/src/Meziantou.Analyzer/Rules/NonFlagsEnumsShouldNotBeMarkedWithFlagsAttributeAnalyzer.cs
+++ b/src/Meziantou.Analyzer/Rules/NonFlagsEnumsShouldNotBeMarkedWithFlagsAttributeAnalyzer.cs
@@ -3,6 +3,7 @@
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using Meziantou.Analyzer.Configurations;
+using Meziantou.Analyzer.Internals;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.Diagnostics;
diff --git a/src/Meziantou.Analyzer/Rules/NotPatternShouldBeParenthesizedAnalyzer.cs b/src/Meziantou.Analyzer/Rules/NotPatternShouldBeParenthesizedAnalyzer.cs
index 64268e87..ef8bafb8 100644
--- a/src/Meziantou.Analyzer/Rules/NotPatternShouldBeParenthesizedAnalyzer.cs
+++ b/src/Meziantou.Analyzer/Rules/NotPatternShouldBeParenthesizedAnalyzer.cs
@@ -45,4 +45,4 @@ private void AnalyzeNotPatternSyntax(SyntaxNodeAnalysisContext context)
}
}
}
-#endif
\ No newline at end of file
+#endif
diff --git a/src/Meziantou.Analyzer/Rules/NullableAttributeUsageAnalyzer.cs b/src/Meziantou.Analyzer/Rules/NullableAttributeUsageAnalyzer.cs
index 867fcee6..c65cfef4 100644
--- a/src/Meziantou.Analyzer/Rules/NullableAttributeUsageAnalyzer.cs
+++ b/src/Meziantou.Analyzer/Rules/NullableAttributeUsageAnalyzer.cs
@@ -1,5 +1,6 @@
using System.Collections.Immutable;
using System.Linq;
+using Meziantou.Analyzer.Internals;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.Diagnostics;
diff --git a/src/Meziantou.Analyzer/Rules/ObjectGetTypeOnTypeInstanceAnalyzer.cs b/src/Meziantou.Analyzer/Rules/ObjectGetTypeOnTypeInstanceAnalyzer.cs
index 9b5f93c8..2c5e573d 100644
--- a/src/Meziantou.Analyzer/Rules/ObjectGetTypeOnTypeInstanceAnalyzer.cs
+++ b/src/Meziantou.Analyzer/Rules/ObjectGetTypeOnTypeInstanceAnalyzer.cs
@@ -1,4 +1,5 @@
using System.Collections.Immutable;
+using Meziantou.Analyzer.Internals;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.Diagnostics;
using Microsoft.CodeAnalysis.Operations;
@@ -45,7 +46,6 @@ public override void Initialize(AnalysisContext context)
context.ReportDiagnostic(Rule, operation);
}
}
-
}, OperationKind.Invocation);
});
}
diff --git a/src/Meziantou.Analyzer/Rules/ObsoleteAttributesShouldIncludeExplanationsAnalyzer.cs b/src/Meziantou.Analyzer/Rules/ObsoleteAttributesShouldIncludeExplanationsAnalyzer.cs
index 0b84e731..f94214a7 100644
--- a/src/Meziantou.Analyzer/Rules/ObsoleteAttributesShouldIncludeExplanationsAnalyzer.cs
+++ b/src/Meziantou.Analyzer/Rules/ObsoleteAttributesShouldIncludeExplanationsAnalyzer.cs
@@ -1,4 +1,5 @@
using System.Collections.Immutable;
+using Meziantou.Analyzer.Internals;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.Diagnostics;
diff --git a/src/Meziantou.Analyzer/Rules/OptimizeLinqUsageAnalyzer.cs b/src/Meziantou.Analyzer/Rules/OptimizeLinqUsageAnalyzer.cs
index abd0ded3..5e899157 100755
--- a/src/Meziantou.Analyzer/Rules/OptimizeLinqUsageAnalyzer.cs
+++ b/src/Meziantou.Analyzer/Rules/OptimizeLinqUsageAnalyzer.cs
@@ -4,6 +4,7 @@
using System.Globalization;
using System.Linq;
using Meziantou.Analyzer.Configurations;
+using Meziantou.Analyzer.Internals;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp;
using Microsoft.CodeAnalysis.CSharp.Syntax;
diff --git a/src/Meziantou.Analyzer/Rules/OptimizeStartsWithAnalyzer.cs b/src/Meziantou.Analyzer/Rules/OptimizeStartsWithAnalyzer.cs
index bc7102bb..fbe6b2a3 100644
--- a/src/Meziantou.Analyzer/Rules/OptimizeStartsWithAnalyzer.cs
+++ b/src/Meziantou.Analyzer/Rules/OptimizeStartsWithAnalyzer.cs
@@ -1,6 +1,7 @@
using System;
using System.Collections.Immutable;
using System.Linq;
+using Meziantou.Analyzer.Internals;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.Diagnostics;
using Microsoft.CodeAnalysis.Operations;
@@ -276,7 +277,6 @@ public void AnalyzeInvocation(OperationAnalysisContext context)
if (IndexOf_Char_Int32_Int32 is null)
return;
-
if (operation.Arguments[0].Value is { Type.SpecialType: SpecialType.System_String, ConstantValue: { HasValue: true, Value: string { Length: 1 } } } &&
operation.Arguments[1].Value.Type.IsInt32() &&
operation.Arguments[2].Value.Type.IsInt32() &&
@@ -315,7 +315,6 @@ public void AnalyzeInvocation(OperationAnalysisContext context)
if (LastIndexOf_Char_Int32 is null)
return;
-
if (operation.Arguments[0].Value is { Type.SpecialType: SpecialType.System_String, ConstantValue: { HasValue: true, Value: string { Length: 1 } } } &&
operation.Arguments[1].Value.Type.IsInt32() &&
operation.Arguments[2].Value is { ConstantValue: { HasValue: true, Value: (int)StringComparison.Ordinal } })
@@ -328,7 +327,6 @@ public void AnalyzeInvocation(OperationAnalysisContext context)
if (LastIndexOf_Char_Int32_Int32 is null)
return;
-
if (operation.Arguments[0].Value is { Type.SpecialType: SpecialType.System_String, ConstantValue: { HasValue: true, Value: string { Length: 1 } } } &&
operation.Arguments[1].Value.Type.IsInt32() &&
operation.Arguments[2].Value.Type.IsInt32() &&
diff --git a/src/Meziantou.Analyzer/Rules/OptimizeStringBuilderUsageAnalyzer.cs b/src/Meziantou.Analyzer/Rules/OptimizeStringBuilderUsageAnalyzer.cs
index 91885047..704cdaf3 100644
--- a/src/Meziantou.Analyzer/Rules/OptimizeStringBuilderUsageAnalyzer.cs
+++ b/src/Meziantou.Analyzer/Rules/OptimizeStringBuilderUsageAnalyzer.cs
@@ -148,6 +148,7 @@ private bool IsOptimizable(OperationAnalysisContext context, IOperation operatio
context.ReportDiagnostic(Rule, properties, argument, $"Replace {methodName}(string) with {methodName}(char)");
return true;
}
+
return false;
}
else
diff --git a/src/Meziantou.Analyzer/Rules/OptionalParametersAttributeAnalyzer.cs b/src/Meziantou.Analyzer/Rules/OptionalParametersAttributeAnalyzer.cs
index f7cb282f..ea34682b 100644
--- a/src/Meziantou.Analyzer/Rules/OptionalParametersAttributeAnalyzer.cs
+++ b/src/Meziantou.Analyzer/Rules/OptionalParametersAttributeAnalyzer.cs
@@ -1,4 +1,5 @@
using System.Collections.Immutable;
+using Meziantou.Analyzer.Internals;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.Diagnostics;
diff --git a/src/Meziantou.Analyzer/Rules/ParameterAttributeForRazorComponentAnalyzer.cs b/src/Meziantou.Analyzer/Rules/ParameterAttributeForRazorComponentAnalyzer.cs
index 718aaffd..cbb6d2d9 100644
--- a/src/Meziantou.Analyzer/Rules/ParameterAttributeForRazorComponentAnalyzer.cs
+++ b/src/Meziantou.Analyzer/Rules/ParameterAttributeForRazorComponentAnalyzer.cs
@@ -1,5 +1,6 @@
using System;
using System.Collections.Immutable;
+using Meziantou.Analyzer.Internals;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.Diagnostics;
diff --git a/src/Meziantou.Analyzer/Rules/PreferReturningCollectionAbstractionInsteadOfImplementationAnalyzer.cs b/src/Meziantou.Analyzer/Rules/PreferReturningCollectionAbstractionInsteadOfImplementationAnalyzer.cs
index 02a2559f..5b55340c 100644
--- a/src/Meziantou.Analyzer/Rules/PreferReturningCollectionAbstractionInsteadOfImplementationAnalyzer.cs
+++ b/src/Meziantou.Analyzer/Rules/PreferReturningCollectionAbstractionInsteadOfImplementationAnalyzer.cs
@@ -1,5 +1,6 @@
using System.Collections.Generic;
using System.Collections.Immutable;
+using Meziantou.Analyzer.Internals;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.Diagnostics;
diff --git a/src/Meziantou.Analyzer/Rules/PreserveParamsOnOverrideAnalyzer.cs b/src/Meziantou.Analyzer/Rules/PreserveParamsOnOverrideAnalyzer.cs
index 52624fcc..97a8626b 100644
--- a/src/Meziantou.Analyzer/Rules/PreserveParamsOnOverrideAnalyzer.cs
+++ b/src/Meziantou.Analyzer/Rules/PreserveParamsOnOverrideAnalyzer.cs
@@ -1,6 +1,7 @@
using System.Collections.Immutable;
using System.Linq;
using System.Threading;
+using Meziantou.Analyzer.Internals;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Microsoft.CodeAnalysis.Diagnostics;
diff --git a/src/Meziantou.Analyzer/Rules/PrimaryConstructorParameterShouldBeReadOnlyAnalyzer.cs b/src/Meziantou.Analyzer/Rules/PrimaryConstructorParameterShouldBeReadOnlyAnalyzer.cs
index decee458..2f9e203c 100644
--- a/src/Meziantou.Analyzer/Rules/PrimaryConstructorParameterShouldBeReadOnlyAnalyzer.cs
+++ b/src/Meziantou.Analyzer/Rules/PrimaryConstructorParameterShouldBeReadOnlyAnalyzer.cs
@@ -3,6 +3,7 @@
using System.Collections.Immutable;
using System.Linq;
using System.Threading;
+using Meziantou.Analyzer.Internals;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Microsoft.CodeAnalysis.Diagnostics;
diff --git a/src/Meziantou.Analyzer/Rules/ProcessStartAnalyzer.cs b/src/Meziantou.Analyzer/Rules/ProcessStartAnalyzer.cs
index 11e6ae25..7e7004f5 100644
--- a/src/Meziantou.Analyzer/Rules/ProcessStartAnalyzer.cs
+++ b/src/Meziantou.Analyzer/Rules/ProcessStartAnalyzer.cs
@@ -1,5 +1,6 @@
using System.Collections.Immutable;
using System.Linq;
+using Meziantou.Analyzer.Internals;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Microsoft.CodeAnalysis.Diagnostics;
diff --git a/src/Meziantou.Analyzer/Rules/RegexUsageAnalyzerBase.cs b/src/Meziantou.Analyzer/Rules/RegexUsageAnalyzerBase.cs
index e489cf96..82d116da 100644
--- a/src/Meziantou.Analyzer/Rules/RegexUsageAnalyzerBase.cs
+++ b/src/Meziantou.Analyzer/Rules/RegexUsageAnalyzerBase.cs
@@ -2,6 +2,7 @@
using System.Collections.Immutable;
using System.Linq;
using System.Text.RegularExpressions;
+using Meziantou.Analyzer.Internals;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.Diagnostics;
using Microsoft.CodeAnalysis.Operations;
@@ -167,7 +168,6 @@ private static RegexOptions CheckRegexOptionsArgument(OperationAnalysisContext c
if (regexOptionsSymbol is null)
return (null, null);
-
var arg = arguments.FirstOrDefault(a => a.Parameter is not null && a.Parameter.Type.IsEqualTo(regexOptionsSymbol));
if (arg is null || arg.Value is null || !arg.Value.ConstantValue.HasValue)
return (null, arg);
diff --git a/src/Meziantou.Analyzer/Rules/RemoveEmptyBlockAnalyzer.cs b/src/Meziantou.Analyzer/Rules/RemoveEmptyBlockAnalyzer.cs
index 0e83d7de..4ce5f33e 100644
--- a/src/Meziantou.Analyzer/Rules/RemoveEmptyBlockAnalyzer.cs
+++ b/src/Meziantou.Analyzer/Rules/RemoveEmptyBlockAnalyzer.cs
@@ -1,5 +1,6 @@
using System.Collections.Immutable;
using System.Linq;
+using Meziantou.Analyzer.Internals;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp;
using Microsoft.CodeAnalysis.CSharp.Syntax;
diff --git a/src/Meziantou.Analyzer/Rules/RemoveEmptyStatementAnalyzer.cs b/src/Meziantou.Analyzer/Rules/RemoveEmptyStatementAnalyzer.cs
index 3fc4d85f..ffaa6508 100644
--- a/src/Meziantou.Analyzer/Rules/RemoveEmptyStatementAnalyzer.cs
+++ b/src/Meziantou.Analyzer/Rules/RemoveEmptyStatementAnalyzer.cs
@@ -1,4 +1,5 @@
using System.Collections.Immutable;
+using Meziantou.Analyzer.Internals;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp;
using Microsoft.CodeAnalysis.CSharp.Syntax;
diff --git a/src/Meziantou.Analyzer/Rules/RemoveUselessToStringAnalyzer.cs b/src/Meziantou.Analyzer/Rules/RemoveUselessToStringAnalyzer.cs
index 3b0d2076..1158626e 100644
--- a/src/Meziantou.Analyzer/Rules/RemoveUselessToStringAnalyzer.cs
+++ b/src/Meziantou.Analyzer/Rules/RemoveUselessToStringAnalyzer.cs
@@ -1,5 +1,6 @@
using System;
using System.Collections.Immutable;
+using Meziantou.Analyzer.Internals;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.Diagnostics;
using Microsoft.CodeAnalysis.Operations;
diff --git a/src/Meziantou.Analyzer/Rules/ReplaceEnumToStringWithNameofAnalyzer.cs b/src/Meziantou.Analyzer/Rules/ReplaceEnumToStringWithNameofAnalyzer.cs
index 41652912..129c7390 100644
--- a/src/Meziantou.Analyzer/Rules/ReplaceEnumToStringWithNameofAnalyzer.cs
+++ b/src/Meziantou.Analyzer/Rules/ReplaceEnumToStringWithNameofAnalyzer.cs
@@ -1,4 +1,5 @@
using System.Collections.Immutable;
+using Meziantou.Analyzer.Internals;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.Diagnostics;
using Microsoft.CodeAnalysis.Operations;
@@ -83,7 +84,6 @@ private static void AnalyzeInterpolation(OperationAnalysisContext context)
context.ReportDiagnostic(Rule, operation);
}
-
private static bool IsNameFormat(object? format)
{
if (format is null)
diff --git a/src/Meziantou.Analyzer/Rules/ReturnTaskFromResultInsteadOfReturningNullAnalyzer.cs b/src/Meziantou.Analyzer/Rules/ReturnTaskFromResultInsteadOfReturningNullAnalyzer.cs
index c2c74655..da33d4c7 100644
--- a/src/Meziantou.Analyzer/Rules/ReturnTaskFromResultInsteadOfReturningNullAnalyzer.cs
+++ b/src/Meziantou.Analyzer/Rules/ReturnTaskFromResultInsteadOfReturningNullAnalyzer.cs
@@ -1,5 +1,6 @@
using System.Collections.Immutable;
using System.Diagnostics.CodeAnalysis;
+using Meziantou.Analyzer.Internals;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.Diagnostics;
using Microsoft.CodeAnalysis.Operations;
diff --git a/src/Meziantou.Analyzer/Rules/SequenceNumberMustBeAConstantAnalyzer.cs b/src/Meziantou.Analyzer/Rules/SequenceNumberMustBeAConstantAnalyzer.cs
index 4d5c7006..15661573 100644
--- a/src/Meziantou.Analyzer/Rules/SequenceNumberMustBeAConstantAnalyzer.cs
+++ b/src/Meziantou.Analyzer/Rules/SequenceNumberMustBeAConstantAnalyzer.cs
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Collections.Immutable;
+using Meziantou.Analyzer.Internals;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.Diagnostics;
using Microsoft.CodeAnalysis.Operations;
diff --git a/src/Meziantou.Analyzer/Rules/SimplifyCallerArgumentExpressionAnalyzer.cs b/src/Meziantou.Analyzer/Rules/SimplifyCallerArgumentExpressionAnalyzer.cs
index da5a741b..0a0900fd 100644
--- a/src/Meziantou.Analyzer/Rules/SimplifyCallerArgumentExpressionAnalyzer.cs
+++ b/src/Meziantou.Analyzer/Rules/SimplifyCallerArgumentExpressionAnalyzer.cs
@@ -1,5 +1,6 @@
using System.Collections.Immutable;
using System.Linq;
+using Meziantou.Analyzer.Internals;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.Diagnostics;
using Microsoft.CodeAnalysis.Operations;
diff --git a/src/Meziantou.Analyzer/Rules/StringShouldNotContainsNonDeterministicEndOfLineAnalyzer.cs b/src/Meziantou.Analyzer/Rules/StringShouldNotContainsNonDeterministicEndOfLineAnalyzer.cs
index b76a9772..64c6a17d 100644
--- a/src/Meziantou.Analyzer/Rules/StringShouldNotContainsNonDeterministicEndOfLineAnalyzer.cs
+++ b/src/Meziantou.Analyzer/Rules/StringShouldNotContainsNonDeterministicEndOfLineAnalyzer.cs
@@ -1,4 +1,5 @@
using System.Collections.Immutable;
+using Meziantou.Analyzer.Internals;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp;
using Microsoft.CodeAnalysis.CSharp.Syntax;
diff --git a/src/Meziantou.Analyzer/Rules/TaskInUsingAnalyzer.cs b/src/Meziantou.Analyzer/Rules/TaskInUsingAnalyzer.cs
index 689706d1..3d100e1d 100644
--- a/src/Meziantou.Analyzer/Rules/TaskInUsingAnalyzer.cs
+++ b/src/Meziantou.Analyzer/Rules/TaskInUsingAnalyzer.cs
@@ -1,4 +1,5 @@
using System.Collections.Immutable;
+using Meziantou.Analyzer.Internals;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.Diagnostics;
using Microsoft.CodeAnalysis.Operations;
@@ -72,6 +73,7 @@ private void AnalyzeResource(OperationAnalysisContext context, IOperation? opera
{
AnalyzeResource(context, declarator.Initializer?.Value);
}
+
return;
}
diff --git a/src/Meziantou.Analyzer/Rules/ThrowIfNullWithNonNullableInstanceAnalyzer.cs b/src/Meziantou.Analyzer/Rules/ThrowIfNullWithNonNullableInstanceAnalyzer.cs
index 0a7a44c4..c5c46c6e 100644
--- a/src/Meziantou.Analyzer/Rules/ThrowIfNullWithNonNullableInstanceAnalyzer.cs
+++ b/src/Meziantou.Analyzer/Rules/ThrowIfNullWithNonNullableInstanceAnalyzer.cs
@@ -1,5 +1,6 @@
using System.Collections.Generic;
using System.Collections.Immutable;
+using Meziantou.Analyzer.Internals;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.Diagnostics;
using Microsoft.CodeAnalysis.Operations;
diff --git a/src/Meziantou.Analyzer/Rules/TypeNameMustNotMatchNamespaceAnalyzer.cs b/src/Meziantou.Analyzer/Rules/TypeNameMustNotMatchNamespaceAnalyzer.cs
index 9e1ed763..65d66580 100644
--- a/src/Meziantou.Analyzer/Rules/TypeNameMustNotMatchNamespaceAnalyzer.cs
+++ b/src/Meziantou.Analyzer/Rules/TypeNameMustNotMatchNamespaceAnalyzer.cs
@@ -1,5 +1,6 @@
using System;
using System.Collections.Immutable;
+using Meziantou.Analyzer.Internals;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.Diagnostics;
diff --git a/src/Meziantou.Analyzer/Rules/TypesShouldNotExtendSystemApplicationExceptionAnalyzer.cs b/src/Meziantou.Analyzer/Rules/TypesShouldNotExtendSystemApplicationExceptionAnalyzer.cs
index 3a5165f6..4f5bfaf2 100644
--- a/src/Meziantou.Analyzer/Rules/TypesShouldNotExtendSystemApplicationExceptionAnalyzer.cs
+++ b/src/Meziantou.Analyzer/Rules/TypesShouldNotExtendSystemApplicationExceptionAnalyzer.cs
@@ -1,4 +1,5 @@
using System.Collections.Immutable;
+using Meziantou.Analyzer.Internals;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.Diagnostics;
diff --git a/src/Meziantou.Analyzer/Rules/UseAnOverloadThatHasCancellationTokenAnalyzer.cs b/src/Meziantou.Analyzer/Rules/UseAnOverloadThatHasCancellationTokenAnalyzer.cs
index 807c8715..f1892f50 100644
--- a/src/Meziantou.Analyzer/Rules/UseAnOverloadThatHasCancellationTokenAnalyzer.cs
+++ b/src/Meziantou.Analyzer/Rules/UseAnOverloadThatHasCancellationTokenAnalyzer.cs
@@ -131,7 +131,6 @@ private bool HasAnOverloadWithCancellationToken(IInvocationOperation operation,
return true;
}
-
return false;
bool IsArgumentImplicitlyDeclared(IInvocationOperation invocationOperation, INamedTypeSymbol cancellationTokenSymbol, [NotNullWhen(true)] out AdditionalParameterInfo? parameterInfo)
@@ -301,6 +300,7 @@ public void AnalyzeLoop(OperationAnalysisContext context)
}
}
}
+
return result;
});
}
diff --git a/src/Meziantou.Analyzer/Rules/UseArrayEmptyAnalyzer.cs b/src/Meziantou.Analyzer/Rules/UseArrayEmptyAnalyzer.cs
index 83c1794b..3f4390f1 100644
--- a/src/Meziantou.Analyzer/Rules/UseArrayEmptyAnalyzer.cs
+++ b/src/Meziantou.Analyzer/Rules/UseArrayEmptyAnalyzer.cs
@@ -1,5 +1,6 @@
using System.Collections.Immutable;
using System.Linq;
+using Meziantou.Analyzer.Internals;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Microsoft.CodeAnalysis.Diagnostics;
diff --git a/src/Meziantou.Analyzer/Rules/UseConfigureAwaitAnalyzer.cs b/src/Meziantou.Analyzer/Rules/UseConfigureAwaitAnalyzer.cs
index 0e3dd9f3..500c07b1 100644
--- a/src/Meziantou.Analyzer/Rules/UseConfigureAwaitAnalyzer.cs
+++ b/src/Meziantou.Analyzer/Rules/UseConfigureAwaitAnalyzer.cs
@@ -3,6 +3,7 @@
using System.Linq;
using System.Threading;
using Meziantou.Analyzer.Configurations;
+using Meziantou.Analyzer.Internals;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp;
using Microsoft.CodeAnalysis.CSharp.Syntax;
diff --git a/src/Meziantou.Analyzer/Rules/UseContainsKeyInsteadOfTryGetValueAnalyzer.cs b/src/Meziantou.Analyzer/Rules/UseContainsKeyInsteadOfTryGetValueAnalyzer.cs
index 2b3606d1..7ba4d8ac 100644
--- a/src/Meziantou.Analyzer/Rules/UseContainsKeyInsteadOfTryGetValueAnalyzer.cs
+++ b/src/Meziantou.Analyzer/Rules/UseContainsKeyInsteadOfTryGetValueAnalyzer.cs
@@ -1,6 +1,7 @@
using System;
using System.Collections.Immutable;
using System.Linq;
+using Meziantou.Analyzer.Internals;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.Diagnostics;
using Microsoft.CodeAnalysis.Operations;
diff --git a/src/Meziantou.Analyzer/Rules/UseEventArgsEmptyAnalyzer.cs b/src/Meziantou.Analyzer/Rules/UseEventArgsEmptyAnalyzer.cs
index af1f9dc4..a917e74d 100644
--- a/src/Meziantou.Analyzer/Rules/UseEventArgsEmptyAnalyzer.cs
+++ b/src/Meziantou.Analyzer/Rules/UseEventArgsEmptyAnalyzer.cs
@@ -1,4 +1,5 @@
using System.Collections.Immutable;
+using Meziantou.Analyzer.Internals;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.Diagnostics;
using Microsoft.CodeAnalysis.Operations;
diff --git a/src/Meziantou.Analyzer/Rules/UseEventHandlerOfTAnalyzer.cs b/src/Meziantou.Analyzer/Rules/UseEventHandlerOfTAnalyzer.cs
index 73b3df6f..01c9c59c 100644
--- a/src/Meziantou.Analyzer/Rules/UseEventHandlerOfTAnalyzer.cs
+++ b/src/Meziantou.Analyzer/Rules/UseEventHandlerOfTAnalyzer.cs
@@ -1,5 +1,6 @@
using System.Collections.Immutable;
using System.Diagnostics.CodeAnalysis;
+using Meziantou.Analyzer.Internals;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.Diagnostics;
diff --git a/src/Meziantou.Analyzer/Rules/UseGuidEmptyAnalyzer.cs b/src/Meziantou.Analyzer/Rules/UseGuidEmptyAnalyzer.cs
index e2a3f550..dfd16568 100644
--- a/src/Meziantou.Analyzer/Rules/UseGuidEmptyAnalyzer.cs
+++ b/src/Meziantou.Analyzer/Rules/UseGuidEmptyAnalyzer.cs
@@ -1,4 +1,5 @@
using System.Collections.Immutable;
+using Meziantou.Analyzer.Internals;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.Diagnostics;
using Microsoft.CodeAnalysis.Operations;
diff --git a/src/Meziantou.Analyzer/Rules/UseIsPatternInsteadOfSequenceEqualAnalyzer.cs b/src/Meziantou.Analyzer/Rules/UseIsPatternInsteadOfSequenceEqualAnalyzer.cs
index 8c00549b..98869c11 100644
--- a/src/Meziantou.Analyzer/Rules/UseIsPatternInsteadOfSequenceEqualAnalyzer.cs
+++ b/src/Meziantou.Analyzer/Rules/UseIsPatternInsteadOfSequenceEqualAnalyzer.cs
@@ -4,6 +4,7 @@
using Microsoft.CodeAnalysis.Operations;
using System.Linq;
using System;
+using Meziantou.Analyzer.Internals;
namespace Meziantou.Analyzer.Rules;
diff --git a/src/Meziantou.Analyzer/Rules/UseJSRuntimeInvokeVoidAsyncWhenReturnValueIsNotUsedAnalyzer.cs b/src/Meziantou.Analyzer/Rules/UseJSRuntimeInvokeVoidAsyncWhenReturnValueIsNotUsedAnalyzer.cs
index 87773a0f..4429aad5 100644
--- a/src/Meziantou.Analyzer/Rules/UseJSRuntimeInvokeVoidAsyncWhenReturnValueIsNotUsedAnalyzer.cs
+++ b/src/Meziantou.Analyzer/Rules/UseJSRuntimeInvokeVoidAsyncWhenReturnValueIsNotUsedAnalyzer.cs
@@ -1,4 +1,5 @@
using System.Collections.Immutable;
+using Meziantou.Analyzer.Internals;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.Diagnostics;
using Microsoft.CodeAnalysis.Operations;
diff --git a/src/Meziantou.Analyzer/Rules/UseOperatingSystemInsteadOfRuntimeInformationAnalyzer.cs b/src/Meziantou.Analyzer/Rules/UseOperatingSystemInsteadOfRuntimeInformationAnalyzer.cs
index db388a7f..ea9aad65 100644
--- a/src/Meziantou.Analyzer/Rules/UseOperatingSystemInsteadOfRuntimeInformationAnalyzer.cs
+++ b/src/Meziantou.Analyzer/Rules/UseOperatingSystemInsteadOfRuntimeInformationAnalyzer.cs
@@ -1,4 +1,5 @@
using System.Collections.Immutable;
+using Meziantou.Analyzer.Internals;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.Diagnostics;
using Microsoft.CodeAnalysis.Operations;
diff --git a/src/Meziantou.Analyzer/Rules/UsePatternMatchingForEqualityComparisonsAnalyzer.cs b/src/Meziantou.Analyzer/Rules/UsePatternMatchingForEqualityComparisonsAnalyzer.cs
index c9e92de7..a79e4f4e 100644
--- a/src/Meziantou.Analyzer/Rules/UsePatternMatchingForEqualityComparisonsAnalyzer.cs
+++ b/src/Meziantou.Analyzer/Rules/UsePatternMatchingForEqualityComparisonsAnalyzer.cs
@@ -1,5 +1,6 @@
using System.Collections.Immutable;
using System.Linq;
+using Meziantou.Analyzer.Internals;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.Diagnostics;
using Microsoft.CodeAnalysis.Operations;
@@ -103,5 +104,4 @@ public void AnalyzeBinary(OperationAnalysisContext context)
}
}
}
-
}
diff --git a/src/Meziantou.Analyzer/Rules/UsePatternMatchingForEqualityComparisonsCommon.cs b/src/Meziantou.Analyzer/Rules/UsePatternMatchingForEqualityComparisonsCommon.cs
index 91231e1b..45d8ccdc 100644
--- a/src/Meziantou.Analyzer/Rules/UsePatternMatchingForEqualityComparisonsCommon.cs
+++ b/src/Meziantou.Analyzer/Rules/UsePatternMatchingForEqualityComparisonsCommon.cs
@@ -1,5 +1,6 @@
using Microsoft.CodeAnalysis.Operations;
using Microsoft.CodeAnalysis;
+using Meziantou.Analyzer.Internals;
namespace Meziantou.Analyzer.Rules;
internal static class UsePatternMatchingForEqualityComparisonsCommon
diff --git a/src/Meziantou.Analyzer/Rules/UseRegexSourceGeneratorAnalyzer.cs b/src/Meziantou.Analyzer/Rules/UseRegexSourceGeneratorAnalyzer.cs
index 8c00eeea..aa414a83 100644
--- a/src/Meziantou.Analyzer/Rules/UseRegexSourceGeneratorAnalyzer.cs
+++ b/src/Meziantou.Analyzer/Rules/UseRegexSourceGeneratorAnalyzer.cs
@@ -65,13 +65,13 @@ private static void AnalyzeObjectCreation(OperationAnalysisContext context)
return;
}
- var properties = ImmutableDictionary.CreateRange(new[]
- {
+ var properties = ImmutableDictionary.CreateRange(
+ [
new KeyValuePair(UseRegexSourceGeneratorAnalyzerCommon.PatternIndexName, "0"),
new KeyValuePair(UseRegexSourceGeneratorAnalyzerCommon.RegexOptionsIndexName, op.Arguments.Length > 1 ? "1" : null),
new KeyValuePair(UseRegexSourceGeneratorAnalyzerCommon.RegexTimeoutIndexName, op.Arguments.Length > 2 ? "2" : null),
new KeyValuePair(UseRegexSourceGeneratorAnalyzerCommon.RegexTimeoutName, op.Arguments.Length > 2 ? TimeSpanOperation.GetMilliseconds(op.Arguments[2].Value)?.ToString(CultureInfo.InvariantCulture) : null),
- });
+ ]);
context.ReportDiagnostic(RegexSourceGeneratorRule, properties, op);
}
@@ -110,13 +110,13 @@ private static void AnalyzeInvocation(OperationAnalysisContext context)
return;
}
- var properties = ImmutableDictionary.CreateRange(new[]
- {
+ var properties = ImmutableDictionary.CreateRange(
+ [
new KeyValuePair(UseRegexSourceGeneratorAnalyzerCommon.PatternIndexName, "1"),
new KeyValuePair(UseRegexSourceGeneratorAnalyzerCommon.RegexOptionsIndexName, op.Arguments.Length > 2 ? "2" : null),
new KeyValuePair(UseRegexSourceGeneratorAnalyzerCommon.RegexTimeoutIndexName, op.Arguments.Length > 3 ? "3" : null),
new KeyValuePair(UseRegexSourceGeneratorAnalyzerCommon.RegexTimeoutName, op.Arguments.Length > 3 ? TimeSpanOperation.GetMilliseconds(op.Arguments[3].Value)?.ToString(CultureInfo.InvariantCulture) : null),
- });
+ ]);
context.ReportDiagnostic(RegexSourceGeneratorRule, properties, op);
}
@@ -138,13 +138,13 @@ private static void AnalyzeInvocation(OperationAnalysisContext context)
return;
}
- var properties = ImmutableDictionary.CreateRange(new[]
- {
+ var properties = ImmutableDictionary.CreateRange(
+ [
new KeyValuePair(UseRegexSourceGeneratorAnalyzerCommon.PatternIndexName, "1"),
new KeyValuePair(UseRegexSourceGeneratorAnalyzerCommon.RegexOptionsIndexName, op.Arguments.Length > 3 ? "3" : null),
new KeyValuePair(UseRegexSourceGeneratorAnalyzerCommon.RegexTimeoutIndexName, op.Arguments.Length > 4 ? "4" : null),
new KeyValuePair(UseRegexSourceGeneratorAnalyzerCommon.RegexTimeoutName, op.Arguments.Length > 4 ? TimeSpanOperation.GetMilliseconds(op.Arguments[4].Value)?.ToString(CultureInfo.InvariantCulture) : null),
- });
+ ]);
context.ReportDiagnostic(RegexSourceGeneratorRule, properties, op);
}
diff --git a/src/Meziantou.Analyzer/Rules/UseStringCreateInsteadOfFormattableStringAnalyzer.cs b/src/Meziantou.Analyzer/Rules/UseStringCreateInsteadOfFormattableStringAnalyzer.cs
index 86dbcfdb..7d411030 100644
--- a/src/Meziantou.Analyzer/Rules/UseStringCreateInsteadOfFormattableStringAnalyzer.cs
+++ b/src/Meziantou.Analyzer/Rules/UseStringCreateInsteadOfFormattableStringAnalyzer.cs
@@ -1,5 +1,6 @@
using System.Collections.Immutable;
using System.Linq;
+using Meziantou.Analyzer.Internals;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.Diagnostics;
using Microsoft.CodeAnalysis.Operations;
diff --git a/src/Meziantou.Analyzer/Rules/UseStringEqualsAnalyzer.cs b/src/Meziantou.Analyzer/Rules/UseStringEqualsAnalyzer.cs
index b545a76d..f6ee18ee 100644
--- a/src/Meziantou.Analyzer/Rules/UseStringEqualsAnalyzer.cs
+++ b/src/Meziantou.Analyzer/Rules/UseStringEqualsAnalyzer.cs
@@ -1,4 +1,5 @@
using System.Collections.Immutable;
+using Meziantou.Analyzer.Internals;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.Diagnostics;
using Microsoft.CodeAnalysis.Operations;
diff --git a/src/Meziantou.Analyzer/Rules/UseStringEqualsInsteadOfIsPatternAnalyzer.cs b/src/Meziantou.Analyzer/Rules/UseStringEqualsInsteadOfIsPatternAnalyzer.cs
index 239b5c8a..e64e5f5d 100644
--- a/src/Meziantou.Analyzer/Rules/UseStringEqualsInsteadOfIsPatternAnalyzer.cs
+++ b/src/Meziantou.Analyzer/Rules/UseStringEqualsInsteadOfIsPatternAnalyzer.cs
@@ -1,4 +1,5 @@
using System.Collections.Immutable;
+using Meziantou.Analyzer.Internals;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.Diagnostics;
using Microsoft.CodeAnalysis.Operations;
diff --git a/src/Meziantou.Analyzer/Rules/UseStructLayoutAttributeAnalyzer.cs b/src/Meziantou.Analyzer/Rules/UseStructLayoutAttributeAnalyzer.cs
index 764934d5..67a128f1 100644
--- a/src/Meziantou.Analyzer/Rules/UseStructLayoutAttributeAnalyzer.cs
+++ b/src/Meziantou.Analyzer/Rules/UseStructLayoutAttributeAnalyzer.cs
@@ -1,5 +1,6 @@
using System.Collections.Immutable;
using System.Linq;
+using Meziantou.Analyzer.Internals;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.Diagnostics;
diff --git a/src/Meziantou.Analyzer/Rules/UseSystemThreadingLockInsteadOfObjectAnalyzer.cs b/src/Meziantou.Analyzer/Rules/UseSystemThreadingLockInsteadOfObjectAnalyzer.cs
index 746959b1..3afab307 100644
--- a/src/Meziantou.Analyzer/Rules/UseSystemThreadingLockInsteadOfObjectAnalyzer.cs
+++ b/src/Meziantou.Analyzer/Rules/UseSystemThreadingLockInsteadOfObjectAnalyzer.cs
@@ -1,5 +1,6 @@
using System.Collections.Concurrent;
using System.Collections.Immutable;
+using Meziantou.Analyzer.Internals;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Microsoft.CodeAnalysis.Diagnostics;
diff --git a/src/Meziantou.Analyzer/Rules/UseTaskUnwrapAnalyzer.cs b/src/Meziantou.Analyzer/Rules/UseTaskUnwrapAnalyzer.cs
index e6765b87..038da740 100644
--- a/src/Meziantou.Analyzer/Rules/UseTaskUnwrapAnalyzer.cs
+++ b/src/Meziantou.Analyzer/Rules/UseTaskUnwrapAnalyzer.cs
@@ -1,4 +1,5 @@
using System.Collections.Immutable;
+using Meziantou.Analyzer.Internals;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.Diagnostics;
using Microsoft.CodeAnalysis.Operations;
diff --git a/src/Meziantou.Analyzer/Rules/ValidateArgumentsCorrectlyAnalyzer.cs b/src/Meziantou.Analyzer/Rules/ValidateArgumentsCorrectlyAnalyzer.cs
index 66088726..21b5187b 100755
--- a/src/Meziantou.Analyzer/Rules/ValidateArgumentsCorrectlyAnalyzer.cs
+++ b/src/Meziantou.Analyzer/Rules/ValidateArgumentsCorrectlyAnalyzer.cs
@@ -2,6 +2,7 @@
using System.Collections.Immutable;
using System.Globalization;
using System.Linq;
+using Meziantou.Analyzer.Internals;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp;
using Microsoft.CodeAnalysis.CSharp.Syntax;
diff --git a/src/Meziantou.Analyzer/Rules/ValidateUnsafeAccessorAttributeUsageAnalyzer.cs b/src/Meziantou.Analyzer/Rules/ValidateUnsafeAccessorAttributeUsageAnalyzer.cs
index f04fd330..25ecc365 100644
--- a/src/Meziantou.Analyzer/Rules/ValidateUnsafeAccessorAttributeUsageAnalyzer.cs
+++ b/src/Meziantou.Analyzer/Rules/ValidateUnsafeAccessorAttributeUsageAnalyzer.cs
@@ -1,4 +1,5 @@
using System.Collections.Immutable;
+using Meziantou.Analyzer.Internals;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.Diagnostics;
using Microsoft.CodeAnalysis.Operations;
diff --git a/src/Meziantou.Analyzer/Rules/ValueReturnedByStreamReadShouldBeUsedAnalyzer.cs b/src/Meziantou.Analyzer/Rules/ValueReturnedByStreamReadShouldBeUsedAnalyzer.cs
index 0f761df1..1c2a1ac1 100644
--- a/src/Meziantou.Analyzer/Rules/ValueReturnedByStreamReadShouldBeUsedAnalyzer.cs
+++ b/src/Meziantou.Analyzer/Rules/ValueReturnedByStreamReadShouldBeUsedAnalyzer.cs
@@ -1,5 +1,6 @@
using System.Collections.Immutable;
using System.IO;
+using Meziantou.Analyzer.Internals;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.Diagnostics;
using Microsoft.CodeAnalysis.Operations;
diff --git a/src/Meziantou.Analyzer/Suppressors/IDE0058Suppressor.cs b/src/Meziantou.Analyzer/Suppressors/IDE0058Suppressor.cs
index 2fec37d7..dfbee9bd 100644
--- a/src/Meziantou.Analyzer/Suppressors/IDE0058Suppressor.cs
+++ b/src/Meziantou.Analyzer/Suppressors/IDE0058Suppressor.cs
@@ -1,4 +1,5 @@
using System.Collections.Immutable;
+using Meziantou.Analyzer.Internals;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.Diagnostics;
using Microsoft.CodeAnalysis.Operations;
diff --git a/tests/Meziantou.Analyzer.Test/Helpers/DiagnosticResult.cs b/tests/Meziantou.Analyzer.Test/Helpers/DiagnosticResult.cs
index b7c7b961..7a29fd29 100755
--- a/tests/Meziantou.Analyzer.Test/Helpers/DiagnosticResult.cs
+++ b/tests/Meziantou.Analyzer.Test/Helpers/DiagnosticResult.cs
@@ -1,8 +1,7 @@
-using System;
-using System.Collections.Generic;
+using System.Collections.Generic;
using Microsoft.CodeAnalysis;
-namespace TestHelper;
+namespace Meziantou.Analyzer.Test.Helpers;
public sealed class DiagnosticResult
{
diff --git a/tests/Meziantou.Analyzer.Test/Helpers/DiagnosticResultLocation.cs b/tests/Meziantou.Analyzer.Test/Helpers/DiagnosticResultLocation.cs
index 65315dcd..e1b6bd66 100644
--- a/tests/Meziantou.Analyzer.Test/Helpers/DiagnosticResultLocation.cs
+++ b/tests/Meziantou.Analyzer.Test/Helpers/DiagnosticResultLocation.cs
@@ -1,7 +1,7 @@
using System;
using System.Runtime.InteropServices;
-namespace TestHelper;
+namespace Meziantou.Analyzer.Test.Helpers;
///
/// Location where the diagnostic appears, as determined by path, line number, and column number.
@@ -12,14 +12,10 @@ public readonly struct DiagnosticResultLocation
public DiagnosticResultLocation(string path, int lineStart, int columnStart, int lineEnd, int columnEnd)
{
if (lineStart < -1)
- {
throw new ArgumentOutOfRangeException(nameof(lineStart), "line must be >= -1");
- }
if (columnStart < -1)
- {
throw new ArgumentOutOfRangeException(nameof(columnStart), "column must be >= -1");
- }
Path = path;
LineStart = lineStart;
diff --git a/tests/Meziantou.Analyzer.Test/Helpers/ProjectBuilder.Validation.cs b/tests/Meziantou.Analyzer.Test/Helpers/ProjectBuilder.Validation.cs
index 967be2f1..fd8ecd7e 100755
--- a/tests/Meziantou.Analyzer.Test/Helpers/ProjectBuilder.Validation.cs
+++ b/tests/Meziantou.Analyzer.Test/Helpers/ProjectBuilder.Validation.cs
@@ -399,6 +399,7 @@ private static string FormatDiagnostics(IList analyzers, par
}
}
}
+
return builder.ToString();
}
diff --git a/tests/Meziantou.Analyzer.Test/Helpers/TargetFramework.cs b/tests/Meziantou.Analyzer.Test/Helpers/TargetFramework.cs
index d65c7004..828bc473 100644
--- a/tests/Meziantou.Analyzer.Test/Helpers/TargetFramework.cs
+++ b/tests/Meziantou.Analyzer.Test/Helpers/TargetFramework.cs
@@ -1,4 +1,4 @@
-namespace TestHelper;
+namespace Meziantou.Analyzer.Test.Helpers;
[System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1027:Mark enums with FlagsAttribute")]
public enum TargetFramework
diff --git a/tests/Meziantou.Analyzer.Test/Meziantou.Analyzer.Test.csproj b/tests/Meziantou.Analyzer.Test/Meziantou.Analyzer.Test.csproj
index 8b305430..f27d0d85 100644
--- a/tests/Meziantou.Analyzer.Test/Meziantou.Analyzer.Test.csproj
+++ b/tests/Meziantou.Analyzer.Test/Meziantou.Analyzer.Test.csproj
@@ -1,7 +1,7 @@
- net8.0
+ net9.0
$(TargetFrameworks);net462
false
true
@@ -17,9 +17,9 @@
runtime; build; native; contentfiles; analyzers; buildtransitive
-
-
-
+
+
+
all
runtime; build; native; contentfiles; analyzers; buildtransitive
diff --git a/tests/Meziantou.Analyzer.Test/Rules/AddOverloadWithSpanOrMemoryAnalyzerTests.cs b/tests/Meziantou.Analyzer.Test/Rules/AddOverloadWithSpanOrMemoryAnalyzerTests.cs
index 8ff4ca7a..da5de3b8 100755
--- a/tests/Meziantou.Analyzer.Test/Rules/AddOverloadWithSpanOrMemoryAnalyzerTests.cs
+++ b/tests/Meziantou.Analyzer.Test/Rules/AddOverloadWithSpanOrMemoryAnalyzerTests.cs
@@ -1,5 +1,6 @@
using System.Threading.Tasks;
using Meziantou.Analyzer.Rules;
+using Meziantou.Analyzer.Test.Helpers;
using TestHelper;
using Xunit;
diff --git a/tests/Meziantou.Analyzer.Test/Rules/AttributeNameShouldEndWithAttributeAnalyzerTests.cs b/tests/Meziantou.Analyzer.Test/Rules/AttributeNameShouldEndWithAttributeAnalyzerTests.cs
index 5e2bdb5c..df2ba3bf 100644
--- a/tests/Meziantou.Analyzer.Test/Rules/AttributeNameShouldEndWithAttributeAnalyzerTests.cs
+++ b/tests/Meziantou.Analyzer.Test/Rules/AttributeNameShouldEndWithAttributeAnalyzerTests.cs
@@ -38,5 +38,4 @@ await CreateProjectBuilder()
.WithSourceCode(SourceCode)
.ValidateAsync();
}
-
}
diff --git a/tests/Meziantou.Analyzer.Test/Rules/AwaitTaskBeforeDisposingResourcesAnalyzerTests.cs b/tests/Meziantou.Analyzer.Test/Rules/AwaitTaskBeforeDisposingResourcesAnalyzerTests.cs
index 09b1bf0e..3450721a 100755
--- a/tests/Meziantou.Analyzer.Test/Rules/AwaitTaskBeforeDisposingResourcesAnalyzerTests.cs
+++ b/tests/Meziantou.Analyzer.Test/Rules/AwaitTaskBeforeDisposingResourcesAnalyzerTests.cs
@@ -1,5 +1,6 @@
using System.Threading.Tasks;
using Meziantou.Analyzer.Rules;
+using Meziantou.Analyzer.Test.Helpers;
using TestHelper;
using Xunit;
diff --git a/tests/Meziantou.Analyzer.Test/Rules/CommaAnalyzerTests.cs b/tests/Meziantou.Analyzer.Test/Rules/CommaAnalyzerTests.cs
index b45c5671..046e34c5 100644
--- a/tests/Meziantou.Analyzer.Test/Rules/CommaAnalyzerTests.cs
+++ b/tests/Meziantou.Analyzer.Test/Rules/CommaAnalyzerTests.cs
@@ -1,5 +1,6 @@
using System.Threading.Tasks;
using Meziantou.Analyzer.Rules;
+using Meziantou.Analyzer.Test.Helpers;
using TestHelper;
using Xunit;
diff --git a/tests/Meziantou.Analyzer.Test/Rules/ConcurrentDictionaryMustPreventClosureWhenAccessingTheKeyAnalyzerTests_MA0105.cs b/tests/Meziantou.Analyzer.Test/Rules/ConcurrentDictionaryMustPreventClosureWhenAccessingTheKeyAnalyzerTests_MA0105.cs
index 1d120d03..c1d9c09c 100644
--- a/tests/Meziantou.Analyzer.Test/Rules/ConcurrentDictionaryMustPreventClosureWhenAccessingTheKeyAnalyzerTests_MA0105.cs
+++ b/tests/Meziantou.Analyzer.Test/Rules/ConcurrentDictionaryMustPreventClosureWhenAccessingTheKeyAnalyzerTests_MA0105.cs
@@ -1,5 +1,6 @@
using System.Threading.Tasks;
using Meziantou.Analyzer.Rules;
+using Meziantou.Analyzer.Test.Helpers;
using TestHelper;
using Xunit;
diff --git a/tests/Meziantou.Analyzer.Test/Rules/ConcurrentDictionaryMustPreventClosureWhenAccessingTheKeyAnalyzerTests_MA0106.cs b/tests/Meziantou.Analyzer.Test/Rules/ConcurrentDictionaryMustPreventClosureWhenAccessingTheKeyAnalyzerTests_MA0106.cs
index 7ca250fe..b895b813 100644
--- a/tests/Meziantou.Analyzer.Test/Rules/ConcurrentDictionaryMustPreventClosureWhenAccessingTheKeyAnalyzerTests_MA0106.cs
+++ b/tests/Meziantou.Analyzer.Test/Rules/ConcurrentDictionaryMustPreventClosureWhenAccessingTheKeyAnalyzerTests_MA0106.cs
@@ -1,5 +1,6 @@
using System.Threading.Tasks;
using Meziantou.Analyzer.Rules;
+using Meziantou.Analyzer.Test.Helpers;
using TestHelper;
using Xunit;
diff --git a/tests/Meziantou.Analyzer.Test/Rules/ConstructorArgumentParametersShouldExistInConstructorsAnalyzerTests.cs b/tests/Meziantou.Analyzer.Test/Rules/ConstructorArgumentParametersShouldExistInConstructorsAnalyzerTests.cs
index cf04c18c..578f916b 100644
--- a/tests/Meziantou.Analyzer.Test/Rules/ConstructorArgumentParametersShouldExistInConstructorsAnalyzerTests.cs
+++ b/tests/Meziantou.Analyzer.Test/Rules/ConstructorArgumentParametersShouldExistInConstructorsAnalyzerTests.cs
@@ -1,5 +1,6 @@
using System.Threading.Tasks;
using Meziantou.Analyzer.Rules;
+using Meziantou.Analyzer.Test.Helpers;
using TestHelper;
using Xunit;
diff --git a/tests/Meziantou.Analyzer.Test/Rules/DebuggerDisplayAttributeShouldContainValidExpressionsAnalyzerTests.cs b/tests/Meziantou.Analyzer.Test/Rules/DebuggerDisplayAttributeShouldContainValidExpressionsAnalyzerTests.cs
index 11748e6c..dfbe3bac 100755
--- a/tests/Meziantou.Analyzer.Test/Rules/DebuggerDisplayAttributeShouldContainValidExpressionsAnalyzerTests.cs
+++ b/tests/Meziantou.Analyzer.Test/Rules/DebuggerDisplayAttributeShouldContainValidExpressionsAnalyzerTests.cs
@@ -1,5 +1,6 @@
using System.Threading.Tasks;
using Meziantou.Analyzer.Rules;
+using Meziantou.Analyzer.Test.Helpers;
using TestHelper;
using Xunit;
diff --git a/tests/Meziantou.Analyzer.Test/Rules/DoNotCallVirtualMethodInConstructorAnalyzerTests.cs b/tests/Meziantou.Analyzer.Test/Rules/DoNotCallVirtualMethodInConstructorAnalyzerTests.cs
index 90d633c3..a95a5aae 100644
--- a/tests/Meziantou.Analyzer.Test/Rules/DoNotCallVirtualMethodInConstructorAnalyzerTests.cs
+++ b/tests/Meziantou.Analyzer.Test/Rules/DoNotCallVirtualMethodInConstructorAnalyzerTests.cs
@@ -275,5 +275,4 @@ await CreateProjectBuilder()
.WithSourceCode(SourceCode)
.ValidateAsync();
}
-
}
diff --git a/tests/Meziantou.Analyzer.Test/Rules/DoNotDeclareStaticMembersOnGenericTypesTests.cs b/tests/Meziantou.Analyzer.Test/Rules/DoNotDeclareStaticMembersOnGenericTypesTests.cs
index bbf6c0a1..fdc649b6 100644
--- a/tests/Meziantou.Analyzer.Test/Rules/DoNotDeclareStaticMembersOnGenericTypesTests.cs
+++ b/tests/Meziantou.Analyzer.Test/Rules/DoNotDeclareStaticMembersOnGenericTypesTests.cs
@@ -1,5 +1,6 @@
using System.Threading.Tasks;
using Meziantou.Analyzer.Rules;
+using Meziantou.Analyzer.Test.Helpers;
using TestHelper;
using Xunit;
diff --git a/tests/Meziantou.Analyzer.Test/Rules/DoNotLogClassifiedDataAnalyzerTests.cs b/tests/Meziantou.Analyzer.Test/Rules/DoNotLogClassifiedDataAnalyzerTests.cs
index 7b54fca2..0a84535a 100755
--- a/tests/Meziantou.Analyzer.Test/Rules/DoNotLogClassifiedDataAnalyzerTests.cs
+++ b/tests/Meziantou.Analyzer.Test/Rules/DoNotLogClassifiedDataAnalyzerTests.cs
@@ -1,5 +1,6 @@
using System.Threading.Tasks;
using Meziantou.Analyzer.Rules;
+using Meziantou.Analyzer.Test.Helpers;
using TestHelper;
using Xunit;
diff --git a/tests/Meziantou.Analyzer.Test/Rules/DoNotOverwriteRazorComponentParameterValueTests.cs b/tests/Meziantou.Analyzer.Test/Rules/DoNotOverwriteRazorComponentParameterValueTests.cs
index 1be66002..92cce507 100644
--- a/tests/Meziantou.Analyzer.Test/Rules/DoNotOverwriteRazorComponentParameterValueTests.cs
+++ b/tests/Meziantou.Analyzer.Test/Rules/DoNotOverwriteRazorComponentParameterValueTests.cs
@@ -1,5 +1,6 @@
using System.Threading.Tasks;
using Meziantou.Analyzer.Rules;
+using Meziantou.Analyzer.Test.Helpers;
using TestHelper;
using Xunit;
diff --git a/tests/Meziantou.Analyzer.Test/Rules/DoNotUseAsyncDelegateForSyncDelegateAnalyzerTests.cs b/tests/Meziantou.Analyzer.Test/Rules/DoNotUseAsyncDelegateForSyncDelegateAnalyzerTests.cs
index d6889b2f..8d79ec49 100755
--- a/tests/Meziantou.Analyzer.Test/Rules/DoNotUseAsyncDelegateForSyncDelegateAnalyzerTests.cs
+++ b/tests/Meziantou.Analyzer.Test/Rules/DoNotUseAsyncDelegateForSyncDelegateAnalyzerTests.cs
@@ -1,5 +1,6 @@
using System.Threading.Tasks;
using Meziantou.Analyzer.Rules;
+using Meziantou.Analyzer.Test.Helpers;
using TestHelper;
using Xunit;
diff --git a/tests/Meziantou.Analyzer.Test/Rules/DoNotUseAsyncVoidAnalyzerTests.cs b/tests/Meziantou.Analyzer.Test/Rules/DoNotUseAsyncVoidAnalyzerTests.cs
index 50efa8bb..6e569baa 100755
--- a/tests/Meziantou.Analyzer.Test/Rules/DoNotUseAsyncVoidAnalyzerTests.cs
+++ b/tests/Meziantou.Analyzer.Test/Rules/DoNotUseAsyncVoidAnalyzerTests.cs
@@ -1,5 +1,6 @@
using System.Threading.Tasks;
using Meziantou.Analyzer.Rules;
+using Meziantou.Analyzer.Test.Helpers;
using TestHelper;
using Xunit;
@@ -99,5 +100,4 @@ void A()
""")
.ValidateAsync();
}
-
}
diff --git a/tests/Meziantou.Analyzer.Test/Rules/DoNotUseBlockingCallInAsyncContextAnalyzer_AsyncContextTests.cs b/tests/Meziantou.Analyzer.Test/Rules/DoNotUseBlockingCallInAsyncContextAnalyzer_AsyncContextTests.cs
index 5637855a..2df1e10b 100644
--- a/tests/Meziantou.Analyzer.Test/Rules/DoNotUseBlockingCallInAsyncContextAnalyzer_AsyncContextTests.cs
+++ b/tests/Meziantou.Analyzer.Test/Rules/DoNotUseBlockingCallInAsyncContextAnalyzer_AsyncContextTests.cs
@@ -1,5 +1,6 @@
using System.Threading.Tasks;
using Meziantou.Analyzer.Rules;
+using Meziantou.Analyzer.Test.Helpers;
using TestHelper;
using Xunit;
diff --git a/tests/Meziantou.Analyzer.Test/Rules/DoNotUseDefaultEqualsOnValueTypeAnalyzer_HashSetTests.cs b/tests/Meziantou.Analyzer.Test/Rules/DoNotUseDefaultEqualsOnValueTypeAnalyzer_HashSetTests.cs
index af0b1d09..71a9716b 100644
--- a/tests/Meziantou.Analyzer.Test/Rules/DoNotUseDefaultEqualsOnValueTypeAnalyzer_HashSetTests.cs
+++ b/tests/Meziantou.Analyzer.Test/Rules/DoNotUseDefaultEqualsOnValueTypeAnalyzer_HashSetTests.cs
@@ -119,6 +119,4 @@ await CreateProjectBuilder()
.WithSourceCode(sourceCode)
.ValidateAsync();
}
-
-
}
diff --git a/tests/Meziantou.Analyzer.Test/Rules/DoNotUseEqualityOperatorsForSpanOfCharAnalyzerTests.cs b/tests/Meziantou.Analyzer.Test/Rules/DoNotUseEqualityOperatorsForSpanOfCharAnalyzerTests.cs
index 858ebde7..50a14f8b 100644
--- a/tests/Meziantou.Analyzer.Test/Rules/DoNotUseEqualityOperatorsForSpanOfCharAnalyzerTests.cs
+++ b/tests/Meziantou.Analyzer.Test/Rules/DoNotUseEqualityOperatorsForSpanOfCharAnalyzerTests.cs
@@ -1,5 +1,6 @@
using System.Threading.Tasks;
using Meziantou.Analyzer.Rules;
+using Meziantou.Analyzer.Test.Helpers;
using TestHelper;
using Xunit;
diff --git a/tests/Meziantou.Analyzer.Test/Rules/DoNotUseImplicitCultureSensitiveToStringAnalyzerTests.cs b/tests/Meziantou.Analyzer.Test/Rules/DoNotUseImplicitCultureSensitiveToStringAnalyzerTests.cs
index 6c28b187..e4a0af04 100755
--- a/tests/Meziantou.Analyzer.Test/Rules/DoNotUseImplicitCultureSensitiveToStringAnalyzerTests.cs
+++ b/tests/Meziantou.Analyzer.Test/Rules/DoNotUseImplicitCultureSensitiveToStringAnalyzerTests.cs
@@ -1,5 +1,6 @@
using System.Threading.Tasks;
using Meziantou.Analyzer.Rules;
+using Meziantou.Analyzer.Test.Helpers;
using TestHelper;
using Xunit;
diff --git a/tests/Meziantou.Analyzer.Test/Rules/DoNotUseToStringIfObjectAnalyzerTests.cs b/tests/Meziantou.Analyzer.Test/Rules/DoNotUseToStringIfObjectAnalyzerTests.cs
index 3687f82a..44896853 100755
--- a/tests/Meziantou.Analyzer.Test/Rules/DoNotUseToStringIfObjectAnalyzerTests.cs
+++ b/tests/Meziantou.Analyzer.Test/Rules/DoNotUseToStringIfObjectAnalyzerTests.cs
@@ -1,5 +1,6 @@
using System.Threading.Tasks;
using Meziantou.Analyzer.Rules;
+using Meziantou.Analyzer.Test.Helpers;
using TestHelper;
using Xunit;
diff --git a/tests/Meziantou.Analyzer.Test/Rules/DoNotUseUnknownParameterForRazorComponentAnalyzerTests.cs b/tests/Meziantou.Analyzer.Test/Rules/DoNotUseUnknownParameterForRazorComponentAnalyzerTests.cs
index 16b6ef16..9497fbcf 100755
--- a/tests/Meziantou.Analyzer.Test/Rules/DoNotUseUnknownParameterForRazorComponentAnalyzerTests.cs
+++ b/tests/Meziantou.Analyzer.Test/Rules/DoNotUseUnknownParameterForRazorComponentAnalyzerTests.cs
@@ -1,5 +1,6 @@
using System.Threading.Tasks;
using Meziantou.Analyzer.Rules;
+using Meziantou.Analyzer.Test.Helpers;
using TestHelper;
using Xunit;
@@ -279,5 +280,4 @@ await CreateProjectBuilder()
.WithSourceCode(Usings + sourceCode + ComponentWithChildContent)
.ValidateAsync();
}
-
}
diff --git a/tests/Meziantou.Analyzer.Test/Rules/EqualityShouldBeCorrectlyImplementedAnalyzerMA0094Tests.cs b/tests/Meziantou.Analyzer.Test/Rules/EqualityShouldBeCorrectlyImplementedAnalyzerMA0094Tests.cs
index a172ebf8..7fa46ba4 100644
--- a/tests/Meziantou.Analyzer.Test/Rules/EqualityShouldBeCorrectlyImplementedAnalyzerMA0094Tests.cs
+++ b/tests/Meziantou.Analyzer.Test/Rules/EqualityShouldBeCorrectlyImplementedAnalyzerMA0094Tests.cs
@@ -119,5 +119,4 @@ await CreateProjectBuilder()
.WithSourceCode(originalCode)
.ValidateAsync();
}
-
}
diff --git a/tests/Meziantou.Analyzer.Test/Rules/EventArgsNameShouldEndWithEventArgsAnalyzerTests.cs b/tests/Meziantou.Analyzer.Test/Rules/EventArgsNameShouldEndWithEventArgsAnalyzerTests.cs
index 39539177..182bdf3e 100644
--- a/tests/Meziantou.Analyzer.Test/Rules/EventArgsNameShouldEndWithEventArgsAnalyzerTests.cs
+++ b/tests/Meziantou.Analyzer.Test/Rules/EventArgsNameShouldEndWithEventArgsAnalyzerTests.cs
@@ -38,5 +38,4 @@ await CreateProjectBuilder()
.WithSourceCode(SourceCode)
.ValidateAsync();
}
-
}
diff --git a/tests/Meziantou.Analyzer.Test/Rules/ExceptionNameShouldEndWithExceptionAnalyzerTests.cs b/tests/Meziantou.Analyzer.Test/Rules/ExceptionNameShouldEndWithExceptionAnalyzerTests.cs
index d109ede2..6955ea2f 100644
--- a/tests/Meziantou.Analyzer.Test/Rules/ExceptionNameShouldEndWithExceptionAnalyzerTests.cs
+++ b/tests/Meziantou.Analyzer.Test/Rules/ExceptionNameShouldEndWithExceptionAnalyzerTests.cs
@@ -38,5 +38,4 @@ await CreateProjectBuilder()
.WithSourceCode(SourceCode)
.ValidateAsync();
}
-
}
diff --git a/tests/Meziantou.Analyzer.Test/Rules/JSInteropMustNotBeUsedInOnInitializedAnalyzerTests.cs b/tests/Meziantou.Analyzer.Test/Rules/JSInteropMustNotBeUsedInOnInitializedAnalyzerTests.cs
index 4ecd3f43..b8d3bea5 100644
--- a/tests/Meziantou.Analyzer.Test/Rules/JSInteropMustNotBeUsedInOnInitializedAnalyzerTests.cs
+++ b/tests/Meziantou.Analyzer.Test/Rules/JSInteropMustNotBeUsedInOnInitializedAnalyzerTests.cs
@@ -1,5 +1,6 @@
using System.Threading.Tasks;
using Meziantou.Analyzer.Rules;
+using Meziantou.Analyzer.Test.Helpers;
using TestHelper;
using Xunit;
diff --git a/tests/Meziantou.Analyzer.Test/Rules/JSInvokableMethodsMustBePublicAnalyzerTests.cs b/tests/Meziantou.Analyzer.Test/Rules/JSInvokableMethodsMustBePublicAnalyzerTests.cs
index 18e13a53..af85b499 100644
--- a/tests/Meziantou.Analyzer.Test/Rules/JSInvokableMethodsMustBePublicAnalyzerTests.cs
+++ b/tests/Meziantou.Analyzer.Test/Rules/JSInvokableMethodsMustBePublicAnalyzerTests.cs
@@ -1,5 +1,6 @@
using System.Threading.Tasks;
using Meziantou.Analyzer.Rules;
+using Meziantou.Analyzer.Test.Helpers;
using TestHelper;
using Xunit;
@@ -34,5 +35,4 @@ await CreateProjectBuilder()
.WithSourceCode(SourceCode)
.ValidateAsync();
}
-
}
diff --git a/tests/Meziantou.Analyzer.Test/Rules/LoggerParameterTypeAnalyzerTests.cs b/tests/Meziantou.Analyzer.Test/Rules/LoggerParameterTypeAnalyzerTests.cs
index 91031c98..cf538ae5 100755
--- a/tests/Meziantou.Analyzer.Test/Rules/LoggerParameterTypeAnalyzerTests.cs
+++ b/tests/Meziantou.Analyzer.Test/Rules/LoggerParameterTypeAnalyzerTests.cs
@@ -1,5 +1,6 @@
using System.Threading.Tasks;
using Meziantou.Analyzer.Rules;
+using Meziantou.Analyzer.Test.Helpers;
using TestHelper;
using Xunit;
@@ -361,7 +362,7 @@ await CreateProjectBuilder()
.WithSourceCode("")
.WithOutputKind(Microsoft.CodeAnalysis.OutputKind.DynamicallyLinkedLibrary)
.AddAdditionalFile("LoggerParameterTypes.txt", "Prop;int")
- .ShouldReportDiagnostic(new DiagnosticResult { Id = "MA0125", Locations = new[] { new DiagnosticResultLocation("LoggerParameterTypes.txt", 1, 1, 1, 1) } })
+ .ShouldReportDiagnostic(new DiagnosticResult { Id = "MA0125", Locations = [new DiagnosticResultLocation("LoggerParameterTypes.txt", 1, 1, 1, 1)] })
.ValidateAsync();
}
@@ -372,7 +373,7 @@ await CreateProjectBuilder()
.WithSourceCode("")
.WithOutputKind(Microsoft.CodeAnalysis.OutputKind.DynamicallyLinkedLibrary)
.AddAdditionalFile("LoggerParameterTypes.txt", "Prop;M:System.Int32.MaxValue")
- .ShouldReportDiagnostic(new DiagnosticResult { Id = "MA0125", Locations = new[] { new DiagnosticResultLocation("LoggerParameterTypes.txt", 1, 1, 1, 1) } })
+ .ShouldReportDiagnostic(new DiagnosticResult { Id = "MA0125", Locations = [new DiagnosticResultLocation("LoggerParameterTypes.txt", 1, 1, 1, 1)] })
.ValidateAsync();
}
@@ -384,7 +385,7 @@ await CreateProjectBuilder()
.WithOutputKind(Microsoft.CodeAnalysis.OutputKind.DynamicallyLinkedLibrary)
.AddAdditionalFile("LoggerParameterTypes.1.txt", "Prop;System.String")
.AddAdditionalFile("LoggerParameterTypes.2.txt", "New;System.String\nProp;System.String")
- .ShouldReportDiagnostic(new DiagnosticResult { Id = "MA0126", Locations = new[] { new DiagnosticResultLocation("LoggerParameterTypes.2.txt", 2, 1, 2, 1) } })
+ .ShouldReportDiagnostic(new DiagnosticResult { Id = "MA0126", Locations = [new DiagnosticResultLocation("LoggerParameterTypes.2.txt", 2, 1, 2, 1)] })
.ValidateAsync();
}
diff --git a/tests/Meziantou.Analyzer.Test/Rules/LoggerParameterTypeAnalyzer_SerilogTests.cs b/tests/Meziantou.Analyzer.Test/Rules/LoggerParameterTypeAnalyzer_SerilogTests.cs
index 82805540..6b7d51e2 100644
--- a/tests/Meziantou.Analyzer.Test/Rules/LoggerParameterTypeAnalyzer_SerilogTests.cs
+++ b/tests/Meziantou.Analyzer.Test/Rules/LoggerParameterTypeAnalyzer_SerilogTests.cs
@@ -1,5 +1,6 @@
using System.Threading.Tasks;
using Meziantou.Analyzer.Rules;
+using Meziantou.Analyzer.Test.Helpers;
using TestHelper;
using Xunit;
diff --git a/tests/Meziantou.Analyzer.Test/Rules/MakeMemberReadOnlyAnalyzerTests.cs b/tests/Meziantou.Analyzer.Test/Rules/MakeMemberReadOnlyAnalyzerTests.cs
index 82da4737..2470110e 100644
--- a/tests/Meziantou.Analyzer.Test/Rules/MakeMemberReadOnlyAnalyzerTests.cs
+++ b/tests/Meziantou.Analyzer.Test/Rules/MakeMemberReadOnlyAnalyzerTests.cs
@@ -1,5 +1,6 @@
using System.Threading.Tasks;
using Meziantou.Analyzer.Rules;
+using Meziantou.Analyzer.Test.Helpers;
using TestHelper;
using Xunit;
diff --git a/tests/Meziantou.Analyzer.Test/Rules/MakeMethodStaticAnalyzerTests_Methods.cs b/tests/Meziantou.Analyzer.Test/Rules/MakeMethodStaticAnalyzerTests_Methods.cs
index 4a200082..5725b0d3 100644
--- a/tests/Meziantou.Analyzer.Test/Rules/MakeMethodStaticAnalyzerTests_Methods.cs
+++ b/tests/Meziantou.Analyzer.Test/Rules/MakeMethodStaticAnalyzerTests_Methods.cs
@@ -1,5 +1,6 @@
using System.Threading.Tasks;
using Meziantou.Analyzer.Rules;
+using Meziantou.Analyzer.Test.Helpers;
using TestHelper;
using Xunit;
diff --git a/tests/Meziantou.Analyzer.Test/Rules/MethodsReturningAnAwaitableTypeMustHaveTheAsyncSuffixAnalyzerTests.cs b/tests/Meziantou.Analyzer.Test/Rules/MethodsReturningAnAwaitableTypeMustHaveTheAsyncSuffixAnalyzerTests.cs
index 12f54c5c..4cbecce6 100644
--- a/tests/Meziantou.Analyzer.Test/Rules/MethodsReturningAnAwaitableTypeMustHaveTheAsyncSuffixAnalyzerTests.cs
+++ b/tests/Meziantou.Analyzer.Test/Rules/MethodsReturningAnAwaitableTypeMustHaveTheAsyncSuffixAnalyzerTests.cs
@@ -1,5 +1,6 @@
using System.Threading.Tasks;
using Meziantou.Analyzer.Rules;
+using Meziantou.Analyzer.Test.Helpers;
using TestHelper;
using Xunit;
diff --git a/tests/Meziantou.Analyzer.Test/Rules/NamedParameterAnalyzerTests.cs b/tests/Meziantou.Analyzer.Test/Rules/NamedParameterAnalyzerTests.cs
index 7165b513..6df46a6c 100755
--- a/tests/Meziantou.Analyzer.Test/Rules/NamedParameterAnalyzerTests.cs
+++ b/tests/Meziantou.Analyzer.Test/Rules/NamedParameterAnalyzerTests.cs
@@ -1,5 +1,6 @@
using System.Threading.Tasks;
using Meziantou.Analyzer.Rules;
+using Meziantou.Analyzer.Test.Helpers;
using TestHelper;
using Xunit;
diff --git a/tests/Meziantou.Analyzer.Test/Rules/NullableAttributeUsageAnalyzerTests.cs b/tests/Meziantou.Analyzer.Test/Rules/NullableAttributeUsageAnalyzerTests.cs
index 0a54b0a2..e95098f9 100644
--- a/tests/Meziantou.Analyzer.Test/Rules/NullableAttributeUsageAnalyzerTests.cs
+++ b/tests/Meziantou.Analyzer.Test/Rules/NullableAttributeUsageAnalyzerTests.cs
@@ -62,5 +62,4 @@ await CreateProjectBuilder()
.WithSourceCode(SourceCode)
.ValidateAsync();
}
-
}
diff --git a/tests/Meziantou.Analyzer.Test/Rules/ObjectGetTypeOnTypeInstanceAnalyzerTests.cs b/tests/Meziantou.Analyzer.Test/Rules/ObjectGetTypeOnTypeInstanceAnalyzerTests.cs
index 5beca8a0..0a49c5fe 100644
--- a/tests/Meziantou.Analyzer.Test/Rules/ObjectGetTypeOnTypeInstanceAnalyzerTests.cs
+++ b/tests/Meziantou.Analyzer.Test/Rules/ObjectGetTypeOnTypeInstanceAnalyzerTests.cs
@@ -51,5 +51,4 @@ await CreateProjectBuilder()
.WithSourceCode(code)
.ValidateAsync();
}
-
}
diff --git a/tests/Meziantou.Analyzer.Test/Rules/ObsoleteAttributesShouldIncludeExplanationsAnalyzerTests.cs b/tests/Meziantou.Analyzer.Test/Rules/ObsoleteAttributesShouldIncludeExplanationsAnalyzerTests.cs
index 5ac865d5..680c7053 100644
--- a/tests/Meziantou.Analyzer.Test/Rules/ObsoleteAttributesShouldIncludeExplanationsAnalyzerTests.cs
+++ b/tests/Meziantou.Analyzer.Test/Rules/ObsoleteAttributesShouldIncludeExplanationsAnalyzerTests.cs
@@ -42,5 +42,4 @@ await CreateProjectBuilder()
.WithSourceCode(SourceCode)
.ValidateAsync();
}
-
}
diff --git a/tests/Meziantou.Analyzer.Test/Rules/OptimizeLinqUsageAnalyzerOrderTests.cs b/tests/Meziantou.Analyzer.Test/Rules/OptimizeLinqUsageAnalyzerOrderTests.cs
index 4d832724..27c88ac7 100644
--- a/tests/Meziantou.Analyzer.Test/Rules/OptimizeLinqUsageAnalyzerOrderTests.cs
+++ b/tests/Meziantou.Analyzer.Test/Rules/OptimizeLinqUsageAnalyzerOrderTests.cs
@@ -1,5 +1,6 @@
using System.Threading.Tasks;
using Meziantou.Analyzer.Rules;
+using Meziantou.Analyzer.Test.Helpers;
using TestHelper;
using Xunit;
diff --git a/tests/Meziantou.Analyzer.Test/Rules/OptimizeLinqUsageAnalyzerUseDirectMethodsTests.cs b/tests/Meziantou.Analyzer.Test/Rules/OptimizeLinqUsageAnalyzerUseDirectMethodsTests.cs
index 0bc713fc..947f0180 100755
--- a/tests/Meziantou.Analyzer.Test/Rules/OptimizeLinqUsageAnalyzerUseDirectMethodsTests.cs
+++ b/tests/Meziantou.Analyzer.Test/Rules/OptimizeLinqUsageAnalyzerUseDirectMethodsTests.cs
@@ -1,5 +1,6 @@
using System.Threading.Tasks;
using Meziantou.Analyzer.Rules;
+using Meziantou.Analyzer.Test.Helpers;
using TestHelper;
using Xunit;
diff --git a/tests/Meziantou.Analyzer.Test/Rules/OptimizeLinqUsageAnalyzerUseIndexerTests.cs b/tests/Meziantou.Analyzer.Test/Rules/OptimizeLinqUsageAnalyzerUseIndexerTests.cs
index b0b5d048..cc0bafdc 100644
--- a/tests/Meziantou.Analyzer.Test/Rules/OptimizeLinqUsageAnalyzerUseIndexerTests.cs
+++ b/tests/Meziantou.Analyzer.Test/Rules/OptimizeLinqUsageAnalyzerUseIndexerTests.cs
@@ -1,5 +1,6 @@
using System.Threading.Tasks;
using Meziantou.Analyzer.Rules;
+using Meziantou.Analyzer.Test.Helpers;
using TestHelper;
using Xunit;
diff --git a/tests/Meziantou.Analyzer.Test/Rules/OptimizeStartsWithAnalyzerTests.cs b/tests/Meziantou.Analyzer.Test/Rules/OptimizeStartsWithAnalyzerTests.cs
index b058ff52..483d79a2 100755
--- a/tests/Meziantou.Analyzer.Test/Rules/OptimizeStartsWithAnalyzerTests.cs
+++ b/tests/Meziantou.Analyzer.Test/Rules/OptimizeStartsWithAnalyzerTests.cs
@@ -1,5 +1,6 @@
using System.Threading.Tasks;
using Meziantou.Analyzer.Rules;
+using Meziantou.Analyzer.Test.Helpers;
using TestHelper;
using Xunit;
diff --git a/tests/Meziantou.Analyzer.Test/Rules/OptimizeStringBuilderUsageAnalyzerTests.cs b/tests/Meziantou.Analyzer.Test/Rules/OptimizeStringBuilderUsageAnalyzerTests.cs
index 7074d5ce..3144ba2d 100755
--- a/tests/Meziantou.Analyzer.Test/Rules/OptimizeStringBuilderUsageAnalyzerTests.cs
+++ b/tests/Meziantou.Analyzer.Test/Rules/OptimizeStringBuilderUsageAnalyzerTests.cs
@@ -1,6 +1,7 @@
using System.Collections.Generic;
using System.Threading.Tasks;
using Meziantou.Analyzer.Rules;
+using Meziantou.Analyzer.Test.Helpers;
using TestHelper;
using Xunit;
@@ -172,15 +173,18 @@ void A()
.ValidateAsync();
}
- public static IEnumerable