Skip to content

Commit

Permalink
Make NameOfPropertyAssignmentFunction() externally visible
Browse files Browse the repository at this point in the history
  • Loading branch information
theunrepentantgeek committed Jul 6, 2021
1 parent 22cc0d6 commit 6c15945
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion hack/generator/pkg/conversions/property_conversions.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,15 @@ func CreateTypeConversion(
return nil, err
}


func NameOfPropertyAssignmentFunction(name astmodel.TypeName, direction Direction, idFactory astmodel.IdentifierFactory) string {
nameOfOtherType := idFactory.CreateIdentifier(name.Name(), astmodel.Exported)
return direction.SelectString(
"AssignPropertiesFrom"+nameOfOtherType,
"AssignPropertiesTo"+nameOfOtherType)
}


// assignToOptional will generate a conversion where the destination is optional, if the
// underlying type of the destination is compatible with the source.
//
Expand Down Expand Up @@ -853,7 +862,7 @@ func assignObjectFromObject(
actualReader = astbuilder.AddrOf(reader)
}

functionName := nameOfPropertyAssignmentFunction(sourceName, conversionContext.direction, conversionContext.idFactory)
functionName := NameOfPropertyAssignmentFunction(sourceName, conversionContext.direction, conversionContext.idFactory)

var conversion dst.Stmt
if destinationName.PackageReference.Equals(generationContext.CurrentPackage()) {
Expand Down

0 comments on commit 6c15945

Please sign in to comment.