protected virtual IEnumerable <StatementSyntax> GenerateStatements( ILocatedOpenApiElement <OpenApiResponse> response) { var propertyNameFormatter = _context.NameFormatterSelector.GetFormatter(NameKind.Property); // Declare values variable to hold TryGetValue out results yield return(LocalDeclarationStatement(VariableDeclaration( WellKnownTypes.System.Collections.Generic.IEnumerableT.Name( PredefinedType(Token(SyntaxKind.StringKeyword)))) .AddVariables(VariableDeclarator("values")))); NameSyntax valuesName = IdentifierName("values"); foreach (var header in response.GetHeaders()) { ILocatedOpenApiElement <OpenApiSchema> schemaElement = header.GetSchemaOrDefault(); TypeSyntax typeName = _context.TypeNameProvider.GetName(schemaElement); InvocationExpressionSyntax deserializeExpression = InvocationExpression(MemberAccessExpression(SyntaxKind.SimpleMemberAccessExpression, _serializationNamespace.HeaderSerializerInstance, GenericName("Deserialize") .AddTypeArgumentListArguments(typeName))) .AddArgumentListArguments( Argument(valuesName), Argument(header.Element.Explode ? LiteralExpression(SyntaxKind.TrueLiteralExpression) : LiteralExpression(SyntaxKind.FalseLiteralExpression))); yield return(IfStatement( WellKnownTypes.System.Net.Http.Headers.HttpHeaders.TryGetValues( SyntaxHelpers.MemberAccess(IdentifierName("Message"), "Headers"), SyntaxHelpers.StringLiteral(header.Key), valuesName), Block( ExpressionStatement(AssignmentExpression(SyntaxKind.SimpleAssignmentExpression, IdentifierName(propertyNameFormatter.Format(header.Key)), deserializeExpression))))); } }