Skip to content

Commit

Permalink
Reorder component property keywords so the PropertyKind is first (#733
Browse files Browse the repository at this point in the history
)
  • Loading branch information
joem-msft authored Jan 17, 2025
1 parent 06d6656 commit b0b3b1b
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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"));
}
}
13 changes: 9 additions & 4 deletions src/Persistence/PaYaml/Models/SchemaV3/ComponentDefinition.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
}

Expand All @@ -44,13 +46,16 @@ public abstract record ComponentCustomPropertyBase
/// </summary>
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<PFxFunctionParameter> Parameters { get; init; } = new();

/// <summary>
/// The default script for this custom input property.
/// </summary>
public PFxExpressionYaml? Default { get; init; }
}

0 comments on commit b0b3b1b

Please sign in to comment.