Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/Meziantou.Analyzer/Internals/AwaitableTypes.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System.Collections.Concurrent;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.Operations;

Expand All @@ -6,6 +7,7 @@ internal sealed class AwaitableTypes
{
private readonly INamedTypeSymbol[] _taskOrValueTaskSymbols;
private readonly Compilation _compilation;
private readonly ConcurrentDictionary<ITypeSymbol, bool> _isAwaitableCache = new(SymbolEqualityComparer.Default);

public AwaitableTypes(Compilation compilation)
{
Expand Down Expand Up @@ -80,6 +82,11 @@ public bool IsAwaitable(ITypeSymbol? symbol)
if (symbol is null)
return false;

return _isAwaitableCache.GetOrAdd(symbol, IsAwaitableCore);
}

private bool IsAwaitableCore(ITypeSymbol symbol)
{
if (INotifyCompletionSymbol is null)
return false;

Expand Down
Loading