From 988fbefd8a8cde64bce97e4ed917d967ac85b26a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A9rald=20Barr=C3=A9?= Date: Sun, 23 Oct 2022 11:58:35 -0400 Subject: [PATCH] Remove unused usings --- .../Internals/StringExtensions.cs | 16 ++++------------ ...DoNotUseBlockingCallInAsyncContextAnalyzer.cs | 1 - .../EqualityShouldBeCorrectlyImplementedFixer.cs | 2 +- .../ReplaceEnumToStringWithNameofAnalyzer.cs | 5 ++++- .../Rules/ReplaceEnumToStringWithNameofFixer.cs | 4 ++++ 5 files changed, 13 insertions(+), 15 deletions(-) diff --git a/src/Meziantou.Analyzer/Internals/StringExtensions.cs b/src/Meziantou.Analyzer/Internals/StringExtensions.cs index 385e9a3a8..53b5b5141 100644 --- a/src/Meziantou.Analyzer/Internals/StringExtensions.cs +++ b/src/Meziantou.Analyzer/Internals/StringExtensions.cs @@ -1,7 +1,10 @@ using System; -using System.Diagnostics.CodeAnalysis; using System.Runtime.InteropServices; +#if NETSTANDARD2_0 +using System.Diagnostics.CodeAnalysis; +#endif + namespace Meziantou.Analyzer.Rules; internal static partial class StringExtensions @@ -57,17 +60,6 @@ public bool MoveNext() var span = _str; var index = span.IndexOfAny('\r', '\n'); - /* Unmerged change from project 'Meziantou.Analyzer (netstandard2.0)' - Before: - if (index == -1) - { - _str = ReadOnlySpan.Empty; - After: - if (index == -1) - { - _str = ReadOnlySpan.Empty; - */ - if (index == -1) { _str = ReadOnlySpan.Empty; diff --git a/src/Meziantou.Analyzer/Rules/DoNotUseBlockingCallInAsyncContextAnalyzer.cs b/src/Meziantou.Analyzer/Rules/DoNotUseBlockingCallInAsyncContextAnalyzer.cs index f9f45a4cd..f76ff32c6 100644 --- a/src/Meziantou.Analyzer/Rules/DoNotUseBlockingCallInAsyncContextAnalyzer.cs +++ b/src/Meziantou.Analyzer/Rules/DoNotUseBlockingCallInAsyncContextAnalyzer.cs @@ -1,5 +1,4 @@ using System; -using System.Collections.Concurrent; using System.Collections.Generic; using System.Collections.Immutable; using System.Diagnostics.CodeAnalysis; diff --git a/src/Meziantou.Analyzer/Rules/EqualityShouldBeCorrectlyImplementedFixer.cs b/src/Meziantou.Analyzer/Rules/EqualityShouldBeCorrectlyImplementedFixer.cs index b3697c5d2..0c2701ade 100644 --- a/src/Meziantou.Analyzer/Rules/EqualityShouldBeCorrectlyImplementedFixer.cs +++ b/src/Meziantou.Analyzer/Rules/EqualityShouldBeCorrectlyImplementedFixer.cs @@ -46,7 +46,7 @@ private static async Task ImplementIEquatable(Document document, Synta return document; // Retrieve Nullable Annotation from the Equals method and use it to construct the concrete interface - var equalsMethod = declaredTypeSymbol.GetMembers().OfType().Where(m => IsEqualsOfTMethod(m)).SingleOrDefault(m => m != null); + var equalsMethod = declaredTypeSymbol.GetMembers().OfType().SingleOrDefault(m => IsEqualsOfTMethod(m) && m != null); if (equalsMethod is null) return document; diff --git a/src/Meziantou.Analyzer/Rules/ReplaceEnumToStringWithNameofAnalyzer.cs b/src/Meziantou.Analyzer/Rules/ReplaceEnumToStringWithNameofAnalyzer.cs index 57b02c6d5..27383a9b2 100644 --- a/src/Meziantou.Analyzer/Rules/ReplaceEnumToStringWithNameofAnalyzer.cs +++ b/src/Meziantou.Analyzer/Rules/ReplaceEnumToStringWithNameofAnalyzer.cs @@ -1,9 +1,12 @@ using System.Collections.Immutable; -using System.Linq; using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.Diagnostics; using Microsoft.CodeAnalysis.Operations; +#if ROSLYN3 +using System.Linq; +#endif + namespace Meziantou.Analyzer.Rules; [DiagnosticAnalyzer(LanguageNames.CSharp)] diff --git a/src/Meziantou.Analyzer/Rules/ReplaceEnumToStringWithNameofFixer.cs b/src/Meziantou.Analyzer/Rules/ReplaceEnumToStringWithNameofFixer.cs index 359e245eb..4bd72bffe 100644 --- a/src/Meziantou.Analyzer/Rules/ReplaceEnumToStringWithNameofFixer.cs +++ b/src/Meziantou.Analyzer/Rules/ReplaceEnumToStringWithNameofFixer.cs @@ -8,6 +8,10 @@ using Microsoft.CodeAnalysis.Editing; using Microsoft.CodeAnalysis.Operations; +#if ROSLYN3 +using System.Linq; +#endif + namespace Meziantou.Analyzer.Rules; [ExportCodeFixProvider(LanguageNames.CSharp), Shared]