diff --git a/src/Persistence.Tests/PaYaml/Serialization/PaYamlSerializerTests.cs b/src/Persistence.Tests/PaYaml/Serialization/PaYamlSerializerTests.cs index cb54b176..d50755d8 100644 --- a/src/Persistence.Tests/PaYaml/Serialization/PaYamlSerializerTests.cs +++ b/src/Persistence.Tests/PaYaml/Serialization/PaYamlSerializerTests.cs @@ -3,6 +3,7 @@ using Microsoft.PowerPlatform.PowerApps.Persistence; using Microsoft.PowerPlatform.PowerApps.Persistence.PaYaml.Models; +using Microsoft.PowerPlatform.PowerApps.Persistence.PaYaml.Models.PowerFx; using Microsoft.PowerPlatform.PowerApps.Persistence.PaYaml.Models.SchemaV3; using Microsoft.PowerPlatform.PowerApps.Persistence.PaYaml.Serialization; @@ -261,4 +262,25 @@ public void IsSequenceCheckShouldReturnTrueWhenSequenceInFragmentBeginsWithDocum } #endregion + + [TestMethod] + public void SerializeComponentCustomPropertyUnionPropertyOrder() + { + // Since App.Properties is a NamedObjectMapping, the location info should be set on the NamedObject + var actualYaml = PaYamlSerializer.Serialize(new ComponentCustomPropertyUnion() + { + PropertyKind = ComponentPropertyKind.Input, + DisplayName = "My Property", + Description = "My Property Description", + DataType = PFxDataType.Boolean, + Default = new("true"), + }); + actualYaml.TrimEnd().Should().Be(""" + PropertyKind: Input + DisplayName: My Property + Description: My Property Description + DataType: Boolean + Default: =true + """.Replace("\r\n", "\n")); + } } diff --git a/src/Persistence/PaYaml/Models/SchemaV3/ComponentDefinition.cs b/src/Persistence/PaYaml/Models/SchemaV3/ComponentDefinition.cs index a3df4a0c..f74883af 100644 --- a/src/Persistence/PaYaml/Models/SchemaV3/ComponentDefinition.cs +++ b/src/Persistence/PaYaml/Models/SchemaV3/ComponentDefinition.cs @@ -31,11 +31,13 @@ public record ComponentDefinition : IPaControlInstanceContainer public abstract record ComponentCustomPropertyBase { - [YamlMember(DefaultValuesHandling = DefaultValuesHandling.Preserve)] + [YamlMember(Order = -9, DefaultValuesHandling = DefaultValuesHandling.Preserve)] public required ComponentPropertyKind PropertyKind { get; init; } + [YamlMember(Order = -8)] public string? DisplayName { get; init; } + [YamlMember(Order = -7)] public string? Description { get; init; } } @@ -44,13 +46,16 @@ public abstract record ComponentCustomPropertyBase /// public record ComponentCustomPropertyUnion : ComponentCustomPropertyBase { - public PFxDataType? DataType { get; init; } - public bool? RaiseOnReset { get; init; } - public PFxExpressionYaml? Default { get; init; } + public PFxDataType? DataType { get; init; } public PFxFunctionReturnType? ReturnType { get; init; } public NamedObjectSequence Parameters { get; init; } = new(); + + /// + /// The default script for this custom input property. + /// + public PFxExpressionYaml? Default { get; init; } }