Skip to content

Commit

Permalink
Improve detection for ToString case in MA0028
Browse files Browse the repository at this point in the history
  • Loading branch information
meziantou committed Jul 31, 2024
1 parent 3073490 commit 423b37f
Show file tree
Hide file tree
Showing 4 changed files with 271 additions and 169 deletions.
13 changes: 13 additions & 0 deletions src/Meziantou.Analyzer/Internals/HashSetExtensions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
using System.Collections.Generic;

namespace Meziantou.Analyzer.Internals;
internal static class HashSetExtensions
{
public static void AddIfNotNull<T>(this HashSet<T> hashSet, T? item)
{
if (item is null)
return;

_ = hashSet.Add(item);
}
}
2 changes: 1 addition & 1 deletion src/Meziantou.Analyzer/Internals/SymbolExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ namespace Meziantou.Analyzer;

internal static class SymbolExtensions
{
public static bool IsEqualTo(this ISymbol? symbol, ISymbol? expectedType)
public static bool IsEqualTo(this ISymbol? symbol, [NotNullWhen(true)] ISymbol? expectedType)
{
if (symbol is null || expectedType is null)
return false;
Expand Down
Loading

0 comments on commit 423b37f

Please sign in to comment.