Check if an ITypeSymbol is a delegate type

How can I check if an ITypeSymbol instance refers to a delegate type (like Action or Func<T>).

I think I can check if the base type is System.Delegate. Is this the correct way to do so or is there a better solution?

Answer

Check its TypeKind:

typeSymbol.TypeKind == TypeKind.Delegate;

Leave a Reply

Your email address will not be published. Required fields are marked *