From 6c159453c7505e882990a62c8f9321fd5fca650f Mon Sep 17 00:00:00 2001 From: Bevan Arps Date: Mon, 5 Jul 2021 13:04:39 +1200 Subject: [PATCH] Make NameOfPropertyAssignmentFunction() externally visible --- .../generator/pkg/conversions/property_conversions.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/hack/generator/pkg/conversions/property_conversions.go b/hack/generator/pkg/conversions/property_conversions.go index 55ec6617f07..2ea2afccafd 100644 --- a/hack/generator/pkg/conversions/property_conversions.go +++ b/hack/generator/pkg/conversions/property_conversions.go @@ -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. // @@ -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()) {