using System.Diagnostics.Contracts; using System.Linq; using System.Reflection; namespace ComputeSharp.Core.Extensions { /// /// A that provides extension methods for the type. /// internal static class MethodInfoExtensions { /// /// Gets a fully qualified name for the input method, including parameters. /// /// The input instance. /// A fully qualified name for , including parameters. [Pure] public static string GetFullName(this MethodInfo method) { var parameters = string.Join(", ", method.GetParameters().Select(static p => p.ParameterType.FullName)); if (method.IsGenericMethod) { var arguments = string.Join(", ", method.GetGenericArguments().Select(static t => t.FullName)); return $"{method.DeclaringType!.FullName}.{method.Name}<{arguments}>({parameters})"; } return $"{method.DeclaringType!.FullName}.{method.Name}({parameters})"; } } }