Skip to content

Commit

Permalink
More consistent callback parameter list formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
stakx committed Aug 7, 2019
1 parent 70030c0 commit 6ed6078
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/Moq/MethodCall.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@

using Moq.Properties;

using TypeNameFormatter;

namespace Moq
{
internal sealed partial class MethodCall : SetupWithOutParameterSupport
Expand Down Expand Up @@ -185,13 +187,14 @@ public void SetCallbackResponse(Delegate callback)
var expectedParamTypes = this.Method.GetParameterTypes();
if (!callback.CompareParameterTypesTo(expectedParamTypes))
{
// TODO: the following won't properly distinguish between `in`, `ref`, and `out` parameters!
var actualParams = callback.GetMethodInfo().GetParameters();
throw new ArgumentException(
string.Format(
CultureInfo.CurrentCulture,
Resources.InvalidCallbackParameterMismatch,
string.Join(",", expectedParamTypes.Select(p => p.Name).ToArray()),
string.Join(",", actualParams.Select(p => p.ParameterType.Name).ToArray())));
string.Join(", ", expectedParamTypes.Select(p => p.GetFormattedName()).ToArray()),
string.Join(", ", actualParams.Select(p => p.ParameterType.GetFormattedName()).ToArray())));
}

if (callback.GetMethodInfo().ReturnType != typeof(void))
Expand Down

0 comments on commit 6ed6078

Please sign in to comment.