private void GenerateMethodParameters(MethodEmitter methodEmitter, MethodModel method, ResolvedSerializationMethods serializationMethods) { foreach (var parameter in method.Parameters) { var attributes = parameter.GetAllSetAttributes().ToList(); if (parameter.IsByRef) { this.diagnostics.ReportParameterMustNotBeByRef(method, parameter); } if (parameter.IsCancellationToken) { if (attributes.Count > 0) { this.diagnostics.ReportCancellationTokenMustHaveZeroAttributes(method, parameter); } methodEmitter.EmitSetCancellationToken(parameter); } else { if (attributes.Count > 1) { this.diagnostics.ReportParameterMustHaveZeroOrOneAttributes(method, parameter, attributes); } if (parameter.HeaderAttribute != null) { if (parameter.HeaderAttribute.Attribute.Value != null) { this.diagnostics.ReportHeaderParameterMustNotHaveValue(method, parameter); } if (parameter.HeaderAttribute.Attribute.Name.Contains(":")) { this.diagnostics.ReportHeaderParameterMustNotHaveColonInName(method, parameter); } methodEmitter.EmitAddHeaderParameter(parameter); } else if (parameter.PathAttribute != null) { methodEmitter.EmitAddPathParameter( parameter, serializationMethods.ResolvePath(parameter.PathAttribute.Attribute.SerializationMethod)); } else if (parameter.QueryAttribute != null) { methodEmitter.EmitAddQueryParameter( parameter, serializationMethods.ResolveQuery(parameter.QueryAttribute.Attribute.SerializationMethod)); } else if (parameter.HttpRequestMessagePropertyAttribute != null) { methodEmitter.EmitAddHttpRequestMessagePropertyParameter(parameter); } else if (parameter.RawQueryStringAttribute != null) { methodEmitter.EmitAddRawQueryStringParameter(parameter); } else if (parameter.QueryMapAttribute != null) { if (!methodEmitter.TryEmitAddQueryMapParameter(parameter, serializationMethods.ResolveQuery(parameter.QueryMapAttribute.Attribute.SerializationMethod))) { this.diagnostics.ReportQueryMapParameterIsNotADictionary(method, parameter); } } else if (parameter.BodyAttribute != null) { methodEmitter.EmitSetBodyParameter( parameter, serializationMethods.ResolveBody(parameter.BodyAttribute.Attribute.SerializationMethod)); } else { methodEmitter.EmitAddQueryParameter(parameter, serializationMethods.ResolveQuery(QuerySerializationMethod.Default)); } } } }