Skip to content

Commit

Permalink
Update PaYaml schema and OM to be v3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
joem-msft committed May 8, 2024
1 parent d55c489 commit fe4540d
Show file tree
Hide file tree
Showing 29 changed files with 44 additions and 44 deletions.
6 changes: 3 additions & 3 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@
"yaml.validate": true,
"yaml.schemas": {
"http://json-schema.org/draft-07/schema#": "*.schema.yaml",
"src/schemas/pa-yaml/v2.2/pa.schema.yaml": [
"src/schemas/pa-yaml/v3.0/pa.schema.yaml": [
//"*.pa.yaml",
"src/schemas-tests/pa-yaml/v2.2/**/*.pa.yaml"
"src/schemas-tests/pa-yaml/v3.0/**/*.pa.yaml"
],
"https://raw.githubusercontent.com/microsoft/PowerApps-Tooling/master/schemas/pa-yaml/v2.2/pa.schema.yaml": [
"https://raw.githubusercontent.com/microsoft/PowerApps-Tooling/master/schemas/pa-yaml/v3.0/pa.schema.yaml": [
"*.pa.yaml"
]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
# How to add snippets for use in VS Code: https://code.visualstudio.com/docs/languages/json#_define-snippets-in-json-schemas

$schema: http://json-schema.org/draft-07/schema#
$id: http://powerapps.com/schemas/pa-yaml/v2.2/pa.schema
title: Microsoft Power Apps schema for app source yaml files (v2.2).
$id: http://powerapps.com/schemas/pa-yaml/v3.0/pa.schema
title: Microsoft Power Apps schema for app source yaml files (v3.0).
description: >-
The schema for all *.pa.yaml files which are used to describe a Power Apps canvas app.
All *.pa.yaml files in an *.msapp are logically combined into a single *.pa.yaml file.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Licensed under the MIT License.

using Microsoft.PowerPlatform.PowerApps.Persistence.PaYaml.Models;
using Microsoft.PowerPlatform.PowerApps.Persistence.PaYaml.Models.SchemaV2_2;
using Microsoft.PowerPlatform.PowerApps.Persistence.PaYaml.Models.SchemaV3_0;

namespace Persistence.Tests.PaYaml.Models;

Expand Down
34 changes: 17 additions & 17 deletions src/Persistence.Tests/PaYaml/Serialization/PaYamlSerializerTests.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

using Microsoft.PowerPlatform.PowerApps.Persistence.PaYaml.Models.SchemaV2_2;
using Microsoft.PowerPlatform.PowerApps.Persistence.PaYaml.Models.SchemaV3_0;
using Microsoft.PowerPlatform.PowerApps.Persistence.PaYaml.Serialization;

namespace Persistence.Tests.PaYaml.Serialization;
Expand All @@ -12,7 +12,7 @@ public class PaYamlSerializerTests : VSTestBase
#region Deserialize Examples

[TestMethod]
[DataRow(@"_TestData/SchemaV2_2/Examples/Src/App.pa.yaml", 5)]
[DataRow(@"_TestData/SchemaV3_0/Examples/Src/App.pa.yaml", 5)]
public void DeserializeExamplePaYamlApp(string path, int expectedAppPropertiesCount)
{
var paFileRoot = PaYamlSerializer.Deserialize<PaModule>(File.ReadAllText(path));
Expand All @@ -29,9 +29,9 @@ public void DeserializeExamplePaYamlApp(string path, int expectedAppPropertiesCo
}

[TestMethod]
[DataRow(@"_TestData/SchemaV2_2/Examples/Src/Screens/Screen1.pa.yaml", 2, 8, 14, 2, 3)]
[DataRow(@"_TestData/SchemaV2_2/Examples/Src/Screens/FormsScreen2.pa.yaml", 0, 1, 62, 0, 0)]
[DataRow(@"_TestData/SchemaV2_2/Examples/Src/Screens/ComponentsScreen4.pa.yaml", 0, 6, 6, 0, 0)]
[DataRow(@"_TestData/SchemaV3_0/Examples/Src/Screens/Screen1.pa.yaml", 2, 8, 14, 2, 3)]
[DataRow(@"_TestData/SchemaV3_0/Examples/Src/Screens/FormsScreen2.pa.yaml", 0, 1, 62, 0, 0)]
[DataRow(@"_TestData/SchemaV3_0/Examples/Src/Screens/ComponentsScreen4.pa.yaml", 0, 6, 6, 0, 0)]
public void DeserializeExamplePaYamlScreen(string path, int expectedScreenPropertiesCount, int expectedScreenChildrenCount, int expectedDescendantsCount, int expectedScreenGroupsCount, int expectedTotalGroupsCount)
{
var paFileRoot = PaYamlSerializer.Deserialize<PaModule>(File.ReadAllText(path));
Expand All @@ -54,7 +54,7 @@ public void DeserializeExamplePaYamlScreen(string path, int expectedScreenProper
}

[TestMethod]
[DataRow(@"_TestData/SchemaV2_2/Examples/Src/Components/MyHeaderComponent.pa.yaml", 9, 6, 1)]
[DataRow(@"_TestData/SchemaV3_0/Examples/Src/Components/MyHeaderComponent.pa.yaml", 9, 6, 1)]
public void DeserializeExamplePaYamlComponentDefinition(string path, int expectedCustomPropertiesCount, int expectedPropertiesCount, int expectedChildrenCount)
{
var paFileRoot = PaYamlSerializer.Deserialize<PaModule>(File.ReadAllText(path));
Expand All @@ -76,7 +76,7 @@ public void DeserializeExamplePaYamlComponentDefinition(string path, int expecte
[TestMethod]
public void DeserializeExamplePaYamlSingleFileApp()
{
var path = @"_TestData/SchemaV2_2/Examples/Single-File-App.pa.yaml";
var path = @"_TestData/SchemaV3_0/Examples/Single-File-App.pa.yaml";
var paFileRoot = PaYamlSerializer.Deserialize<PaModule>(File.ReadAllText(path));
paFileRoot.ShouldNotBeNull();

Expand All @@ -99,16 +99,16 @@ public void DeserializeExamplePaYamlSingleFileApp()
#region RoundTrip from yaml

[TestMethod]
[DataRow(@"_TestData/SchemaV2_2/Examples/Src/App.pa.yaml")]
[DataRow(@"_TestData/SchemaV2_2/Examples/Src/Screens/Screen1.pa.yaml")]
[DataRow(@"_TestData/SchemaV2_2/Examples/Src/Screens/FormsScreen2.pa.yaml")]
[DataRow(@"_TestData/SchemaV2_2/Examples/Src/Screens/ComponentsScreen4.pa.yaml")]
[DataRow(@"_TestData/SchemaV2_2/Examples/Src/Components/MyHeaderComponent.pa.yaml")]
[DataRow(@"_TestData/SchemaV2_2/Examples/Single-File-App.pa.yaml")]
[DataRow(@"_TestData/SchemaV2_2/Examples/AmbiguousComponentNames.pa.yaml")]
[DataRow(@"_TestData/SchemaV2_2/FullSchemaUses/App.pa.yaml")]
[DataRow(@"_TestData/SchemaV2_2/FullSchemaUses/Screens-general-controls.pa.yaml")]
[DataRow(@"_TestData/SchemaV2_2/FullSchemaUses/Screens-with-components.pa.yaml")]
[DataRow(@"_TestData/SchemaV3_0/Examples/Src/App.pa.yaml")]
[DataRow(@"_TestData/SchemaV3_0/Examples/Src/Screens/Screen1.pa.yaml")]
[DataRow(@"_TestData/SchemaV3_0/Examples/Src/Screens/FormsScreen2.pa.yaml")]
[DataRow(@"_TestData/SchemaV3_0/Examples/Src/Screens/ComponentsScreen4.pa.yaml")]
[DataRow(@"_TestData/SchemaV3_0/Examples/Src/Components/MyHeaderComponent.pa.yaml")]
[DataRow(@"_TestData/SchemaV3_0/Examples/Single-File-App.pa.yaml")]
[DataRow(@"_TestData/SchemaV3_0/Examples/AmbiguousComponentNames.pa.yaml")]
[DataRow(@"_TestData/SchemaV3_0/FullSchemaUses/App.pa.yaml")]
[DataRow(@"_TestData/SchemaV3_0/FullSchemaUses/Screens-general-controls.pa.yaml")]
[DataRow(@"_TestData/SchemaV3_0/FullSchemaUses/Screens-with-components.pa.yaml")]
public void RoundTripFromYaml(string path)
{
var originalYaml = File.ReadAllText(path);
Expand Down
4 changes: 2 additions & 2 deletions src/Persistence.Tests/Persistence.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@
<None Include="_TestData\**\*">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="..\schemas-tests\pa-yaml\v2.2\Examples\**\*.yaml" LinkBase="_TestData\SchemaV2_2\Examples\">
<None Include="..\schemas-tests\pa-yaml\v3.0\Examples\**\*.yaml" LinkBase="_TestData\SchemaV3_0\Examples\">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="..\schemas-tests\pa-yaml\v2.2\FullSchemaUses\**\*.yaml" LinkBase="_TestData\SchemaV2_2\FullSchemaUses\">
<None Include="..\schemas-tests\pa-yaml\v3.0\FullSchemaUses\**\*.yaml" LinkBase="_TestData\SchemaV3_0\FullSchemaUses\">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion src/Persistence/GlobalSuppressions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@

using System.Diagnostics.CodeAnalysis;

[assembly: SuppressMessage("Naming", "CA1707:Identifiers should not contain underscores", Justification = "Version number in namespace.", Scope = "namespace", Target = "~N:Microsoft.PowerPlatform.PowerApps.Persistence.PaYaml.Models.SchemaV2_2")]
[assembly: SuppressMessage("Naming", "CA1707:Identifiers should not contain underscores", Justification = "Version number in namespace.", Scope = "namespace", Target = "~N:Microsoft.PowerPlatform.PowerApps.Persistence.PaYaml.Models.SchemaV3_0")]
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

using Microsoft.PowerPlatform.PowerApps.Persistence.PaYaml.Models.PowerFx;

namespace Microsoft.PowerPlatform.PowerApps.Persistence.PaYaml.Models.SchemaV2_2;
namespace Microsoft.PowerPlatform.PowerApps.Persistence.PaYaml.Models.SchemaV3_0;

public record AppInstance
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
using Microsoft.PowerPlatform.PowerApps.Persistence.PaYaml.Models.PowerFx;
using YamlDotNet.Serialization;

namespace Microsoft.PowerPlatform.PowerApps.Persistence.PaYaml.Models.SchemaV2_2;
namespace Microsoft.PowerPlatform.PowerApps.Persistence.PaYaml.Models.SchemaV3_0;

public enum ComponentPropertyKind
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

namespace Microsoft.PowerPlatform.PowerApps.Persistence.PaYaml.Models.SchemaV2_2;
namespace Microsoft.PowerPlatform.PowerApps.Persistence.PaYaml.Models.SchemaV3_0;

/// <summary>
/// Represents a group of controls under the same parent.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
using Microsoft.PowerPlatform.PowerApps.Persistence.PaYaml.Models.PowerFx;
using YamlDotNet.Serialization;

namespace Microsoft.PowerPlatform.PowerApps.Persistence.PaYaml.Models.SchemaV2_2;
namespace Microsoft.PowerPlatform.PowerApps.Persistence.PaYaml.Models.SchemaV3_0;

public record ControlInstance
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

namespace Microsoft.PowerPlatform.PowerApps.Persistence.PaYaml.Models.SchemaV2_2;
namespace Microsoft.PowerPlatform.PowerApps.Persistence.PaYaml.Models.SchemaV3_0;

public interface IPaControlInstanceContainer
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

namespace Microsoft.PowerPlatform.PowerApps.Persistence.PaYaml.Models.SchemaV2_2;
namespace Microsoft.PowerPlatform.PowerApps.Persistence.PaYaml.Models.SchemaV3_0;

public static class ModelsExtensions
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

namespace Microsoft.PowerPlatform.PowerApps.Persistence.PaYaml.Models.SchemaV2_2;
namespace Microsoft.PowerPlatform.PowerApps.Persistence.PaYaml.Models.SchemaV3_0;

/// <summary>
/// Represents a Power Apps Yaml module file.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

namespace Microsoft.PowerPlatform.PowerApps.Persistence.PaYaml.Models.SchemaV2_2;
namespace Microsoft.PowerPlatform.PowerApps.Persistence.PaYaml.Models.SchemaV3_0;

public static class SchemaKeywords
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

using Microsoft.PowerPlatform.PowerApps.Persistence.PaYaml.Models.PowerFx;

namespace Microsoft.PowerPlatform.PowerApps.Persistence.PaYaml.Models.SchemaV2_2;
namespace Microsoft.PowerPlatform.PowerApps.Persistence.PaYaml.Models.SchemaV3_0;

public record ScreenInstance : IPaControlInstanceContainer
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Licensed under the MIT License.

using Microsoft.PowerPlatform.PowerApps.Persistence.PaYaml.Models.PowerFx;
using Microsoft.PowerPlatform.PowerApps.Persistence.PaYaml.Models.SchemaV2_2;
using Microsoft.PowerPlatform.PowerApps.Persistence.PaYaml.Models.SchemaV3_0;
using YamlDotNet.Serialization;
using YamlDotNet.Serialization.NamingConventions;

Expand Down
4 changes: 2 additions & 2 deletions src/schemas-tests/.vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
],
"yaml.schemas": {
"http://json-schema.org/draft-07/schema#": "*.schema.yaml",
"../schemas/pa-yaml/v2.2/pa.schema.yaml": [
"pa-yaml/v2.2/**/*.pa.yaml"
"../schemas/pa-yaml/v3.0/pa.schema.yaml": [
"pa-yaml/v3.0/**/*.pa.yaml"
]
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
# How to add snippets for use in VS Code: https://code.visualstudio.com/docs/languages/json#_define-snippets-in-json-schemas

$schema: http://json-schema.org/draft-07/schema#
$id: http://powerapps.com/schemas/pa-yaml/v2.2/pa.schema
title: Microsoft Power Apps schema for app source yaml files (v2.2).
$id: http://powerapps.com/schemas/pa-yaml/v3.0/pa.schema
title: Microsoft Power Apps schema for app source yaml files (v3.0).
description: >-
The schema for all *.pa.yaml files which are used to describe a Power Apps canvas app.
All *.pa.yaml files in an *.msapp are logically combined into a single *.pa.yaml file.
Expand Down
8 changes: 4 additions & 4 deletions src/schemas/publish.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

:: TODO: Instead of a straight copy, we should remove yaml comments; only keeping '$comment'
:: TODO: We MAY want to also publish the *.schema.json files too.
@ECHO Copying pa-yaml/v2.2 ...
@RMDIR /S /Q "%_SchemasDistRoot%pa-yaml\v2.2\"
@MKDIR "%_SchemasDistRoot%pa-yaml\v2.2\"
@COPY pa-yaml\v2.2\pa.schema.yaml "%_SchemasDistRoot%pa-yaml\v2.2\"
@ECHO Copying pa-yaml/v3.0 ...
@RMDIR /S /Q "%_SchemasDistRoot%pa-yaml\v3.0\"
@MKDIR "%_SchemasDistRoot%pa-yaml\v3.0\"
@COPY pa-yaml\v3.0\pa.schema.yaml "%_SchemasDistRoot%pa-yaml\v3.0\"

0 comments on commit fe4540d

Please sign in to comment.