/// <summary> /// Initialize a new instance of <see cref="MethodDescriptor"/> class. /// </summary> /// <param name="runtimeMethodHandle">The <see cref="System.RuntimeMethodHandle"/> of the <see cref="MethodBase"/> to wrap.</param> internal MethodDescriptor(RuntimeMethodHandle runtimeMethodHandle) { var method = MethodBase.GetMethodFromHandle(runtimeMethodHandle); if (TypeExtensions.IsPropertyMethod(method)) { //Dont throw for indexer properties //TODO: hack should be a better way of doing this if ((method.Name != "get_Item") && !method.Name.StartsWith("set_Item")) { throw new ArgumentException("Creating a MethodDescriptor for a property is not supported.", "runtimeMethodHandle"); } } Parameters = new ParameterCollection(this); RuntimeMethodHandle = runtimeMethodHandle; Name = method.Name; IsStatic = method.IsStatic; AppendParameters(method); ProcessInterfaces(method); ProcessBaseMethods(method); Parameters.SetToReadOnly(); }