From f8076852d90405057514f6a1d0f2855a60f537bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A9rald=20Barr=C3=A9?= Date: Tue, 12 Nov 2024 21:13:28 -0500 Subject: [PATCH] Update .NET SDK 9.0 (#768) --- .editorconfig | 9 +++-- Directory.Build.props | 7 +++- Directory.Build.targets | 8 ++--- global.json | 4 +-- .../DocumentationGenerator.csproj | 2 +- src/ListDotNetTypes/ListDotNetTypes.csproj | 6 ++-- src/ListDotNetTypes/Program.cs | 4 ++- .../RequireNamedArgumentAttribute.cs | 1 - .../StructuredLogFieldAttribute.cs | 1 - .../Internals/DocumentBasedFixAllProvider.cs | 35 +++++++++---------- .../Internals/FixAllContextHelper.cs | 2 +- .../Meziantou.Analyzer.CodeFixers.csproj | 2 +- .../AvoidUsingRedundantElseFixAllProvider.cs | 8 ++--- .../Rules/ClassMustBeSealedFixer.cs | 2 +- ...DoNotUseBlockingCallInAsyncContextFixer.cs | 11 +++--- ...UseEqualityComparerDefaultOfStringFixer.cs | 1 + .../Rules/DoNotUseStringGetHashCodeFixer.cs | 1 + ...ualityShouldBeCorrectlyImplementedFixer.cs | 1 + .../Rules/MakeClassStaticFixer.cs | 1 + .../Rules/MakeMemberReadOnlyFixer.cs | 8 ++--- .../Rules/MakeMethodStaticFixer.cs | 1 + ...ributesWithAttributeUsageAttributeFixer.cs | 6 ++-- ...otPatternShouldBeParenthesizedCodeFixer.cs | 2 +- .../Rules/OptimizeLinqUsageFixer.cs | 4 ++- .../Rules/OptimizeStartsWithFixer.cs | 1 + .../Rules/OptimizeStringBuilderUsageFixer.cs | 1 + ...skFromResultInsteadOfReturningNullFixer.cs | 1 + ...dThatHasCancellationTokenFixer_Argument.cs | 1 - .../Rules/UseDateTimeUnixEpochFixer.cs | 1 + .../Rules/UseEventArgsEmptyFixer.cs | 1 + .../Rules/UseGuidEmptyFixer.cs | 1 + .../Rules/UseRegexSourceGeneratorFixer.cs | 1 + .../Rules/UseStringComparerFixer.cs | 1 + .../Rules/UseStringComparisonFixer.cs | 1 + ...ngCreateInsteadOfFormattableStringFixer.cs | 1 + .../Rules/UseStringEqualsFixer.cs | 1 + .../Rules/UseStructLayoutAttributeFixer.cs | 8 ++--- .../Rules/ValidateArgumentsCorrectlyFixer.cs | 1 + .../Internals/CompilationExtensions.cs | 5 ++- .../Internals/ContextExtensions.cs | 3 +- .../Internals/ContextExtensions.g.cs | 2 +- .../Internals/ContextExtensions.tt | 2 +- .../Internals/DiagnosticFieldReportOptions.cs | 2 +- .../DiagnosticInvocationReportOptions.cs | 2 +- .../DiagnosticMethodReportOptions.cs | 2 +- .../DiagnosticParameterReportOptions.cs | 2 +- .../DiagnosticPropertyReportOptions.cs | 2 +- .../Internals/DiagnosticReporter.cs | 2 +- .../Internals/EnumerableExtensions.cs | 2 +- .../Internals/LanguageVersionExtensions.cs | 2 +- .../Internals/ListExtensions.cs | 4 +-- .../Internals/MethodSymbolExtensions.cs | 2 +- .../Internals/NamespaceSymbolExtensions.cs | 2 +- .../Internals/ObjectPool.cs | 1 - .../Internals/OperationExtensions.cs | 3 +- .../Internals/OperationUtilities.cs | 3 +- .../Internals/StringExtensions.cs | 2 +- .../Internals/SymbolExtensions.cs | 2 +- .../Internals/SyntaxTokenListExtensions.cs | 2 +- .../Internals/TypeSymbolExtensions.cs | 2 +- .../Meziantou.Analyzer.csproj | 2 +- ...tTypesShouldNotHaveConstructorsAnalyzer.cs | 1 + .../AddOverloadWithSpanOrMemoryAnalyzer.cs | 3 +- ...otBeUsedToUnsubscribeFromEventsAnalyzer.cs | 1 + ...eptionShouldSpecifyArgumentNameAnalyzer.cs | 1 + ...ibuteNameShouldEndWithAttributeAnalyzer.cs | 1 + ...reWhenUsingConcurrentDictionaryAnalyzer.cs | 6 ++-- ...AvoidComparisonWithBoolConstantAnalyzer.cs | 4 +-- ...ingOnPubliclyAccessibleInstanceAnalyzer.cs | 1 + .../Rules/AvoidUsingRedundantElseAnalyzer.cs | 3 ++ .../AvoidUsingRedundantElseAnalyzerCommon.cs | 2 +- ...metersShouldExistInConstructorsAnalyzer.cs | 1 + ...teShouldContainValidExpressionsAnalyzer.cs | 1 + .../Rules/DeclareTypesInNamespacesAnalyzer.cs | 1 + ...tCallVirtualMethodInConstructorAnalyzer.cs | 1 + ...DoNotDeclareStaticMembersOnGenericTypes.cs | 1 + ...ConvertDateTimeToDateTimeOffsetAnalyzer.cs | 1 + .../Rules/DoNotLogClassifiedDataAnalyzer.cs | 1 + .../Rules/DoNotNaNInComparisonsAnalyzer.cs | 1 + ...otOverwriteRazorComponentParameterValue.cs | 1 + .../DoNotRaiseApplicationExceptionAnalyzer.cs | 1 + ...NotRaiseNotImplementedExceptionAnalyzer.cs | 1 + ...DoNotRaiseReservedExceptionTypeAnalyzer.cs | 1 + ...inalExceptionFromThrowStatementAnalyzer.cs | 1 + .../Rules/DoNotThrowFromFinalizerAnalyzer.cs | 1 + .../DoNotThrowFromFinallyBlockAnalyzer.cs | 1 + ...UseAsyncDelegateForSyncDelegateAnalyzer.cs | 1 + .../Rules/DoNotUseAsyncVoidAnalyzer.cs | 1 + ...oNotUseDefaultEqualsOnValueTypeAnalyzer.cs | 5 +-- ...EqualityComparerDefaultOfStringAnalyzer.cs | 1 + ...eEqualityOperatorsForSpanOfCharAnalyzer.cs | 1 + .../Rules/DoNotUseFinalizerAnalyzer.cs | 1 + ...erCertificateValidationCallbackAnalyzer.cs | 1 + .../DoNotUseStringGetHashCodeAnalyzer.cs | 1 + .../Rules/DoNotUseToStringIfObjectAnalyzer.cs | 1 + ...knownParameterForRazorComponentAnalyzer.cs | 1 + .../DoNotUseZeroToInitializeAnEnumValue.cs | 1 + ...FieldsWithThreadStaticAttributeAnalyzer.cs | 1 + ...ontUseDangerousThreadingMethodsAnalyzer.cs | 1 + .../Rules/DotNotUseNameFromBCLAnalyzer.cs | 1 + ...ityShouldBeCorrectlyImplementedAnalyzer.cs | 1 + ...uldBeCorrectlyImplementedAnalyzerCommon.cs | 3 +- ...tArgsNameShouldEndWithEventArgsAnalyzer.cs | 1 + ...EventsShouldHaveProperArgumentsAnalyzer.cs | 1 + ...ptionNameShouldEndWithExceptionAnalyzer.cs | 1 + .../FileNameMustMatchTypeNameAnalyzer.cs | 1 + .../Rules/FixToDoAnalyzer.cs | 1 + .../IfElseBranchesAreIdenticalAnalyzer.cs | 1 + ...ropMustNotBeUsedInOnInitializedAnalyzer.cs | 1 + .../JSInvokableMethodsMustBePublicAnalyzer.cs | 1 + ...alVariablesShouldNotHideSymbolsAnalyzer.cs | 1 + .../Rules/LoggerParameterTypeAnalyzer.cs | 1 - .../Rules/MakeClassStaticAnalyzer.cs | 1 + .../Rules/MakeInterpolatedStringAnalyzer.cs | 1 + .../Rules/MakeMemberReadOnlyAnalyzer.cs | 1 + ...utesWithAttributeUsageAttributeAnalyzer.cs | 1 + ...houldNotChangeParameterDefaultsAnalyzer.cs | 1 + .../Rules/MethodShouldNotBeTooLongAnalyzer.cs | 1 + .../Rules/NamedParameterAnalyzer.cs | 1 + ...tStaticFieldsShouldNotBeVisibleAnalyzer.cs | 1 + ...ldNotBeMarkedWithFlagsAttributeAnalyzer.cs | 1 + ...NotPatternShouldBeParenthesizedAnalyzer.cs | 2 +- .../Rules/NullableAttributeUsageAnalyzer.cs | 1 + .../ObjectGetTypeOnTypeInstanceAnalyzer.cs | 2 +- ...ibutesShouldIncludeExplanationsAnalyzer.cs | 1 + .../Rules/OptimizeLinqUsageAnalyzer.cs | 1 + .../Rules/OptimizeStartsWithAnalyzer.cs | 4 +-- .../OptimizeStringBuilderUsageAnalyzer.cs | 1 + .../OptionalParametersAttributeAnalyzer.cs | 1 + ...meterAttributeForRazorComponentAnalyzer.cs | 1 + ...tractionInsteadOfImplementationAnalyzer.cs | 1 + .../Rules/PreserveParamsOnOverrideAnalyzer.cs | 1 + ...ructorParameterShouldBeReadOnlyAnalyzer.cs | 1 + .../Rules/ProcessStartAnalyzer.cs | 1 + .../Rules/RegexUsageAnalyzerBase.cs | 2 +- .../Rules/RemoveEmptyBlockAnalyzer.cs | 1 + .../Rules/RemoveEmptyStatementAnalyzer.cs | 1 + .../Rules/RemoveUselessToStringAnalyzer.cs | 1 + .../ReplaceEnumToStringWithNameofAnalyzer.cs | 2 +- ...romResultInsteadOfReturningNullAnalyzer.cs | 1 + .../SequenceNumberMustBeAConstantAnalyzer.cs | 1 + ...implifyCallerArgumentExpressionAnalyzer.cs | 1 + ...ntainsNonDeterministicEndOfLineAnalyzer.cs | 1 + .../Rules/TaskInUsingAnalyzer.cs | 2 ++ ...owIfNullWithNonNullableInstanceAnalyzer.cs | 1 + .../TypeNameMustNotMatchNamespaceAnalyzer.cs | 1 + ...xtendSystemApplicationExceptionAnalyzer.cs | 1 + ...verloadThatHasCancellationTokenAnalyzer.cs | 2 +- .../Rules/UseArrayEmptyAnalyzer.cs | 1 + .../Rules/UseConfigureAwaitAnalyzer.cs | 1 + ...ContainsKeyInsteadOfTryGetValueAnalyzer.cs | 1 + .../Rules/UseEventArgsEmptyAnalyzer.cs | 1 + .../Rules/UseEventHandlerOfTAnalyzer.cs | 1 + .../Rules/UseGuidEmptyAnalyzer.cs | 1 + ...IsPatternInsteadOfSequenceEqualAnalyzer.cs | 1 + ...idAsyncWhenReturnValueIsNotUsedAnalyzer.cs | 1 + ...stemInsteadOfRuntimeInformationAnalyzer.cs | 1 + ...nMatchingForEqualityComparisonsAnalyzer.cs | 2 +- ...ernMatchingForEqualityComparisonsCommon.cs | 1 + .../Rules/UseRegexSourceGeneratorAnalyzer.cs | 18 +++++----- ...reateInsteadOfFormattableStringAnalyzer.cs | 1 + .../Rules/UseStringEqualsAnalyzer.cs | 1 + ...eStringEqualsInsteadOfIsPatternAnalyzer.cs | 1 + .../Rules/UseStructLayoutAttributeAnalyzer.cs | 1 + ...temThreadingLockInsteadOfObjectAnalyzer.cs | 1 + .../Rules/UseTaskUnwrapAnalyzer.cs | 1 + .../ValidateArgumentsCorrectlyAnalyzer.cs | 1 + ...ateUnsafeAccessorAttributeUsageAnalyzer.cs | 1 + ...eturnedByStreamReadShouldBeUsedAnalyzer.cs | 1 + .../Suppressors/IDE0058Suppressor.cs | 1 + .../Helpers/DiagnosticResult.cs | 5 ++- .../Helpers/DiagnosticResultLocation.cs | 6 +--- .../Helpers/ProjectBuilder.Validation.cs | 1 + .../Helpers/TargetFramework.cs | 2 +- .../Meziantou.Analyzer.Test.csproj | 8 ++--- ...ddOverloadWithSpanOrMemoryAnalyzerTests.cs | 1 + ...NameShouldEndWithAttributeAnalyzerTests.cs | 1 - ...skBeforeDisposingResourcesAnalyzerTests.cs | 1 + .../Rules/CommaAnalyzerTests.cs | 1 + ...WhenAccessingTheKeyAnalyzerTests_MA0105.cs | 1 + ...WhenAccessingTheKeyAnalyzerTests_MA0106.cs | 1 + ...sShouldExistInConstructorsAnalyzerTests.cs | 1 + ...uldContainValidExpressionsAnalyzerTests.cs | 1 + ...VirtualMethodInConstructorAnalyzerTests.cs | 1 - ...DeclareStaticMembersOnGenericTypesTests.cs | 1 + .../DoNotLogClassifiedDataAnalyzerTests.cs | 1 + ...rwriteRazorComponentParameterValueTests.cs | 1 + ...yncDelegateForSyncDelegateAnalyzerTests.cs | 1 + .../Rules/DoNotUseAsyncVoidAnalyzerTests.cs | 2 +- ...nAsyncContextAnalyzer_AsyncContextTests.cs | 1 + ...tEqualsOnValueTypeAnalyzer_HashSetTests.cs | 2 -- ...lityOperatorsForSpanOfCharAnalyzerTests.cs | 1 + ...itCultureSensitiveToStringAnalyzerTests.cs | 1 + .../DoNotUseToStringIfObjectAnalyzerTests.cs | 1 + ...ParameterForRazorComponentAnalyzerTests.cs | 2 +- ...CorrectlyImplementedAnalyzerMA0094Tests.cs | 1 - ...NameShouldEndWithEventArgsAnalyzerTests.cs | 1 - ...NameShouldEndWithExceptionAnalyzerTests.cs | 1 - ...stNotBeUsedInOnInitializedAnalyzerTests.cs | 1 + ...vokableMethodsMustBePublicAnalyzerTests.cs | 2 +- .../Rules/LoggerParameterTypeAnalyzerTests.cs | 7 ++-- ...oggerParameterTypeAnalyzer_SerilogTests.cs | 1 + .../Rules/MakeMemberReadOnlyAnalyzerTests.cs | 1 + .../MakeMethodStaticAnalyzerTests_Methods.cs | 1 + ...TypeMustHaveTheAsyncSuffixAnalyzerTests.cs | 1 + .../Rules/NamedParameterAnalyzerTests.cs | 1 + .../NullableAttributeUsageAnalyzerTests.cs | 1 - ...bjectGetTypeOnTypeInstanceAnalyzerTests.cs | 1 - ...sShouldIncludeExplanationsAnalyzerTests.cs | 1 - .../OptimizeLinqUsageAnalyzerOrderTests.cs | 1 + ...eLinqUsageAnalyzerUseDirectMethodsTests.cs | 1 + ...ptimizeLinqUsageAnalyzerUseIndexerTests.cs | 1 + .../Rules/OptimizeStartsWithAnalyzerTests.cs | 1 + ...OptimizeStringBuilderUsageAnalyzerTests.cs | 16 +++++---- ...lParametersAttributeAnalyzerMA0088Tests.cs | 1 - ...AttributeForRazorComponentAnalyzerTests.cs | 1 + .../PreserveParamsOnOverrideAnalyzerTests.cs | 1 - .../Rules/ProcessStartAnalyzerTests.cs | 1 - .../Rules/RemoveEmptyBlockAnalyzerTests.cs | 1 - ...laceEnumToStringWithNameofAnalyzerTests.cs | 1 - ...sultInsteadOfReturningNullAnalyzerTests.cs | 1 - ...uenceNumberMustBeAConstantAnalyzerTests.cs | 1 + ...fyCallerArgumentExpressionAnalyzerTests.cs | 1 + ...sNonDeterministicEndOfLineAnalyzerTests.cs | 1 + ...ullWithNonNullableInstanceAnalyzerTests.cs | 1 + ...adThatHasCancellationTokenAnalyzerTests.cs | 2 +- .../Rules/UseConfigureAwaitAnalyzerTests.cs | 1 + .../UseDateTimeUnixEpochAnalyzerTests.cs | 1 + .../Rules/UseIFormatProviderAnalyzerTests.cs | 1 + ...ternInsteadOfSequenceEqualAnalyzerTests.cs | 1 + ...eVoidAsyncWhenReturnValueIsNotUsedTests.cs | 1 + .../UseLangwordInXmlCommentAnalyzerTests.cs | 1 + ...nsteadOfRuntimeInformationAnalyzerTests.cs | 1 + .../Rules/UseRegexOptionsAnalyzerTests.cs | 1 + .../UseRegexSourceGeneratorAnalyzerTests.cs | 1 + .../Rules/UseRegexTimeoutAnalyzerTests.cs | 1 + .../Rules/UseStringComparerAnalyzerTests.cs | 1 + ...parisonAnalyzerNonCultureSensitiveTests.cs | 1 + ...InsteadOfFormattableStringAnalyzerTests.cs | 1 + ...readingLockInsteadOfObjectAnalyzerTests.cs | 1 + .../Rules/UseTaskUnwrapAnalyzerTests.cs | 2 +- ...ValidateArgumentsCorrectlyAnalyzerTests.cs | 1 + ...safeAccessorAttributeUsageAnalyzerTests.cs | 1 + .../CA1822DecoratedMethodSuppressorTests.cs | 3 +- .../Suppressors/IDE0058SuppressorTests.cs | 2 +- 245 files changed, 318 insertions(+), 160 deletions(-) diff --git a/.editorconfig b/.editorconfig index 939fe68d5..60ef73e51 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 61fb4f160..e174c43ee 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 32aa43358..9cc050784 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 91a2345cc..5b8061cc7 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 f97c9d00a..e2ccb5813 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 387f0dc33..a22c3d897 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 64543942b..e8fa82537 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 08b1f09dc..4d308f073 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 f4ad4feb4..cc103432c 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 97adf888a..15d9a9199 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 7ce016000..05507550e 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 f390fdf5f..c125d9db4 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 0b4666a05..fbea59859 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 32c553ead..5a62796e6 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 3b85c56d0..38e9eaccc 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 a55b1a90d..c2b7abbe4 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 46a90bace..b30907044 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 2bc118b8c..d5bf6ae52 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 91bd885ad..bb33b0e11 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 8cdc12399..aadb5961c 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 0bfa3cc2a..61377f1c6 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 a9d71c8f8..1b65d702f 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 e1d3325e0..7723ec7d8 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 3ca5523cd..f120f2ad0 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 4642c669c..c45b71c81 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 b1c9df2d0..2802ed8eb 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 68c51f614..c65422c63 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 72e27ad81..1212d8caf 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 8858abce7..416e70d70 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 95b6cd299..b2b152ba6 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 a32685a83..218771a22 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 698777ddc..d6e93ba25 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 2d0926e2a..e101c81e0 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 20456d6b5..d16eb0c12 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 de1ab61be..1d1803793 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 efa7d87a5..ea8e163af 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 c03d2be01..9cc33dcd1 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 b6ae3c919..58f24c40f 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 45165810a..a8632b95a 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 f40e31440..9caf0d52a 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 ba66016fb..f419ec923 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 33278aae8..b9d7b38c8 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 fd8097847..5d63e67b3 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 79c8e4111..fd123ba4a 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 59ee48702..71c283848 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 5b32d7d03..8d05bac6b 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 6fe4c8975..135b05bf8 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 719ea261f..c9f275f9a 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 292119c22..c9675124b 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 cd9cac8c6..294ab82ed 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 40cee528f..bf5425f5a 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 8fd9fa7b8..8018c5c9c 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 58a6aa576..1dcd71c0e 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 a61d5b5a0..3803d4b48 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 6dec93da6..e18a942c5 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 66d2deef8..ff80e32f6 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 0264027bf..1b3a2b5fa 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 0bf3f4a08..1108f55ed 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 560822268..486dcbf66 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 c59be90e4..805f08058 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 5c1dbf0b4..390a2aae1 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 5af2a633c..077d15fe5 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 4b4553bcf..cfe6041fb 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 8b30fad07..b810da366 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 d425e1065..c7e3e5978 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 986eb3f8e..d0706beb1 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 48bdb9aba..a4e7e39e2 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 cd940b628..e796aff50 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 f12adf669..9fae6e91f 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 f21f2bb15..aa8978e5a 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 d2a756935..90a6f036d 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 dadca7178..c2bd3d39d 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 8ad296aac..558d181c7 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 1041981f6..49b0fbd9d 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 4522d581e..62569dacc 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 883b0aa31..34309c899 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 548f69754..5f9c77a68 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 bcd5c35d9..1fd705f36 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 80fd2c2e7..8050a42f4 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 46fc59ddd..11e6e9fcc 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 98ac2c4b7..14526d800 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 620a07a04..4c4b7da3b 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 ea8d59ea0..1ed5eb93e 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 67dbd9560..2aa76ce43 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 b161d2287..8d39c0674 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 6f11d56bd..ef0e7ceeb 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 e61c11520..5cd2905a8 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 39acea088..3bb56083e 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 1dfca0e31..fc27ac15c 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 bb82d02c2..f6b659bae 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 954ccd8df..14182096a 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 d032d385e..bc7397d69 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 12ea59016..8872aff55 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 966db9f8d..790ed2366 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 fe5145c8a..6cf2a2abe 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 4937cebc6..2627802d9 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 8e3271e87..42e421f28 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 0b5ae0342..02bfe64fa 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 57afc4ab2..692f0ba53 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 f404474a0..f68e1ca8f 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 1ee8a08c7..8ec286227 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 f462f1259..7e641e6c4 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 8a5e7277f..c40b2ef6a 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 b0da9cb39..9ad51062c 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 c70418c8a..644c09771 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 017f65813..189dc00d1 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 78377ffe4..8756ae248 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 df01258dd..f8abf2abd 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 1fc4e1db8..654865924 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 a60942a63..9a637a31b 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 f7a3d3911..bf71d28d7 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 a87d84b8f..c0a463b5a 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 ae65fc596..f9ac25851 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 adc4fa097..c0b0970d2 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 eb5644a61..e8428ad9a 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 39fb4bb12..fed834f4c 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 6386770af..fc6b663a6 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 472d35010..d24fbe85a 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 622db1871..42d6ba15e 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 36249f54b..47cc84e56 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 96499d775..337ba18b5 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 64268e87c..ef8bafb8e 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 867fcee63..c65cfef48 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 9b5f93c84..2c5e573d5 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 0b84e7317..f94214a7e 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 abd0ded3f..5e899157c 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 bc7102bb7..fbe6b2a3c 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 91885047c..704cdaf39 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 f7cb282fa..ea34682b7 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 718aaffd6..cbb6d2d9f 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 02a2559f0..5b55340cc 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 52624fcc8..97a8626b0 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 decee4588..2f9e203c0 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 11e6ae25b..7e7004f5d 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 e489cf963..82d116daf 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 0e83d7de7..4ce5f33ec 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 3fc4d85ff..ffaa65088 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 3b0d20765..1158626e5 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 416529120..129c73900 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 c2c746557..da33d4c78 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 4d5c7006a..156615735 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 da5a741b7..0a0900fd2 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 b76a97726..64c6a17d9 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 689706d18..3d100e1d0 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 0a7a44c40..c5c46c6ed 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 9e1ed763d..65d665803 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 3a5165f6d..4f5bfaf2d 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 807c8715c..f1892f500 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 83c1794b3..3f4390f13 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 0e3dd9f33..500c07b13 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 2b3606d16..7ba4d8acf 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 af1f9dc42..a917e74d7 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 73b3df6f0..01c9c59c4 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 e2a3f550c..dfd16568b 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 8c00549ba..98869c111 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 87773a0f2..4429aad5e 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 db388a7f6..ea9aad65f 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 c9e92de76..a79e4f4ee 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 91231e1b9..45d8ccdc9 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 8c00eeeab..aa414a83c 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 86dbcfdb1..7d4110303 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 b545a76d6..f6ee18eec 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 239b5c8ae..e64e5f5da 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 764934d54..67a128f1e 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 746959b1d..3afab307d 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 e6765b870..038da7407 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 660887266..21b5187b4 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 f04fd3302..25ecc3655 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 0f761df17..1c2a1ac11 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 2fec37d7b..dfbee9bdc 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 b7c7b9611..7a29fd290 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 65315dcd8..e1b6bd662 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 967be2f17..fd8ecd7e7 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 d65c7004e..828bc4738 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 8b3054304..f27d0d859 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 8ff4ca7ac..da5de3b87 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 5e2bdb5cf..df2ba3bfa 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 09b1bf0ec..3450721ac 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 b45c56719..046e34c53 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 1d120d032..c1d9c09c2 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 7ca250fe7..b895b8133 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 cf04c18ce..578f916b3 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 11748e6c9..dfbe3bacf 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 90d633c33..a95a5aaea 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 bbf6c0a1f..fdc649b64 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 7b54fca2e..0a84535a1 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 1be660026..92cce5079 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 d6889b2f5..8d79ec491 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 50efa8bb7..6e569baa9 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 5637855a1..2df1e10bf 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 af0b1d093..71a9716b9 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 858ebde7c..50a14f8b1 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 6c28b187f..e4a0af045 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 3687f82a1..44896853e 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 16b6ef16d..9497fbcfb 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 a172ebf84..7fa46ba4a 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 395391773..182bdf3e8 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 d109ede2e..6955ea2fc 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 4ecd3f437..b8d3bea5a 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 18e13a537..af85b4998 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 91031c98f..cf538ae59 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 82805540e..6b7d51e2f 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 82da47376..2470110e2 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 4a2000820..5725b0d37 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 12f54c5c8..4cbecce6a 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 7165b5131..6df46a6c9 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 0a54b0a26..e95098f9d 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 5beca8a09..0a49c5fe7 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 5ac865d57..680c70532 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 4d8327243..27c88ac7c 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 0bc713fc9..947f01801 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 b0b5d0488..cc0bafdcc 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 b058ff521..483d79a2e 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 7074d5ce6..3144ba2d3 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 EmptyStringsArguments + public static TheoryData EmptyStringsArguments { get { - yield return new object[] { @"$""""" }; - yield return new object[] { @"$""{""""}""" }; - yield return new object[] { @"""""" }; - yield return new object[] { @""""" + """"" }; - yield return new object[] { @"string.Empty" }; + return new TheoryData + { + { @"$""""" }, + { @"$""{""""}""" }, + { @"""""" }, + { @""""" + """"" }, + { @"string.Empty" }, + }; } } diff --git a/tests/Meziantou.Analyzer.Test/Rules/OptionalParametersAttributeAnalyzerMA0088Tests.cs b/tests/Meziantou.Analyzer.Test/Rules/OptionalParametersAttributeAnalyzerMA0088Tests.cs index 2bbbe4f6a..79317ad8d 100644 --- a/tests/Meziantou.Analyzer.Test/Rules/OptionalParametersAttributeAnalyzerMA0088Tests.cs +++ b/tests/Meziantou.Analyzer.Test/Rules/OptionalParametersAttributeAnalyzerMA0088Tests.cs @@ -66,5 +66,4 @@ await CreateProjectBuilder() .WithSourceCode(SourceCode) .ValidateAsync(); } - } diff --git a/tests/Meziantou.Analyzer.Test/Rules/ParameterAttributeForRazorComponentAnalyzerTests.cs b/tests/Meziantou.Analyzer.Test/Rules/ParameterAttributeForRazorComponentAnalyzerTests.cs index 4921f71f9..98be9fc9b 100644 --- a/tests/Meziantou.Analyzer.Test/Rules/ParameterAttributeForRazorComponentAnalyzerTests.cs +++ b/tests/Meziantou.Analyzer.Test/Rules/ParameterAttributeForRazorComponentAnalyzerTests.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/PreserveParamsOnOverrideAnalyzerTests.cs b/tests/Meziantou.Analyzer.Test/Rules/PreserveParamsOnOverrideAnalyzerTests.cs index 9a6ca10c7..85df9fa25 100644 --- a/tests/Meziantou.Analyzer.Test/Rules/PreserveParamsOnOverrideAnalyzerTests.cs +++ b/tests/Meziantou.Analyzer.Test/Rules/PreserveParamsOnOverrideAnalyzerTests.cs @@ -107,5 +107,4 @@ await CreateProjectBuilder() .WithSourceCode(SourceCode) .ValidateAsync(); } - } diff --git a/tests/Meziantou.Analyzer.Test/Rules/ProcessStartAnalyzerTests.cs b/tests/Meziantou.Analyzer.Test/Rules/ProcessStartAnalyzerTests.cs index 2963fbc50..86af3dda2 100644 --- a/tests/Meziantou.Analyzer.Test/Rules/ProcessStartAnalyzerTests.cs +++ b/tests/Meziantou.Analyzer.Test/Rules/ProcessStartAnalyzerTests.cs @@ -140,7 +140,6 @@ await CreateProjectBuilder("MA0163") .ValidateAsync(); } - [Fact] public async Task Process_start_should_report_when_use_shell_execute_is_not_set_and_input_redirected() { diff --git a/tests/Meziantou.Analyzer.Test/Rules/RemoveEmptyBlockAnalyzerTests.cs b/tests/Meziantou.Analyzer.Test/Rules/RemoveEmptyBlockAnalyzerTests.cs index 721a24e19..d3ac9b81e 100644 --- a/tests/Meziantou.Analyzer.Test/Rules/RemoveEmptyBlockAnalyzerTests.cs +++ b/tests/Meziantou.Analyzer.Test/Rules/RemoveEmptyBlockAnalyzerTests.cs @@ -127,7 +127,6 @@ await CreateProjectBuilder() // - [Fact] public async Task EmptyFinallyBlock() { diff --git a/tests/Meziantou.Analyzer.Test/Rules/ReplaceEnumToStringWithNameofAnalyzerTests.cs b/tests/Meziantou.Analyzer.Test/Rules/ReplaceEnumToStringWithNameofAnalyzerTests.cs index 568fb4b84..89521f5f5 100644 --- a/tests/Meziantou.Analyzer.Test/Rules/ReplaceEnumToStringWithNameofAnalyzerTests.cs +++ b/tests/Meziantou.Analyzer.Test/Rules/ReplaceEnumToStringWithNameofAnalyzerTests.cs @@ -216,5 +216,4 @@ await CreateProjectBuilder() .ShouldBatchFixCodeWith(CodeFix) .ValidateAsync(); } - } diff --git a/tests/Meziantou.Analyzer.Test/Rules/ReturnTaskFromResultInsteadOfReturningNullAnalyzerTests.cs b/tests/Meziantou.Analyzer.Test/Rules/ReturnTaskFromResultInsteadOfReturningNullAnalyzerTests.cs index b955cf2e9..beb309f03 100644 --- a/tests/Meziantou.Analyzer.Test/Rules/ReturnTaskFromResultInsteadOfReturningNullAnalyzerTests.cs +++ b/tests/Meziantou.Analyzer.Test/Rules/ReturnTaskFromResultInsteadOfReturningNullAnalyzerTests.cs @@ -219,5 +219,4 @@ await CreateProjectBuilder() .WithSourceCode(SourceCode) .ValidateAsync(); } - } diff --git a/tests/Meziantou.Analyzer.Test/Rules/SequenceNumberMustBeAConstantAnalyzerTests.cs b/tests/Meziantou.Analyzer.Test/Rules/SequenceNumberMustBeAConstantAnalyzerTests.cs index 61d650c5d..2c81091a7 100644 --- a/tests/Meziantou.Analyzer.Test/Rules/SequenceNumberMustBeAConstantAnalyzerTests.cs +++ b/tests/Meziantou.Analyzer.Test/Rules/SequenceNumberMustBeAConstantAnalyzerTests.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/SimplifyCallerArgumentExpressionAnalyzerTests.cs b/tests/Meziantou.Analyzer.Test/Rules/SimplifyCallerArgumentExpressionAnalyzerTests.cs index 0a07e01ca..41892daff 100644 --- a/tests/Meziantou.Analyzer.Test/Rules/SimplifyCallerArgumentExpressionAnalyzerTests.cs +++ b/tests/Meziantou.Analyzer.Test/Rules/SimplifyCallerArgumentExpressionAnalyzerTests.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/StringShouldNotContainsNonDeterministicEndOfLineAnalyzerTests.cs b/tests/Meziantou.Analyzer.Test/Rules/StringShouldNotContainsNonDeterministicEndOfLineAnalyzerTests.cs index 1ae499e9e..9f2ae2d3f 100755 --- a/tests/Meziantou.Analyzer.Test/Rules/StringShouldNotContainsNonDeterministicEndOfLineAnalyzerTests.cs +++ b/tests/Meziantou.Analyzer.Test/Rules/StringShouldNotContainsNonDeterministicEndOfLineAnalyzerTests.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/ThrowIfNullWithNonNullableInstanceAnalyzerTests.cs b/tests/Meziantou.Analyzer.Test/Rules/ThrowIfNullWithNonNullableInstanceAnalyzerTests.cs index 75205e6ea..9c95bb25e 100644 --- a/tests/Meziantou.Analyzer.Test/Rules/ThrowIfNullWithNonNullableInstanceAnalyzerTests.cs +++ b/tests/Meziantou.Analyzer.Test/Rules/ThrowIfNullWithNonNullableInstanceAnalyzerTests.cs @@ -1,5 +1,6 @@ using System.Threading.Tasks; using Meziantou.Analyzer.Rules; +using Meziantou.Analyzer.Test.Helpers; using Microsoft.CodeAnalysis; using TestHelper; using Xunit; diff --git a/tests/Meziantou.Analyzer.Test/Rules/UseAnOverloadThatHasCancellationTokenAnalyzerTests.cs b/tests/Meziantou.Analyzer.Test/Rules/UseAnOverloadThatHasCancellationTokenAnalyzerTests.cs index 17d687e9e..820153610 100644 --- a/tests/Meziantou.Analyzer.Test/Rules/UseAnOverloadThatHasCancellationTokenAnalyzerTests.cs +++ b/tests/Meziantou.Analyzer.Test/Rules/UseAnOverloadThatHasCancellationTokenAnalyzerTests.cs @@ -1,5 +1,6 @@ using System.Threading.Tasks; using Meziantou.Analyzer.Rules; +using Meziantou.Analyzer.Test.Helpers; using TestHelper; using Xunit; @@ -594,7 +595,6 @@ await CreateProjectBuilder() } #endif - #if CSHARP10_OR_GREATER [Fact] public async Task RecordStructCtor_ShouldReportDiagnosticWithProperty() diff --git a/tests/Meziantou.Analyzer.Test/Rules/UseConfigureAwaitAnalyzerTests.cs b/tests/Meziantou.Analyzer.Test/Rules/UseConfigureAwaitAnalyzerTests.cs index 9638fc5be..1aa5d88ba 100644 --- a/tests/Meziantou.Analyzer.Test/Rules/UseConfigureAwaitAnalyzerTests.cs +++ b/tests/Meziantou.Analyzer.Test/Rules/UseConfigureAwaitAnalyzerTests.cs @@ -1,5 +1,6 @@ using System.Threading.Tasks; using Meziantou.Analyzer.Rules; +using Meziantou.Analyzer.Test.Helpers; using Microsoft.CodeAnalysis; using TestHelper; using Xunit; diff --git a/tests/Meziantou.Analyzer.Test/Rules/UseDateTimeUnixEpochAnalyzerTests.cs b/tests/Meziantou.Analyzer.Test/Rules/UseDateTimeUnixEpochAnalyzerTests.cs index 7189cdeaf..0df6798a0 100755 --- a/tests/Meziantou.Analyzer.Test/Rules/UseDateTimeUnixEpochAnalyzerTests.cs +++ b/tests/Meziantou.Analyzer.Test/Rules/UseDateTimeUnixEpochAnalyzerTests.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/UseIFormatProviderAnalyzerTests.cs b/tests/Meziantou.Analyzer.Test/Rules/UseIFormatProviderAnalyzerTests.cs index 052b8235b..5e335e8b7 100755 --- a/tests/Meziantou.Analyzer.Test/Rules/UseIFormatProviderAnalyzerTests.cs +++ b/tests/Meziantou.Analyzer.Test/Rules/UseIFormatProviderAnalyzerTests.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/UseIsPatternInsteadOfSequenceEqualAnalyzerTests.cs b/tests/Meziantou.Analyzer.Test/Rules/UseIsPatternInsteadOfSequenceEqualAnalyzerTests.cs index be4186e45..e700596f3 100644 --- a/tests/Meziantou.Analyzer.Test/Rules/UseIsPatternInsteadOfSequenceEqualAnalyzerTests.cs +++ b/tests/Meziantou.Analyzer.Test/Rules/UseIsPatternInsteadOfSequenceEqualAnalyzerTests.cs @@ -1,6 +1,7 @@ #if CSHARP11_OR_GREATER 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/UseJSRuntimeInvokeVoidAsyncWhenReturnValueIsNotUsedTests.cs b/tests/Meziantou.Analyzer.Test/Rules/UseJSRuntimeInvokeVoidAsyncWhenReturnValueIsNotUsedTests.cs index 7e3a71b7d..99c36b040 100755 --- a/tests/Meziantou.Analyzer.Test/Rules/UseJSRuntimeInvokeVoidAsyncWhenReturnValueIsNotUsedTests.cs +++ b/tests/Meziantou.Analyzer.Test/Rules/UseJSRuntimeInvokeVoidAsyncWhenReturnValueIsNotUsedTests.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/UseLangwordInXmlCommentAnalyzerTests.cs b/tests/Meziantou.Analyzer.Test/Rules/UseLangwordInXmlCommentAnalyzerTests.cs index cfcf9bbfd..c5ce3b1fc 100644 --- a/tests/Meziantou.Analyzer.Test/Rules/UseLangwordInXmlCommentAnalyzerTests.cs +++ b/tests/Meziantou.Analyzer.Test/Rules/UseLangwordInXmlCommentAnalyzerTests.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/UseOperatingSystemInsteadOfRuntimeInformationAnalyzerTests.cs b/tests/Meziantou.Analyzer.Test/Rules/UseOperatingSystemInsteadOfRuntimeInformationAnalyzerTests.cs index 2e47e1c5f..aab1e1a09 100644 --- a/tests/Meziantou.Analyzer.Test/Rules/UseOperatingSystemInsteadOfRuntimeInformationAnalyzerTests.cs +++ b/tests/Meziantou.Analyzer.Test/Rules/UseOperatingSystemInsteadOfRuntimeInformationAnalyzerTests.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/UseRegexOptionsAnalyzerTests.cs b/tests/Meziantou.Analyzer.Test/Rules/UseRegexOptionsAnalyzerTests.cs index c28186f21..250b6a5cc 100644 --- a/tests/Meziantou.Analyzer.Test/Rules/UseRegexOptionsAnalyzerTests.cs +++ b/tests/Meziantou.Analyzer.Test/Rules/UseRegexOptionsAnalyzerTests.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/UseRegexSourceGeneratorAnalyzerTests.cs b/tests/Meziantou.Analyzer.Test/Rules/UseRegexSourceGeneratorAnalyzerTests.cs index 1ab0b7077..c1cb4d3a1 100644 --- a/tests/Meziantou.Analyzer.Test/Rules/UseRegexSourceGeneratorAnalyzerTests.cs +++ b/tests/Meziantou.Analyzer.Test/Rules/UseRegexSourceGeneratorAnalyzerTests.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/UseRegexTimeoutAnalyzerTests.cs b/tests/Meziantou.Analyzer.Test/Rules/UseRegexTimeoutAnalyzerTests.cs index 7b7f2ab0d..eca65067a 100755 --- a/tests/Meziantou.Analyzer.Test/Rules/UseRegexTimeoutAnalyzerTests.cs +++ b/tests/Meziantou.Analyzer.Test/Rules/UseRegexTimeoutAnalyzerTests.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/UseStringComparerAnalyzerTests.cs b/tests/Meziantou.Analyzer.Test/Rules/UseStringComparerAnalyzerTests.cs index c5ad2a7da..14ca7c3b2 100755 --- a/tests/Meziantou.Analyzer.Test/Rules/UseStringComparerAnalyzerTests.cs +++ b/tests/Meziantou.Analyzer.Test/Rules/UseStringComparerAnalyzerTests.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/UseStringComparisonAnalyzerNonCultureSensitiveTests.cs b/tests/Meziantou.Analyzer.Test/Rules/UseStringComparisonAnalyzerNonCultureSensitiveTests.cs index e078333e6..c6d257eda 100755 --- a/tests/Meziantou.Analyzer.Test/Rules/UseStringComparisonAnalyzerNonCultureSensitiveTests.cs +++ b/tests/Meziantou.Analyzer.Test/Rules/UseStringComparisonAnalyzerNonCultureSensitiveTests.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/UseStringCreateInsteadOfFormattableStringAnalyzerTests.cs b/tests/Meziantou.Analyzer.Test/Rules/UseStringCreateInsteadOfFormattableStringAnalyzerTests.cs index 312ac1057..bf44cf3ec 100755 --- a/tests/Meziantou.Analyzer.Test/Rules/UseStringCreateInsteadOfFormattableStringAnalyzerTests.cs +++ b/tests/Meziantou.Analyzer.Test/Rules/UseStringCreateInsteadOfFormattableStringAnalyzerTests.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/UseSystemThreadingLockInsteadOfObjectAnalyzerTests.cs b/tests/Meziantou.Analyzer.Test/Rules/UseSystemThreadingLockInsteadOfObjectAnalyzerTests.cs index 735c9a743..94ed5e3cd 100644 --- a/tests/Meziantou.Analyzer.Test/Rules/UseSystemThreadingLockInsteadOfObjectAnalyzerTests.cs +++ b/tests/Meziantou.Analyzer.Test/Rules/UseSystemThreadingLockInsteadOfObjectAnalyzerTests.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/UseTaskUnwrapAnalyzerTests.cs b/tests/Meziantou.Analyzer.Test/Rules/UseTaskUnwrapAnalyzerTests.cs index a4aa170a2..9b0115259 100755 --- a/tests/Meziantou.Analyzer.Test/Rules/UseTaskUnwrapAnalyzerTests.cs +++ b/tests/Meziantou.Analyzer.Test/Rules/UseTaskUnwrapAnalyzerTests.cs @@ -1,5 +1,6 @@ using System.Threading.Tasks; using Meziantou.Analyzer.Rules; +using Meziantou.Analyzer.Test.Helpers; using TestHelper; using Xunit; @@ -105,5 +106,4 @@ await CreateProjectBuilder() """) .ValidateAsync(); } - } diff --git a/tests/Meziantou.Analyzer.Test/Rules/ValidateArgumentsCorrectlyAnalyzerTests.cs b/tests/Meziantou.Analyzer.Test/Rules/ValidateArgumentsCorrectlyAnalyzerTests.cs index f46dca862..5c5be2c4f 100644 --- a/tests/Meziantou.Analyzer.Test/Rules/ValidateArgumentsCorrectlyAnalyzerTests.cs +++ b/tests/Meziantou.Analyzer.Test/Rules/ValidateArgumentsCorrectlyAnalyzerTests.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/ValidateUnsafeAccessorAttributeUsageAnalyzerTests.cs b/tests/Meziantou.Analyzer.Test/Rules/ValidateUnsafeAccessorAttributeUsageAnalyzerTests.cs index f7ed61d6a..ed2dff7e2 100644 --- a/tests/Meziantou.Analyzer.Test/Rules/ValidateUnsafeAccessorAttributeUsageAnalyzerTests.cs +++ b/tests/Meziantou.Analyzer.Test/Rules/ValidateUnsafeAccessorAttributeUsageAnalyzerTests.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/Suppressors/CA1822DecoratedMethodSuppressorTests.cs b/tests/Meziantou.Analyzer.Test/Suppressors/CA1822DecoratedMethodSuppressorTests.cs index 41a163052..366e6a7a6 100644 --- a/tests/Meziantou.Analyzer.Test/Suppressors/CA1822DecoratedMethodSuppressorTests.cs +++ b/tests/Meziantou.Analyzer.Test/Suppressors/CA1822DecoratedMethodSuppressorTests.cs @@ -1,6 +1,7 @@ #if ROSLYN_4_10_OR_GREATER using System.Threading.Tasks; using Meziantou.Analyzer.Suppressors; +using Meziantou.Analyzer.Test.Helpers; using TestHelper; using Xunit; @@ -66,4 +67,4 @@ internal sealed class Sample .ValidateAsync(); } } -#endif \ No newline at end of file +#endif diff --git a/tests/Meziantou.Analyzer.Test/Suppressors/IDE0058SuppressorTests.cs b/tests/Meziantou.Analyzer.Test/Suppressors/IDE0058SuppressorTests.cs index c6391c860..9764d8d2c 100644 --- a/tests/Meziantou.Analyzer.Test/Suppressors/IDE0058SuppressorTests.cs +++ b/tests/Meziantou.Analyzer.Test/Suppressors/IDE0058SuppressorTests.cs @@ -92,4 +92,4 @@ static void A() """) .ValidateAsync(); } -#endif \ No newline at end of file +#endif