IMethodSymbol Interface
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Represents a method or method-like symbol (including constructor, destructor, operator, or property/event accessor).
public interface class IMethodSymbol : IEquatable<Microsoft::CodeAnalysis::ISymbol ^>, Microsoft::CodeAnalysis::ISymbol
public interface IMethodSymbol : IEquatable<Microsoft.CodeAnalysis.ISymbol>, Microsoft.CodeAnalysis.ISymbol
type IMethodSymbol = interface
interface ISymbol
interface IEquatable<ISymbol>
Public Interface IMethodSymbol
Implements IEquatable(Of ISymbol), ISymbol
- Implements
Remarks
This interface is reserved for implementation by its associated APIs. We reserve the right to change it in the future.
Properties
Arity |
Returns the arity of this method, or the number of type parameters it takes. A non-generic method has zero arity. |
AssociatedAnonymousDelegate |
If this method is a Lambda method (MethodKind = MethodKind.LambdaMethod) and there is an anonymous delegate associated with it, returns this delegate. Returns null if the symbol is not a lambda or if it does not have an anonymous delegate associated with it. |
AssociatedSymbol |
Returns a symbol (e.g. property, event, etc.) associated with the method. |
CallingConvention |
The calling convention enum of the method symbol. |
CanBeReferencedByName |
Returns true if this symbol can be referenced by its name in code. (Inherited from ISymbol) |
ConstructedFrom |
Returns the method symbol that this method was constructed from. The resulting method symbol has the same containing type (if any), but has type arguments that are the same as the type parameters (although its containing type might not). |
ContainingAssembly |
Gets the IAssemblySymbol for the containing assembly. Returns null if the symbol is shared across multiple assemblies. (Inherited from ISymbol) |
ContainingModule |
Gets the IModuleSymbol for the containing module. Returns null if the symbol is shared across multiple modules. (Inherited from ISymbol) |
ContainingNamespace |
Gets the INamespaceSymbol for the nearest enclosing namespace. Returns null if the symbol isn't contained in a namespace. (Inherited from ISymbol) |
ContainingSymbol |
Gets the ISymbol for the immediately containing symbol. (Inherited from ISymbol) |
ContainingType |
Gets the INamedTypeSymbol for the containing type. Returns null if the symbol is not contained within a type. (Inherited from ISymbol) |
DeclaredAccessibility |
Gets a Accessibility indicating the declared accessibility for the symbol. Returns NotApplicable if no accessibility is declared. (Inherited from ISymbol) |
DeclaringSyntaxReferences |
Get the syntax node(s) where this symbol was declared in source. Some symbols (for example, partial classes) may be defined in more than one location. This property should return one or more syntax nodes only if the symbol was declared in source code and also was not implicitly declared (see the IsImplicitlyDeclared property). Note that for namespace symbol, the declaring syntax might be declaring a nested namespace. For example, the declaring syntax node for N1 in "namespace N1.N2 {...}" is the entire NamespaceDeclarationSyntax for N1.N2. For the global namespace, the declaring syntax will be the CompilationUnitSyntax. (Inherited from ISymbol) |
ExplicitInterfaceImplementations |
Returns interface methods explicitly implemented by this method. |
HasUnsupportedMetadata |
Indicates that this symbol uses metadata that cannot be supported by the language. Examples include:
This is distinguished from, for example, references to metadata symbols defined in assemblies that weren't referenced. Symbols where this returns true can never be used successfully, and thus should never appear in any IDE feature. This is set for metadata symbols, as follows:
|
HidesBaseMethodsByName |
Returns true if this method hides base methods by name. This cannot be specified directly in the C# language, but can be true for methods defined in other languages imported from metadata. The equivalent of the "hidebyname" flag in metadata. |
IsAbstract |
Gets a value indicating whether the symbol is abstract. (Inherited from ISymbol) |
IsAsync |
Returns true if this method is an async method |
IsCheckedBuiltin |
Returns whether this built-in operator checks for integer overflow. |
IsConditional |
Returns a flag indicating whether this symbol has at least one applied/inherited conditional attribute. |
IsDefinition |
Gets a value indicating whether the symbol is the original definition. Returns false if the symbol is derived from another symbol, by type substitution for instance. (Inherited from ISymbol) |
IsExtensionMethod |
Returns true if this method is an extension method. |
IsExtern |
Gets a value indicating whether the symbol is defined externally. (Inherited from ISymbol) |
IsGenericMethod |
Returns whether this method is generic; i.e., does it have any type parameters? |
IsImplicitlyDeclared |
Returns true if this symbol was automatically created by the compiler, and does not have an explicit corresponding source code declaration. (Inherited from ISymbol) |
IsInitOnly |
Returns true for 'init' set accessors, and false otherwise. |
IsOverride |
Gets a value indicating whether the symbol is an override of a base class symbol. (Inherited from ISymbol) |
IsPartialDefinition |
Return true if this is a partial method definition without a body. If there is an implementing body, it can be retrieved with PartialImplementationPart. |
IsReadOnly |
Indicates whether the method is readonly, i.e. whether the 'this' receiver parameter is 'ref readonly'. Returns true for readonly instance methods and accessors and for reduced extension methods with a 'this in' parameter. |
IsSealed |
Gets a value indicating whether the symbol is sealed. (Inherited from ISymbol) |
IsStatic |
Gets a value indicating whether the symbol is static. (Inherited from ISymbol) |
IsVararg |
Returns whether this method is using CLI VARARG calling convention. This is used for C-style variable argument lists. This is used extremely rarely in C# code and is represented using the undocumented "__arglist" keyword. Note that methods with "params" on the last parameter are indicated with the "IsParams" property on ParameterSymbol, and are not represented with this property. |
IsVirtual |
Gets a value indicating whether the symbol is virtual. (Inherited from ISymbol) |
Kind |
Gets the SymbolKind indicating what kind of symbol it is. (Inherited from ISymbol) |
Language |
Gets the source language ("C#" or "Visual Basic"). (Inherited from ISymbol) |
Locations |
Gets the locations where the symbol was originally defined, either in source or metadata. Some symbols (for example, partial classes) may be defined in more than one location. (Inherited from ISymbol) |
MetadataName |
Gets the name of a symbol as it appears in metadata. Most of the time, this is the same as the Name property, with the following exceptions:
|
MetadataToken |
Gets the metadata token associated with this symbol, or 0 if the symbol is not loaded from metadata. (Inherited from ISymbol) |
MethodImplementationFlags |
Returns the implementation flags for the given method symbol. |
MethodKind |
Gets what kind of method this is. There are several different kinds of things in the C# language that are represented as methods. This property allow distinguishing those things without having to decode the name of the method. |
Name |
Gets the symbol name. Returns the empty string if unnamed. (Inherited from ISymbol) |
OriginalDefinition |
Get the original definition of this symbol. If this symbol is derived from another symbol by (say) type substitution, this gets the original symbol, as it was defined in source or metadata. |
OverriddenMethod |
If this method overrides another method (because it both had the override modifier and there correctly was a method to override), returns the overridden method. |
Parameters |
Gets the parameters of this method. If this method has no parameters, returns an empty list. |
PartialDefinitionPart |
If this is a partial method implementation part, returns the corresponding definition part. Otherwise null. |
PartialImplementationPart |
If this is a partial method declaration without a body, and the method is implemented with a body, returns that implementing definition. Otherwise null. |
ReceiverNullableAnnotation |
If this method can be applied to an object, returns the top-level nullability of the object it is applied to. |
ReceiverType |
If this method can be applied to an object, returns the type of object it is applied to. |
ReducedFrom |
If this method is a reduced extension method, returns the definition of extension method from which this was reduced. Otherwise, returns null. |
RefCustomModifiers |
Custom modifiers associated with the ref modifier, or an empty array if there are none. |
RefKind |
Returns the RefKind of the method. |
ReturnNullableAnnotation |
Gets the top-level nullability of the return type of the method. |
ReturnsByRef |
Returns true if this method returns by reference. |
ReturnsByRefReadonly |
Returns true if this method returns by ref readonly. |
ReturnsVoid |
Returns true if this method has no return type; i.e., returns "void". |
ReturnType |
Gets the return type of the method. |
ReturnTypeCustomModifiers |
Returns the list of custom modifiers, if any, associated with the return type. |
TypeArgumentNullableAnnotations |
Returns the top-level nullability of the type arguments that have been substituted for the type parameters. If nothing has been substituted for a given type parameter, then None is returned. |
TypeArguments |
Returns the type arguments that have been substituted for the type parameters. If nothing has been substituted for a given type parameter, then the type parameter itself is consider the type argument. |
TypeArgumentsNullableAnnotations |
Returns the top-level nullability of the type arguments that have been substituted for the type parameters. If nothing has been substituted for a given type parameter, then NotApplicable is returned. |
TypeParameters |
Get the type parameters on this method. If the method has not generic, returns an empty list. |
UnmanagedCallingConventionTypes |
Modifier types that are considered part of the calling convention of this method, if the MethodKind is FunctionPointerSignature and the CallingConvention is Unmanaged. If this is not a function pointer signature or the calling convention is not unmanaged, this is an empty array. Order and duplication of these modifiers reflect source/metadata order and duplication, whichever this symbol came from. |
Methods
Accept(SymbolVisitor) | (Inherited from ISymbol) |
Accept<TArgument,TResult>(SymbolVisitor<TArgument,TResult>, TArgument) | (Inherited from ISymbol) |
Accept<TResult>(SymbolVisitor<TResult>) | (Inherited from ISymbol) |
Construct(ImmutableArray<ITypeSymbol>, ImmutableArray<NullableAnnotation>) |
Returns a constructed method given its type arguments and type argument nullable annotations. |
Construct(ITypeSymbol[]) |
Returns a constructed method given its type arguments. |
Equals(ISymbol, SymbolEqualityComparer) |
Determines if this symbol is equal to another, according to the rules of the provided SymbolEqualityComparer (Inherited from ISymbol) |
GetAttributes() |
Gets the attributes for the symbol. Returns an empty ImmutableArray<T> if there are no attributes. (Inherited from ISymbol) |
GetDllImportData() |
Platform invoke information, or null if the method isn't a P/Invoke. |
GetDocumentationCommentId() |
Returns the Documentation Comment ID for the symbol, or null if the symbol doesn't support documentation comments. (Inherited from ISymbol) |
GetDocumentationCommentXml(CultureInfo, Boolean, CancellationToken) |
Gets the XML (as text) for the comment associated with the symbol. (Inherited from ISymbol) |
GetReturnTypeAttributes() |
Returns the list of custom attributes, if any, associated with the returned value. |
GetTypeInferredDuringReduction(ITypeParameterSymbol) |
If this method is a reduced extension method, returns a type inferred during reduction process for the type parameter. |
ReduceExtensionMethod(ITypeSymbol) |
If this is an extension method that can be applied to a receiver of the given type, returns a reduced extension method symbol thus formed. Otherwise, returns null. |
ToDisplayParts(SymbolDisplayFormat) |
Convert a symbol to an array of string parts, each of which has a kind. Useful for colorizing the display string. (Inherited from ISymbol) |
ToDisplayString(SymbolDisplayFormat) |
Converts the symbol to a string representation. (Inherited from ISymbol) |
ToMinimalDisplayParts(SemanticModel, Int32, SymbolDisplayFormat) |
Convert a symbol to an array of string parts, each of which has a kind. May be tailored to a specific location in the source code. Useful for colorizing the display string. (Inherited from ISymbol) |
ToMinimalDisplayString(SemanticModel, Int32, SymbolDisplayFormat) |
Convert a symbol to a string that can be displayed to the user. May be tailored to a specific location in the source code. (Inherited from ISymbol) |
Extension Methods
GetConstructedReducedFrom(IMethodSymbol) |
Returns the constructed form of the ReducedFrom property, including the type arguments that were either inferred during reduction or supplied at the call site. |
HandledEvents(IMethodSymbol) | |
IsMustOverride(ISymbol) | |
IsNotOverridable(ISymbol) | |
IsOverloads(IMethodSymbol) | |
IsOverridable(ISymbol) | |
IsOverrides(ISymbol) | |
IsShared(ISymbol) |
Determines if symbol is Shared. |