Table of Contents

Interface IMethod

Namespace
ICSharpCode.Decompiler.TypeSystem
Assembly
ICSharpCode.Decompiler.dll

Represents a method, constructor, destructor or operator.

public interface IMethod : IParameterizedMember, IMember, IEntity, ISymbol, ICompilationProvider, INamedElement
Inherited Members
Extension Methods

Properties

AccessorKind

Gets the kind of accessor this is.

MethodSemanticsAttributes AccessorKind { get; }

Property Value

MethodSemanticsAttributes

AccessorOwner

If this method is an accessor, returns the corresponding property/event. Otherwise, returns null.

IMember? AccessorOwner { get; }

Property Value

IMember

HasBody

Gets whether the method has a body. This property returns false for abstract or extern methods, or for partial methods without implementation.

bool HasBody { get; }

Property Value

bool

IsAccessor

Gets whether the method is a property/event accessor.

bool IsAccessor { get; }

Property Value

bool

IsConstructor

bool IsConstructor { get; }

Property Value

bool

IsDestructor

bool IsDestructor { get; }

Property Value

bool

IsExtensionMethod

bool IsExtensionMethod { get; }

Property Value

bool

IsInitOnly

Gets whether this method may only be called on fresh instances. Used with C# 9 init; property setters.

bool IsInitOnly { get; }

Property Value

bool

IsLocalFunction

bool IsLocalFunction { get; }

Property Value

bool

IsOperator

bool IsOperator { get; }

Property Value

bool

ReducedFrom

If this method is reduced from an extension method or a local function returns the original method, null otherwise. A reduced method doesn't contain the extension method parameter. That means that it has one parameter less than its definition. A local function doesn't contain compiler-generated method parameters at the end.

IMethod? ReducedFrom { get; }

Property Value

IMethod

ReturnTypeIsRefReadOnly

Gets whether the return type is 'ref readonly'.

bool ReturnTypeIsRefReadOnly { get; }

Property Value

bool

ThisIsRefReadOnly

Gets whether the method accepts the 'this' reference as ref readonly. This can be either because the method is C# 8.0 'readonly', or because it is within a C# 7.2 'readonly struct'

bool ThisIsRefReadOnly { get; }

Property Value

bool

TypeArguments

Gets the type arguments passed to this method. If the method is generic but not parameterized yet, this property returns the type parameters, as if the method was parameterized with its own type arguments (void M<T>() { M<T>(); }).

IReadOnlyList<IType> TypeArguments { get; }

Property Value

IReadOnlyList<IType>

TypeParameters

Gets the type parameters of this method; or an empty list if the method is not generic.

IReadOnlyList<ITypeParameter> TypeParameters { get; }

Property Value

IReadOnlyList<ITypeParameter>

Methods

GetReturnTypeAttributes()

Gets the attributes associated with the return type. (e.g. [return: MarshalAs(...)])

IEnumerable<IAttribute> GetReturnTypeAttributes()

Returns

IEnumerable<IAttribute>

Remarks

Does not include inherited attributes.

Specialize(TypeParameterSubstitution)

Specializes this method with the given substitution. If this method is already specialized, the new substitution is composed with the existing substition.

IMethod Specialize(TypeParameterSubstitution substitution)

Parameters

substitution TypeParameterSubstitution

Returns

IMethod