func IdentityConvertComplexArrayProperty(builder *ConversionFunctionBuilder, params ConversionParameters) []dst.Stmt {
	destinationType, ok := params.DestinationType.(*ArrayType)
	if !ok {
		return nil
	}
	sourceType, ok := params.SourceType.(*ArrayType)
	if !ok {
		return nil
	}
	var results []dst.Stmt
	locals := params.Locals.Clone()  
	itemIdent := builder.CreateLocal(locals, "item", params.NameHint)
	depth := params.CountArraysAndMapsInConversionContext()
	destination := params.GetDestination()
	if depth > 0 {
		innerDestinationIdent := locals.CreateLocal(params.NameHint, "Temp")
		destination = dst.NewIdent(innerDestinationIdent)
		results = append(
			results,
			astbuilder.LocalVariableDeclaration(
				innerDestinationIdent,
				destinationType.AsType(builder.CodeGenerationContext),
				""))
	}
	result := &dst.RangeStmt{
		Key:   dst.NewIdent("_"),
		Value: dst.NewIdent(itemIdent),
		X:     params.GetSource(),
		Tok:   token.DEFINE,
		Body: &dst.BlockStmt{
			List: builder.BuildConversion(
				ConversionParameters{
					Source:            dst.NewIdent(itemIdent),
					SourceType:        sourceType.Element(),
					Destination:       dst.Clone(destination).(dst.Expr),
					DestinationType:   destinationType.Element(),
					NameHint:          itemIdent,
					ConversionContext: append(params.ConversionContext, destinationType),
					AssignmentHandler: astbuilder.AppendList,
					Locals:            locals,
				}),
		},
	}
	results = append(results, result)
	if params.AssignmentHandler != nil {
		results = append(results, params.AssignmentHandler(params.GetDestination(), dst.Clone(destination).(dst.Expr)))
	}
	return results
}
IdentityConvertComplexArrayProperty handles conversion for array properties with complex elements
This function generates code that looks like this:
for _, item := range <source> {
<code for producing result from destinationType.Element()>
<destination> = append(<destination>, <result>)
}
package astmodel
import (
	"fmt"
	"go/token"
	"strings"
	"github.com/dave/dst"
	"github.com/Azure/k8s-infra/hack/generator/pkg/astbuilder"
)
type ConversionParameters struct {
	Source            dst.Expr
	Destination       dst.Expr
	SourceType        Type
	DestinationType   Type
	NameHint          string
	ConversionContext []Type
	AssignmentHandler func(destination, source dst.Expr) dst.Stmt
	Locals            *KnownLocalsSet
}
func (params ConversionParameters) GetSource() dst.Expr {
	return dst.Clone(params.Source).(dst.Expr)
}
func (params ConversionParameters) GetDestination() dst.Expr {
	return dst.Clone(params.Destination).(dst.Expr)
}
func (params ConversionParameters) WithSource(source dst.Expr) ConversionParameters {
	result := params.copy()
	result.Source = source
	return result
}
func (params ConversionParameters) WithSourceType(t Type) ConversionParameters {
	result := params.copy()
	result.SourceType = t
	return result
}
func (params ConversionParameters) WithDestination(destination dst.Expr) ConversionParameters {
	result := params.copy()
	result.Destination = destination
	return result
}
func (params ConversionParameters) WithDestinationType(t Type) ConversionParameters {
	result := params.copy()
	result.DestinationType = t
	return result
}
func (params ConversionParameters) WithAssignmentHandler(
	assignmentHandler func(result dst.Expr, destination dst.Expr) dst.Stmt) ConversionParameters {
	result := params.copy()
	result.AssignmentHandler = assignmentHandler
	return result
}
func (params ConversionParameters) AssignmentHandlerOrDefault() func(destination, source dst.Expr) dst.Stmt {
	if params.AssignmentHandler == nil {
		return AssignmentHandlerAssign
	}
	return params.AssignmentHandler
}
func (params ConversionParameters) CountArraysAndMapsInConversionContext() int {
	result := 0
	for _, t := range params.ConversionContext {
		switch t.(type) {
		case *MapType:
			result += 1
		case *ArrayType:
			result += 1
		}
	}
	return result
}
func (params ConversionParameters) copy() ConversionParameters {
	result := params
	result.ConversionContext = append([]Type(nil), params.ConversionContext...)
	result.Locals = result.Locals.Clone()
	return result
}
type ConversionHandler func(builder *ConversionFunctionBuilder, params ConversionParameters) []dst.Stmt
type ConversionFunctionBuilder struct {
	conversions []ConversionHandler
	IdFactory             IdentifierFactory
	CodeGenerationContext *CodeGenerationContext
}
func NewConversionFunctionBuilder(idFactory IdentifierFactory, codeGenerationContext *CodeGenerationContext) *ConversionFunctionBuilder {
	return &ConversionFunctionBuilder{
		IdFactory:             idFactory,
		CodeGenerationContext: codeGenerationContext,
		conversions: []ConversionHandler{
			IdentityConvertComplexOptionalProperty,
			IdentityConvertComplexArrayProperty,
			IdentityConvertComplexMapProperty,
			IdentityAssignValidatedTypeDestination,
			IdentityAssignValidatedTypeSource,
			IdentityAssignPrimitiveType,
			IdentityDeepCopyJSON,
			IdentityAssignTypeName,
		},
	}
}
func (builder *ConversionFunctionBuilder) AddConversionHandlers(conversionHandlers ...ConversionHandler) {
	builder.conversions = append(builder.conversions, conversionHandlers...)
}
func (builder *ConversionFunctionBuilder) PrependConversionHandlers(conversionHandlers ...ConversionHandler) {
	builder.conversions = append(conversionHandlers, builder.conversions...)
}
func (builder *ConversionFunctionBuilder) BuildConversion(params ConversionParameters) []dst.Stmt {
	for _, conversion := range builder.conversions {
		result := conversion(builder, params)
		if len(result) > 0 {
			return result
		}
	}
	types := builder.CodeGenerationContext.GetAllReachableTypes()
	var sourceSB strings.Builder
	params.SourceType.WriteDebugDescription(&sourceSB, types)
	var destinationSB strings.Builder
	params.SourceType.WriteDebugDescription(&destinationSB, types)
	panic(fmt.Sprintf("don't know how to perform conversion for %T -> %T", sourceSB.String(), destinationSB.String()))
}
func IdentityConvertComplexOptionalProperty(builder *ConversionFunctionBuilder, params ConversionParameters) []dst.Stmt {
	destinationType, ok := params.DestinationType.(*OptionalType)
	if !ok {
		return nil
	}
	sourceType, ok := params.SourceType.(*OptionalType)
	if !ok {
		return nil
	}
	tempVarIdent := params.Locals.CreateLocal(params.NameHint)
	innerStatements := builder.BuildConversion(
		ConversionParameters{
			Source:            astbuilder.Dereference(params.GetSource()),
			SourceType:        sourceType.Element(),
			Destination:       dst.NewIdent(tempVarIdent),
			DestinationType:   destinationType.Element(),
			NameHint:          params.NameHint,
			ConversionContext: append(params.ConversionContext, destinationType),
			AssignmentHandler: AssignmentHandlerDefine,
			Locals:            params.Locals.Clone(),
		})
	innerStatements = append(
		innerStatements,
		astbuilder.SimpleAssignment(
			params.GetDestination(),
			token.ASSIGN,
			astbuilder.AddrOf(dst.NewIdent(tempVarIdent))))
	result := &dst.IfStmt{
		Cond: &dst.BinaryExpr{
			X:  params.GetSource(),
			Op: token.NEQ,
			Y:  dst.NewIdent("nil"),
		},
		Body: &dst.BlockStmt{
			List: innerStatements,
		},
	}
	return []dst.Stmt{result}
}