final class · System.Reflection

MethodInfo

public final class MethodInfo : MethodBase

A method: its result type, and calls through Invoke(target, arguments).

Tipo
final class
Espacio de nombres
System.Reflection
Ensamblado
System.Core
Acceso
public, final
Archivo fuente
Reflection.ant

Herencia

Clases base
Any MemberInfo MethodBase MethodInfo

Propiedades

Type ReturnType { get; }
#

read-only

bool IsVirtual { get; }
#

read-only

bool IsAbstract { get; }
#

read-only

bool IsGenericMethod { get; }
#

read-only

A method with its own type parameters (it cannot be called through Invoke).

Métodos

Invoke(any? target, any?[] arguments) : any?
#

Calls the method on target (null for a static method) with arguments: its result, boxed (null for none).

override ToString() : str
#

override

Miembros privados e internos (3)

readonly Type returnType
#

private

new(Type declaring, str name, i32 flags, TypeDescriber describer, i32 index, Type returnType, ParameterInfo[] parameters)
#

internal

SameAs(MethodInfo other) : bool
#

internal

Whether other is the same method seen from a class below (an override).

Miembros heredados (12)

Código fuente

MethodInfo en Antril, descompilado a partir de su Larva HIR.

System.Reflection.MethodInfo.ant
// System.Reflection.MethodInfo — System.Core (decompiled from Larva HIR)

import System;

into namespace System.Reflection
{
	/// A method: its result type, and calls through `Invoke(target, arguments)`.
	public final class MethodInfo : MethodBase
	{
		readonly Type returnType;

		internal:
			new(Type declaring, str name, i32 flags, TypeDescriber describer, i32 index, Type returnType, ParameterInfo[] parameters) : base(declaring, name, flags, describer, index, parameters)
			{
				this.returnType = returnType;
			}

			/// Whether `other` is the same method seen from a class below (an override).
			SameAs(MethodInfo other) : bool
			{
				if (other.Name != Name || other.GetParameters().Length != GetParameters().Length)
					return false;
				loop (i32 i = 0..GetParameters().Length)
				{
					if (other.GetParameters()[i].ParameterType != GetParameters()[i].ParameterType)
						return false;
				}
				return true;
			}

		public:
			/// Calls the method on `target` (null for a static method) with `arguments`: its result, boxed (null for none).
			Invoke(any? target, any?[] arguments) : any?
			{
				Check(arguments);
				if (IsGenericMethod)
					throw new NotSupportedError(Name + " has type parameters: it cannot be called through reflection");
				return Describer.Invoke(Index, target, arguments);
			}

			override ToString() : str => returnType.FullName + " " + Name + "(" + Parameters.Text(GetParameters()) + ")";

			Type ReturnType
			{
				get => returnType;
			}

			bool IsVirtual
			{
				get => Has(4);
			}

			bool IsAbstract
			{
				get => Has(8);
			}

			/// A method with its own type parameters (it cannot be called through Invoke).
			bool IsGenericMethod
			{
				get => Has(32);
			}
	}
}
Esc