final class · System.Reflection

MethodInfo

public final class MethodInfo : MethodBase

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

Kind
final class
Namespace
System.Reflection
Assembly
System.Core
Access
public, final
Source file
Reflection.ant

Inheritance

Base classes
Any MemberInfo MethodBase MethodInfo

Properties

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).

Methods

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

Private and internal members (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).

Inherited members (12)

Source

MethodInfo as Antril, decompiled from its 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