Address review comments

This commit is contained in:
Jon Skeet 2018-03-27 10:16:53 +01:00
parent 7b19d20882
commit 9c05c35341

View File

@ -56,32 +56,40 @@ namespace Google.Protobuf.Reflection
internal static readonly Type[] EmptyTypes = new Type[0]; internal static readonly Type[] EmptyTypes = new Type[0];
/// <summary> /// <summary>
/// Creates a delegate which will cast the argument to the appropriate method target type, /// Creates a delegate which will cast the argument to the type that declares the method,
/// call the method on it, then convert the result to object. /// call the method on it, then convert the result to object.
/// </summary> /// </summary>
/// <param name="method">The method to create a delegate for, which must be declared in an IMessage
/// implementation.</param>
internal static Func<IMessage, object> CreateFuncIMessageObject(MethodInfo method) => internal static Func<IMessage, object> CreateFuncIMessageObject(MethodInfo method) =>
GetReflectionHelper(method.DeclaringType, method.ReturnType).CreateFuncIMessageObject(method); GetReflectionHelper(method.DeclaringType, method.ReturnType).CreateFuncIMessageObject(method);
/// <summary> /// <summary>
/// Creates a delegate which will cast the argument to the appropriate method target type, /// Creates a delegate which will cast the argument to the type that declares the method,
/// call the method on it, then convert the result to the specified type. The method is expected /// call the method on it, then convert the result to the specified type. The method is expected
/// to actually return an enum (because of where we're calling it - for oneof cases). Sometimes that /// to actually return an enum (because of where we're calling it - for oneof cases). Sometimes that
/// means we need some extra work to perform conversions. /// means we need some extra work to perform conversions.
/// </summary> /// </summary>
/// <param name="method">The method to create a delegate for, which must be declared in an IMessage
/// implementation.</param>
internal static Func<IMessage, int> CreateFuncIMessageInt32(MethodInfo method) => internal static Func<IMessage, int> CreateFuncIMessageInt32(MethodInfo method) =>
GetReflectionHelper(method.DeclaringType, method.ReturnType).CreateFuncIMessageInt32(method); GetReflectionHelper(method.DeclaringType, method.ReturnType).CreateFuncIMessageInt32(method);
/// <summary> /// <summary>
/// Creates a delegate which will execute the given method after casting the first argument to /// Creates a delegate which will execute the given method after casting the first argument to
/// the target type of the method, and the second argument to the first parameter type of the method. /// the type that declares the method, and the second argument to the first parameter type of the method.
/// </summary> /// </summary>
/// <param name="method">The method to create a delegate for, which must be declared in an IMessage
/// implementation.</param>
internal static Action<IMessage, object> CreateActionIMessageObject(MethodInfo method) => internal static Action<IMessage, object> CreateActionIMessageObject(MethodInfo method) =>
GetReflectionHelper(method.DeclaringType, method.GetParameters()[0].ParameterType).CreateActionIMessageObject(method); GetReflectionHelper(method.DeclaringType, method.GetParameters()[0].ParameterType).CreateActionIMessageObject(method);
/// <summary> /// <summary>
/// Creates a delegate which will execute the given method after casting the first argument to /// Creates a delegate which will execute the given method after casting the first argument to
/// the target type of the method. /// type that declares the method.
/// </summary> /// </summary>
/// <param name="method">The method to create a delegate for, which must be declared in an IMessage
/// implementation.</param>
internal static Action<IMessage> CreateActionIMessage(MethodInfo method) => internal static Action<IMessage> CreateActionIMessage(MethodInfo method) =>
GetReflectionHelper(method.DeclaringType, typeof(object)).CreateActionIMessage(method); GetReflectionHelper(method.DeclaringType, typeof(object)).CreateActionIMessage(method);