Detect body parameter to implement #89

Nope, I was the slow one and already fixed it; the PR is updated ☺

From: Bennor McCarthy [mailto:notifications@github.com]
Sent: Friday, December 19, 2014 6:08 PM
To: paulcbetts/refit
Cc: Oren Novotny
Subject: Re: [refit] Detect body parameter to implement #89 (#102)


In Refit/RequestBuilderImplementation.cs<https://github.com/paulcbetts/refit/pull/102#discussion-diff-22134905>:

> @@ -423,12 +430,32 @@ string getUrlNameForParameter(ParameterInfo paramInfo)

>                  throw new ArgumentException("Only one parameter can be a Body parameter");

>              }

>

> +            // #1, body attribute wins

> +            if (bodyParams.Count == 1)

> +            {

> +                var ret = bodyParams[0];

> +                return Tuple.Create(ret.BodyAttribute.SerializationMethod, parameterList.IndexOf(ret.Parameter));

> +            }

> +

>              if (bodyParams.Count == 0) {

We've already got a check for bodyParams.Count > 1 (line 429), then one for bodyParams.Count == 1 (line 434), and both of these throw or return if they are matched.

We don't need to check explicitly for bodyParams.Count == 0 on line 440, since it can't be anything else. (Unless I'm missing something - I am a little slow today [:beers:] )

—
Reply to this email directly or view it on GitHub<https://github.com/paulcbetts/refit/pull/102/files#r22134905>.