Skip to main content

SymbolExtensions Class

Namespace: Roslynator

Assembly: Roslynator.Core.dll

A set of extension methods for ISymbol and its derived types.

public static class SymbolExtensions

Methods

MethodSummary
BaseTypes(ITypeSymbol)Gets a list of base types of this type.
BaseTypesAndSelf(ITypeSymbol)Gets a list of base types of this type (including this type).
EqualsOrInheritsFrom(ITypeSymbol, ITypeSymbol, Boolean)Returns true if the type is equal or inherits from a specified base type.
EqualsOrInheritsFrom(ITypeSymbol, MetadataName, Boolean)Returns true if the type is equal or inherits from a type with the specified name.
FindMember<TSymbol>(INamedTypeSymbol, Func<TSymbol, Boolean>, Boolean)Searches for a member that matches the conditions defined by the specified predicate and returns the first occurrence within the type's members.
FindMember<TSymbol>(INamedTypeSymbol, String, Func<TSymbol, Boolean>, Boolean)Searches for a member that has the specified name and matches the conditions defined by the specified predicate, if any, and returns the first occurrence within the type's members.
FindMember<TSymbol>(ITypeSymbol, Func<TSymbol, Boolean>)Searches for a member that matches the conditions defined by the specified predicate, if any, and returns the first occurrence within the type's members.
FindMember<TSymbol>(ITypeSymbol, String, Func<TSymbol, Boolean>)Searches for a member that has the specified name and matches the conditions defined by the specified predicate, if any, and returns the first occurrence within the type's members.
FindTypeMember(INamedTypeSymbol, Func<INamedTypeSymbol, Boolean>, Boolean)Searches for a type member that matches the conditions defined by the specified predicate and returns the first occurrence within the type's members.
FindTypeMember(INamedTypeSymbol, String, Func<INamedTypeSymbol, Boolean>, Boolean)Searches for a type member that has the specified name and matches the conditions defined by the specified predicate, if any, and returns the first occurrence within the type's members.
FindTypeMember(INamedTypeSymbol, String, Int32, Func<INamedTypeSymbol, Boolean>, Boolean)Searches for a type member that has the specified name, arity and matches the conditions defined by the specified predicate, if any, and returns the first occurrence within the type's members.
GetAttribute(ISymbol, INamedTypeSymbol)Returns the attribute for the symbol that matches the specified attribute class, or null if the symbol does not have the specified attribute.
GetAttribute(ISymbol, MetadataName)Returns the attribute for the symbol that matches the specified name, or null if the symbol does not have the specified attribute.
HasAttribute(ISymbol, INamedTypeSymbol)Returns true if the symbol has the specified attribute.
HasAttribute(ISymbol, MetadataName)Returns true if the symbol has attribute with the specified name.
HasAttribute(ITypeSymbol, INamedTypeSymbol, Boolean)Returns true if the type symbol has the specified attribute.
HasAttribute(ITypeSymbol, MetadataName, Boolean)Returns true if the type symbol has attribute with the specified name.
HasConstantValue(IFieldSymbol, Boolean)Get a value indicating whether the field symbol has specified constant value.
HasConstantValue(IFieldSymbol, Byte)Get a value indicating whether the field symbol has specified constant value.
HasConstantValue(IFieldSymbol, Char)Get a value indicating whether the field symbol has specified constant value.
HasConstantValue(IFieldSymbol, Decimal)Get a value indicating whether the field symbol has specified constant value.
HasConstantValue(IFieldSymbol, Double)Get a value indicating whether the field symbol has specified constant value.
HasConstantValue(IFieldSymbol, Int16)Get a value indicating whether the field symbol has specified constant value.
HasConstantValue(IFieldSymbol, Int32)Get a value indicating whether the field symbol has specified constant value.
HasConstantValue(IFieldSymbol, Int64)Get a value indicating whether the field symbol has specified constant value.
HasConstantValue(IFieldSymbol, SByte)Get a value indicating whether the field symbol has specified constant value.
HasConstantValue(IFieldSymbol, Single)Get a value indicating whether the field symbol has specified constant value.
HasConstantValue(IFieldSymbol, String)Get a value indicating whether the field symbol has specified constant value.
HasConstantValue(IFieldSymbol, UInt16)Get a value indicating whether the field symbol has specified constant value.
HasConstantValue(IFieldSymbol, UInt32)Get a value indicating whether the field symbol has specified constant value.
HasConstantValue(IFieldSymbol, UInt64)Get a value indicating whether the field symbol has specified constant value.
HasMetadataName(ISymbol, MetadataName)Returns true if a symbol has the specified MetadataName.
Implements(ITypeSymbol, INamedTypeSymbol, Boolean)Returns true if the type implements specified interface.
Implements(ITypeSymbol, MetadataName, Boolean)Returns true if the type implements specified interface name.
Implements(ITypeSymbol, SpecialType, Boolean)Returns true if the type implements specified interface.
ImplementsAny(ITypeSymbol, SpecialType, SpecialType, Boolean)Returns true if the type implements any of specified interfaces.
ImplementsAny(ITypeSymbol, SpecialType, SpecialType, SpecialType, Boolean)Returns true if the type implements any of specified interfaces.
ImplementsInterfaceMember(ISymbol, Boolean)Returns true if the symbol implements any interface member.
ImplementsInterfaceMember(ISymbol, INamedTypeSymbol, Boolean)Returns true if the symbol implements any member of the specified interface.
ImplementsInterfaceMember<TSymbol>(ISymbol, Boolean)Returns true if the symbol implements any interface member.
ImplementsInterfaceMember<TSymbol>(ISymbol, INamedTypeSymbol, Boolean)Returns true if the symbol implements any member of the specified interface.
InheritsFrom(ITypeSymbol, ITypeSymbol, Boolean)Returns true if the type inherits from a specified base type.
InheritsFrom(ITypeSymbol, MetadataName, Boolean)Returns true if the type inherits from a type with the specified name.
IsAsyncMethod(ISymbol)Returns true if the symbol is an async method.
IsErrorType(ISymbol)Returns true if the symbol represents an error.
IsIEnumerableOfT(ITypeSymbol)Returns true if the type is IEnumerable<T>.
IsIEnumerableOrIEnumerableOfT(ITypeSymbol)Returns true if the type is IEnumerable or IEnumerable<T>.
IsKind(ISymbol, SymbolKind, SymbolKind, SymbolKind, SymbolKind, SymbolKind)Returns true if the symbol is one of the specified kinds.
IsKind(ISymbol, SymbolKind, SymbolKind, SymbolKind, SymbolKind)Returns true if the symbol is one of the specified kinds.
IsKind(ISymbol, SymbolKind, SymbolKind, SymbolKind)Returns true if the symbol is one of the specified kinds.
IsKind(ISymbol, SymbolKind, SymbolKind)Returns true if the symbol is one of the specified kinds.
IsKind(ISymbol, SymbolKind)Returns true if the symbol is the specified kind.
IsNullableOf(INamedTypeSymbol, ITypeSymbol)Returns true if the type is Nullable<T> and it has specified type argument.
IsNullableOf(INamedTypeSymbol, SpecialType)Returns true if the type is Nullable<T> and it has specified type argument.
IsNullableOf(ITypeSymbol, ITypeSymbol)Returns true if the type is Nullable<T> and it has specified type argument.
IsNullableOf(ITypeSymbol, SpecialType)Returns true if the type is Nullable<T> and it has specified type argument.
IsNullableType(ITypeSymbol)Returns true if the type is a nullable type.
IsObject(ITypeSymbol)Returns true if the type is Object.
IsOrdinaryExtensionMethod(IMethodSymbol)Returns true if this method is an ordinary extension method (i.e. "this" parameter has not been removed).
IsParameterArrayOf(IParameterSymbol, SpecialType, SpecialType, SpecialType)Returns true if the parameter was declared as a parameter array that has one of specified element types.
IsParameterArrayOf(IParameterSymbol, SpecialType, SpecialType)Returns true if the parameter was declared as a parameter array that has one of specified element types.
IsParameterArrayOf(IParameterSymbol, SpecialType)Returns true if the parameter was declared as a parameter array that has a specified element type.
IsPubliclyVisible(ISymbol)Return true if the specified symbol is publicly visible.
IsReducedExtensionMethod(IMethodSymbol)Returns true if this method is a reduced extension method.
IsReferenceTypeOrNullableType(ITypeSymbol)Returns true if the type is a reference type or a nullable type.
IsRefOrOut(IParameterSymbol)Returns true if the parameter was declared as "ref" or "out" parameter.
IsString(ITypeSymbol)Returns true if the type is String.
IsVoid(ITypeSymbol)Returns true if the type is Void.
ReducedFromOrSelf(IMethodSymbol)If this method is a reduced extension method, returns the definition of extension method from which this was reduced. Otherwise, returns this symbol.
SupportsExplicitDeclaration(ITypeSymbol)Returns true if the type can be declared explicitly in a source code.