Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Moved MsappArchive to Persistence #529

Merged
merged 1 commit into from
Jan 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ insert_final_newline = true
charset = utf-8
trim_trailing_whitespace = true

[*.{json,js}]
[*.{json,js,yaml,yml}]
indent_size = 2
tab_width = 2

Expand Down
24 changes: 0 additions & 24 deletions src/PAModel/Exceptions/SerializationException.cs

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Logging" Version="6.0.0" />
<PackageReference Include="Newtonsoft.Json" Version="[13.0.1,)" />
<PackageReference Include="System.Text.Json" Version="[6.0,)" />
<PackageReference Include="System.Text.Encodings.Web" Version="6.0.0" />
Expand Down
46 changes: 0 additions & 46 deletions src/PAModel/Model/Control.cs

This file was deleted.

21 changes: 0 additions & 21 deletions src/PAModel/Model/ControlEditorState.cs

This file was deleted.

17 changes: 0 additions & 17 deletions src/PAModel/Model/RuleEditorState.cs

This file was deleted.

9 changes: 0 additions & 9 deletions src/PAModel/Model/TaggedRuleEditorState.cs

This file was deleted.

76 changes: 46 additions & 30 deletions src/PAModel/packages.lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,6 @@
"version": 1,
"dependencies": {
"net7.0": {
"Microsoft.Extensions.Logging": {
"type": "Direct",
"requested": "[6.0.0, )",
"resolved": "6.0.0",
"contentHash": "eIbyj40QDg1NDz0HBW0S5f3wrLVnKWnDJ/JtZ+yJDFnDj90VoPuoPmFkeaXrtu+0cKm5GRAwoDf+dBWXK0TUdg==",
"dependencies": {
"Microsoft.Extensions.DependencyInjection": "6.0.0",
"Microsoft.Extensions.DependencyInjection.Abstractions": "6.0.0",
"Microsoft.Extensions.Logging.Abstractions": "6.0.0",
"Microsoft.Extensions.Options": "6.0.0",
"System.Diagnostics.DiagnosticSource": "6.0.0"
}
},
"Newtonsoft.Json": {
"type": "Direct",
"requested": "[13.0.1, )",
Expand Down Expand Up @@ -46,46 +33,73 @@
"resolved": "15.1.0",
"contentHash": "fXrqmKkzBtXeJiHEsZOPEWkonHweiwk/l0Hqhz4yMIZPh57kZy03Xbj2/e8HV1QIkTw7yeBe9bbphuE3YiI4vQ=="
},
"Microsoft.Extensions.DependencyInjection": {
"Microsoft.Bcl.AsyncInterfaces": {
"type": "Transitive",
"resolved": "6.0.0",
"contentHash": "k6PWQMuoBDGGHOQTtyois2u4AwyVcIwL2LaSLlTZQm2CYcJ1pxbt6jfAnpWmzENA/wfrYRI/X9DTLoUkE4AsLw==",
"contentHash": "UcSjPsst+DfAdJGVDsu346FX0ci0ah+lw3WRtn18NUwEqRt70HaOQ7lI72vy3+1LxtqI3T5GWwV39rQSrCzAeg=="
},
"Microsoft.Extensions.DependencyInjection": {
"type": "Transitive",
"resolved": "7.0.0",
"contentHash": "elNeOmkeX3eDVG6pYVeV82p29hr+UKDaBhrZyWvWLw/EVZSYEkZlQdkp0V39k/Xehs2Qa0mvoCvkVj3eQxNQ1Q==",
"dependencies": {
"Microsoft.Extensions.DependencyInjection.Abstractions": "6.0.0",
"System.Runtime.CompilerServices.Unsafe": "6.0.0"
"Microsoft.Extensions.DependencyInjection.Abstractions": "7.0.0"
}
},
"Microsoft.Extensions.DependencyInjection.Abstractions": {
"type": "Transitive",
"resolved": "6.0.0",
"contentHash": "xlzi2IYREJH3/m6+lUrQlujzX8wDitm4QGnUu6kUXTQAWPuZY8i+ticFJbzfqaetLA6KR/rO6Ew/HuYD+bxifg=="
"resolved": "7.0.0",
"contentHash": "h3j/QfmFN4S0w4C2A6X7arXij/M/OVw3uQHSOFxnND4DyAzO1F9eMX7Eti7lU/OkSthEE0WzRsfT/Dmx86jzCw=="
},
"Microsoft.Extensions.Logging": {
"type": "Transitive",
"resolved": "7.0.0",
"contentHash": "Nw2muoNrOG5U5qa2ZekXwudUn2BJcD41e65zwmDHb1fQegTX66UokLWZkJRpqSSHXDOWZ5V0iqhbxOEky91atA==",
"dependencies": {
"Microsoft.Extensions.DependencyInjection": "7.0.0",
"Microsoft.Extensions.DependencyInjection.Abstractions": "7.0.0",
"Microsoft.Extensions.Logging.Abstractions": "7.0.0",
"Microsoft.Extensions.Options": "7.0.0"
}
},
"Microsoft.Extensions.Logging.Abstractions": {
"type": "Transitive",
"resolved": "6.0.0",
"contentHash": "/HggWBbTwy8TgebGSX5DBZ24ndhzi93sHUBDvP1IxbZD7FDokYzdAr6+vbWGjw2XAfR2EJ1sfKUotpjHnFWPxA=="
"resolved": "7.0.0",
"contentHash": "kmn78+LPVMOWeITUjIlfxUPDsI0R6G0RkeAMBmQxAJ7vBJn4q2dTva7pWi65ceN5vPGjJ9q/Uae2WKgvfktJAw=="
},
"Microsoft.Extensions.Options": {
"type": "Transitive",
"resolved": "6.0.0",
"contentHash": "dzXN0+V1AyjOe2xcJ86Qbo233KHuLEY0njf/P2Kw8SfJU+d45HNS2ctJdnEnrWbM9Ye2eFgaC5Mj9otRMU6IsQ==",
"resolved": "7.0.0",
"contentHash": "lP1yBnTTU42cKpMozuafbvNtQ7QcBjr/CcK3bYOGEMH55Fjt+iecXjT6chR7vbgCMqy3PG3aNQSZgo/EuY/9qQ==",
"dependencies": {
"Microsoft.Extensions.DependencyInjection.Abstractions": "6.0.0",
"Microsoft.Extensions.Primitives": "6.0.0"
"Microsoft.Extensions.DependencyInjection.Abstractions": "7.0.0",
"Microsoft.Extensions.Primitives": "7.0.0"
}
},
"Microsoft.Extensions.Primitives": {
"type": "Transitive",
"resolved": "6.0.0",
"contentHash": "9+PnzmQFfEFNR9J2aDTfJGGupShHjOuGw4VUv+JB044biSHrnmCIMD+mJHmb2H7YryrfBEXDurxQ47gJZdCKNQ==",
"resolved": "7.0.0",
"contentHash": "um1KU5kxcRp3CNuI8o/GrZtD4AIOXDk+RLsytjZ9QPok3ttLUelLKpilVPuaFT3TFjOhSibUAso0odbOaCDj3Q=="
},
"Microsoft.PowerFx.Core": {
"type": "Transitive",
"resolved": "1.2.0",
"contentHash": "M9DY6FqWUXUPgjbbHsB3vt7+b4QPFaoKBZ7ixSU7cPgHKzo/aNohzYWxYasXwTV6pamv5gX9AqLuF13RimMPdg==",
"dependencies": {
"System.Runtime.CompilerServices.Unsafe": "6.0.0"
"Microsoft.Bcl.AsyncInterfaces": "6.0.0",
"Microsoft.PowerFx.Transport.Attributes": "1.2.0",
"System.Collections.Immutable": "6.0.0"
}
},
"System.Diagnostics.DiagnosticSource": {
"Microsoft.PowerFx.Transport.Attributes": {
"type": "Transitive",
"resolved": "1.2.0",
"contentHash": "zlvi59W/4MdDJeR2rIL8k633V+FIHtxbhyaurNBZevksNWCZ49AV0bUhpB6cUjD/vwci8ZXXWziw0yYnjXIzNg=="
},
"System.Collections.Immutable": {
"type": "Transitive",
"resolved": "6.0.0",
"contentHash": "frQDfv0rl209cKm1lnwTgFPzNigy2EKk1BS3uAvHvlBVKe5cymGyHO+Sj+NLv5VF/AhHsqPIUUwya5oV4CHMUw==",
"contentHash": "l4zZJ1WU2hqpQQHXz1rvC3etVZN+2DLmQMO79FhOTZHMn8tDRr+WU287sbomD0BETlmKDn0ygUgVy9k5xkkJdA==",
"dependencies": {
"System.Runtime.CompilerServices.Unsafe": "6.0.0"
}
Expand All @@ -98,6 +112,8 @@
"microsoft.powerplatform.powerapps.persistence": {
"type": "Project",
"dependencies": {
"Microsoft.Extensions.Logging": "[7.0.0, )",
"Microsoft.PowerFx.Core": "[1.2.0, )",
"YamlDotNet": "[15.1.0, )"
}
}
Expand Down
Binary file removed src/PAModelTests/Apps/WithYaml/HelloWorld.msapp
Binary file not shown.
2 changes: 1 addition & 1 deletion src/PAModelTests/DataSourceTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
using Microsoft.PowerPlatform.Formulas.Tools;
using Microsoft.PowerPlatform.Formulas.Tools.Extensions;
using Microsoft.PowerPlatform.Formulas.Tools.IO;
using Microsoft.PowerPlatform.Formulas.Tools.MsApp;
using Microsoft.PowerPlatform.PowerApps.Persistence.MsApp;

namespace PAModelTests;

Expand Down
2 changes: 1 addition & 1 deletion src/PASopa.sln
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.PowerPlatform.PowerApps.Persistence", "Persistence\Microsoft.PowerPlatform.PowerApps.Persistence.csproj", "{906B4EA5-F287-4D0E-A511-0D89B2DD9C14}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.PowerPlatform.PowerApps.Persistence.Tests", "Persistence.Tests\Microsoft.PowerPlatform.PowerApps.Persistence.Tests.csproj", "{8AB1C901-FE5E-44BF-AA21-B8F20A9D7CDD}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Persistence.Tests", "Persistence.Tests\Persistence.Tests.csproj", "{8AB1C901-FE5E-44BF-AA21-B8F20A9D7CDD}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand Down
12 changes: 12 additions & 0 deletions src/Persistence.Tests/Extensions/StringExtensions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

namespace Persistence.Tests.Extensions;

internal static class StringExtensions
{
public static string NormalizeNewlines(this string x)
{
return x.Replace("\r\n", "\n").Replace("\r", "\n");
}
}

This file was deleted.

22 changes: 22 additions & 0 deletions src/Persistence.Tests/Model/InvalidControls.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

using Microsoft.PowerPlatform.PowerApps.Persistence.Models;

namespace Persistence.Tests.Model;

[TestClass]
public class InvalidControls
{
[TestMethod]
[DataRow("")]
[DataRow(" ")]
public void Constructor_InvalidControlName_Throws(string controlName)
{
// Act
Action act = () => new Screen(controlName);

// Assert
act.Should().Throw<ArgumentException>();
}
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

using System.IO;
using System.IO.Compression;
using System.Linq;
using Microsoft.PowerPlatform.Formulas.Tools.MsApp;
using Microsoft.PowerPlatform.PowerApps.Persistence.MsApp;
using Microsoft.PowerPlatform.PowerApps.Persistence.Yaml;

namespace PAModelTests.MsApp;
namespace Persistence.Tests.MsApp;

[TestClass]
public class MsappArchiveTests
Expand Down Expand Up @@ -74,22 +73,19 @@ public void AddEntryTests(string[] entries)
}

[TestMethod]
[DataRow(@"Apps/WithYaml/HelloWorld.msapp", 14, 2, "HelloScreen", "screen", 8)]
[DataRow(@"Apps/AppWithLabel.msapp", 11, 2, "Screen1", "ControlInfo", 8)]
public void GetTopLevelControlsTests(string testFile, int allEntriesCount, int controlsCount,
[DataRow(@"_TestData/AppsWithYaml/HelloWorld.msapp", 14, 2, "HelloScreen", "screen", 8)]
public void Msapp_ShouldHave_Screens(string testFile, int allEntriesCount, int controlsCount,
string topLevelControlName, string topLevelControlType,
int topLevelRulesCount)
{
// Arrange: Create new ZipArchive in memory
using var msappArchive = new MsappArchive(testFile);
using var msappArchive = new MsappArchive(testFile, YamlSerializationFactory.CreateDeserializer());

// Assert
msappArchive.CanonicalEntries.Count.Should().Be(allEntriesCount);
msappArchive.TopLevelControls.Count.Should().Be(controlsCount);
msappArchive.TopLevelControls.Should().ContainSingle(c => c.Name == "App");
msappArchive.Screens.Count.Should().Be(controlsCount);
msappArchive.Screens.Should().ContainSingle(c => c.Name == "App");

var topLevelControl = msappArchive.TopLevelControls.Single(c => c.Name == topLevelControlName);
topLevelControl.EditorState.Rules.Count.Should().Be(topLevelRulesCount);
topLevelControl.Type.Should().Be(topLevelControlType);
var screen = msappArchive.Screens.Single(c => c.Name == topLevelControlName);
}
}
Loading
Loading