// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System.Collections.Immutable;
using Microsoft.CodeAnalysis.Text;
namespace Microsoft.CodeAnalysis
{
///
/// Represents a method or method-like symbol (including constructor,
/// destructor, operator, or property/event accessor).
///
///
/// This interface is reserved for implementation by its associated APIs. We reserve the right to
/// change it in the future.
///
public interface IMethodSymbol : ISymbol
{
///
/// 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.
///
MethodKind MethodKind { get; }
///
/// Returns the arity of this method, or the number of type parameters it takes.
/// A non-generic method has zero arity.
///
int Arity { get; }
///
/// Returns whether this method is generic; i.e., does it have any type parameters?
///
bool IsGenericMethod { get; }
///
/// Returns true if this method is an extension method.
///
bool IsExtensionMethod { get; }
///
/// Returns true if this method is an async method
///
bool IsAsync { get; }
///
/// 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.
///
bool IsVararg { get; }
///
/// Returns whether this built-in operator checks for integer overflow.
///
bool IsCheckedBuiltin { get; }
///
/// 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.
///
bool HidesBaseMethodsByName { get; }
///
/// Returns true if this method has no return type; i.e., returns "void".
///
bool ReturnsVoid { get; }
///
/// Returns true if this method returns by reference.
///
bool ReturnsByRef { get; }
///
/// Returns true if this method returns by ref readonly.
///
bool ReturnsByRefReadonly { get; }
///
/// Returns the RefKind of the method.
///
RefKind RefKind { get; }
///
/// Gets the return type of the method.
///
ITypeSymbol ReturnType { get; }
///
/// 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.
///
ImmutableArray TypeArguments { get; }
///
/// Get the type parameters on this method. If the method has not generic,
/// returns an empty list.
///
ImmutableArray TypeParameters { get; }
///
/// Gets the parameters of this method. If this method has no parameters, returns
/// an empty list.
///
ImmutableArray Parameters { get; }
///
/// 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).
///
IMethodSymbol ConstructedFrom { get; }
///
/// 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.
///
new IMethodSymbol OriginalDefinition { get; }
///
/// 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.
///
IMethodSymbol OverriddenMethod { get; }
///
/// If this method can be applied to an object, returns the type of object it is applied to.
///
ITypeSymbol ReceiverType { get; }
///
/// If this method is a reduced extension method, returns the definition of extension
/// method from which this was reduced. Otherwise, returns null.
///
IMethodSymbol ReducedFrom { get; }
///
/// If this method is a reduced extension method, returns a type inferred during reduction process for the type parameter.
///
/// Type parameter of the corresponding method.
/// Inferred type or Nothing if nothing was inferred.
/// If this is not a reduced extension method.
/// If is null.
/// If doesn't belong to the corresponding method.
ITypeSymbol GetTypeInferredDuringReduction(ITypeParameterSymbol reducedFromTypeParameter);
///
/// 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.
///
IMethodSymbol ReduceExtensionMethod(ITypeSymbol receiverType);
///
/// Returns interface methods explicitly implemented by this method.
///
///
/// Methods imported from metadata can explicitly implement more than one method,
/// that is why return type is ImmutableArray.
///
ImmutableArray ExplicitInterfaceImplementations { get; }
///
/// Returns the list of custom modifiers, if any, associated with the return type.
///
ImmutableArray ReturnTypeCustomModifiers { get; }
///
/// Custom modifiers associated with the ref modifier, or an empty array if there are none.
///
ImmutableArray RefCustomModifiers { get; }
///
/// Returns the list of custom attributes, if any, associated with the returned value.
///
ImmutableArray GetReturnTypeAttributes();
///
/// Returns a symbol (e.g. property, event, etc.) associated with the method.
///
///
/// If this method has of or ,
/// returns the property that this method is the getter or setter for.
/// If this method has of or ,
/// returns the event that this method is the adder or remover for.
/// Note, the set of possible associated symbols might be expanded in the future to
/// reflect changes in the languages.
///
ISymbol AssociatedSymbol { get; }
///
/// Returns a constructed method given its type arguments.
///
/// The immediate type arguments to be replaced for type
/// parameters in the method.
IMethodSymbol Construct(params ITypeSymbol[] typeArguments);
///
/// If this is a partial method implementation part, returns the corresponding
/// definition part. Otherwise null.
///
IMethodSymbol PartialDefinitionPart { get; }
///
/// If this is a partial method declaration without a body, and the method is
/// implemented with a body, returns that implementing definition. Otherwise
/// null.
///
IMethodSymbol PartialImplementationPart { get; }
///
/// Platform invoke information, or null if the method isn't a P/Invoke.
///
DllImportData GetDllImportData();
///
/// 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.
///
INamedTypeSymbol AssociatedAnonymousDelegate { get; }
}
}