Skip to content

Commit ede0074

Browse files
yao-msftryfu-msft
authored andcommitted
Add support for 1.9 manifest in rest source parsing and winget utils interop (#4906)
1 parent 874acff commit ede0074

19 files changed

+861
-9
lines changed

src/AppInstallerCLITests/AppInstallerCLITests.vcxproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -322,6 +322,7 @@
322322
<ClCompile Include="RestInterface_1_5.cpp" />
323323
<ClCompile Include="RestInterface_1_6.cpp" />
324324
<ClCompile Include="RestInterface_1_7.cpp" />
325+
<ClCompile Include="RestInterface_1_9.cpp" />
325326
<ClCompile Include="ResumeFlow.cpp" />
326327
<ClCompile Include="Runtime.cpp" />
327328
<ClCompile Include="SearchRequestSerializer.cpp" />

src/AppInstallerCLITests/AppInstallerCLITests.vcxproj.filters

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -365,6 +365,9 @@
365365
<ClCompile Include="Sixel.cpp">
366366
<Filter>Source Files\CLI</Filter>
367367
</ClCompile>
368+
<ClCompile Include="RestInterface_1_9.cpp">
369+
<Filter>Source Files\Repository</Filter>
370+
</ClCompile>
368371
</ItemGroup>
369372
<ItemGroup>
370373
<None Include="PropertySheet.props" />

src/AppInstallerCLITests/RestClient.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ TEST_CASE("GetSupportedInterface", "[RestSource]")
5151
REQUIRE(RestClient::GetSupportedInterface(TestRestUri, {}, info, {}, version, {})->GetVersion() == version);
5252

5353
// Update this test to next version so that we don't forget to add to supported versions before rest e2e tests are available.
54-
Version invalid{ "1.8.0" };
54+
Version invalid{ "1.10.0" };
5555
REQUIRE_THROWS_HR(RestClient::GetSupportedInterface(TestRestUri, {}, info, {}, invalid, {}), APPINSTALLER_CLI_ERROR_RESTSOURCE_INVALID_VERSION);
5656

5757
Authentication::AuthenticationArguments authArgs;

src/AppInstallerCLITests/RestInterface_1_9.cpp

Lines changed: 400 additions & 0 deletions
Large diffs are not rendered by default.

src/AppInstallerCLITests/YamlManifest.cpp

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1330,6 +1330,37 @@ TEST_CASE("WriteV1_7SingletonManifestAndVerifyContents", "[ManifestCreation]")
13301330
VerifyV1ManifestContent(generatedMultiFileManifest, false, ManifestVer{ s_ManifestVersionV1_7 }, true);
13311331
}
13321332

1333+
TEST_CASE("WriteV1_9SingletonManifestAndVerifyContents", "[ManifestCreation]")
1334+
{
1335+
TempDirectory singletonDirectory{ "SingletonManifest" };
1336+
CopyTestDataFilesToFolder({ "ManifestV1_9-Singleton.yaml" }, singletonDirectory);
1337+
Manifest singletonManifest = YamlParser::CreateFromPath(singletonDirectory);
1338+
1339+
TempDirectory exportedSingletonDirectory{ "exportedSingleton" };
1340+
std::filesystem::path generatedSingletonManifestPath = exportedSingletonDirectory.GetPath() / "testSingletonManifest.yaml";
1341+
YamlWriter::OutputYamlFile(singletonManifest, singletonManifest.Installers[0], generatedSingletonManifestPath);
1342+
1343+
REQUIRE(std::filesystem::exists(generatedSingletonManifestPath));
1344+
Manifest generatedSingletonManifest = YamlParser::CreateFromPath(exportedSingletonDirectory);
1345+
VerifyV1ManifestContent(generatedSingletonManifest, true, ManifestVer{ s_ManifestVersionV1_9 }, true);
1346+
1347+
TempDirectory multiFileDirectory{ "MultiFileManifest" };
1348+
CopyTestDataFilesToFolder({
1349+
"ManifestV1_9-MultiFile-Version.yaml",
1350+
"ManifestV1_9-MultiFile-Installer.yaml",
1351+
"ManifestV1_9-MultiFile-DefaultLocale.yaml",
1352+
"ManifestV1_9-MultiFile-Locale.yaml" }, multiFileDirectory);
1353+
1354+
Manifest multiFileManifest = YamlParser::CreateFromPath(multiFileDirectory);
1355+
TempDirectory exportedMultiFileDirectory{ "exportedMultiFile" };
1356+
std::filesystem::path generatedMultiFileManifestPath = exportedMultiFileDirectory.GetPath() / "testMultiFileManifest.yaml";
1357+
YamlWriter::OutputYamlFile(multiFileManifest, multiFileManifest.Installers[0], generatedMultiFileManifestPath);
1358+
1359+
REQUIRE(std::filesystem::exists(generatedMultiFileManifestPath));
1360+
Manifest generatedMultiFileManifest = YamlParser::CreateFromPath(exportedMultiFileDirectory);
1361+
VerifyV1ManifestContent(generatedMultiFileManifest, false, ManifestVer{ s_ManifestVersionV1_9 }, true);
1362+
}
1363+
13331364
TEST_CASE("WriteManifestWithMultipleLocale", "[ManifestCreation]")
13341365
{
13351366
Manifest multiLocaleManifest = YamlParser::CreateFromPath(TestDataFile("Manifest-Good-MultiLocale.yaml"));

src/AppInstallerRepositoryCore/AppInstallerRepositoryCore.vcxproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -451,6 +451,8 @@
451451
<ClInclude Include="Rest\Schema\1_6\Json\ManifestDeserializer.h" />
452452
<ClInclude Include="Rest\Schema\1_7\Interface.h" />
453453
<ClInclude Include="Rest\Schema\1_7\Json\ManifestDeserializer.h" />
454+
<ClInclude Include="Rest\Schema\1_9\Interface.h" />
455+
<ClInclude Include="Rest\Schema\1_9\Json\ManifestDeserializer.h" />
454456
<ClInclude Include="Rest\Schema\AuthenticationInfoParser.h" />
455457
<ClInclude Include="Rest\Schema\CommonRestConstants.h" />
456458
<ClInclude Include="Rest\Schema\InformationResponseDeserializer.h" />
@@ -544,6 +546,8 @@
544546
<ClCompile Include="Rest\Schema\1_6\RestInterface_1_6.cpp" />
545547
<ClCompile Include="Rest\Schema\1_7\Json\ManifestDeserializer_1_7.cpp" />
546548
<ClCompile Include="Rest\Schema\1_7\RestInterface_1_7.cpp" />
549+
<ClCompile Include="Rest\Schema\1_9\Json\ManifestDeserializer_1_9.cpp" />
550+
<ClCompile Include="Rest\Schema\1_9\RestInterface_1_9.cpp" />
547551
<ClCompile Include="Rest\Schema\AuthenticationInfoParser.cpp" />
548552
<ClCompile Include="Rest\Schema\InformationResponseDeserializer.cpp" />
549553
<ClCompile Include="Rest\Schema\SearchRequestComposer.cpp" />

src/AppInstallerRepositoryCore/AppInstallerRepositoryCore.vcxproj.filters

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,12 @@
103103
<Filter Include="Microsoft\Schema\2_0">
104104
<UniqueIdentifier>{34442899-29e5-4183-96ba-a1e8740146be}</UniqueIdentifier>
105105
</Filter>
106+
<Filter Include="Rest\Schema\1_9">
107+
<UniqueIdentifier>{8edd7018-8836-4b15-84c1-998391e19038}</UniqueIdentifier>
108+
</Filter>
109+
<Filter Include="Rest\Schema\1_9\Json">
110+
<UniqueIdentifier>{7464e3ff-7a60-4bb6-8806-70562382043b}</UniqueIdentifier>
111+
</Filter>
106112
</ItemGroup>
107113
<ItemGroup>
108114
<ClInclude Include="pch.h">
@@ -462,6 +468,12 @@
462468
<ClInclude Include="Microsoft\SQLiteIndexSourceV2.h">
463469
<Filter>Microsoft</Filter>
464470
</ClInclude>
471+
<ClInclude Include="Rest\Schema\1_9\Json\ManifestDeserializer.h">
472+
<Filter>Rest\Schema\1_9\Json</Filter>
473+
</ClInclude>
474+
<ClInclude Include="Rest\Schema\1_9\Interface.h">
475+
<Filter>Rest\Schema\1_9</Filter>
476+
</ClInclude>
465477
</ItemGroup>
466478
<ItemGroup>
467479
<ClCompile Include="pch.cpp">
@@ -722,6 +734,12 @@
722734
<ClCompile Include="Microsoft\SQLiteIndexSourceV2.cpp">
723735
<Filter>Microsoft</Filter>
724736
</ClCompile>
737+
<ClCompile Include="Rest\Schema\1_9\Json\ManifestDeserializer_1_9.cpp">
738+
<Filter>Rest\Schema\1_9\Json</Filter>
739+
</ClCompile>
740+
<ClCompile Include="Rest\Schema\1_9\RestInterface_1_9.cpp">
741+
<Filter>Rest\Schema\1_9</Filter>
742+
</ClCompile>
725743
</ItemGroup>
726744
<ItemGroup>
727745
<None Include="PropertySheet.props" />

src/AppInstallerRepositoryCore/ManifestJSONParser.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#include "Rest/Schema/1_5/Json/ManifestDeserializer.h"
99
#include "Rest/Schema/1_6/Json/ManifestDeserializer.h"
1010
#include "Rest/Schema/1_7/Json/ManifestDeserializer.h"
11+
#include "Rest/Schema/1_9/Json/ManifestDeserializer.h"
1112

1213
namespace AppInstaller::Repository::JSON
1314
{
@@ -46,10 +47,14 @@ namespace AppInstaller::Repository::JSON
4647
{
4748
m_pImpl->m_deserializer = std::make_unique<Rest::Schema::V1_6::Json::ManifestDeserializer>();
4849
}
49-
else
50+
else if (parts.size() > 1 && parts[1].Integer < 9)
5051
{
5152
m_pImpl->m_deserializer = std::make_unique<Rest::Schema::V1_7::Json::ManifestDeserializer>();
5253
}
54+
else
55+
{
56+
m_pImpl->m_deserializer = std::make_unique<Rest::Schema::V1_9::Json::ManifestDeserializer>();
57+
}
5358
}
5459
else
5560
{

src/AppInstallerRepositoryCore/Rest/RestClient.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#include "Rest/Schema/1_5/Interface.h"
99
#include "Rest/Schema/1_6/Interface.h"
1010
#include "Rest/Schema/1_7/Interface.h"
11+
#include "Rest/Schema/1_9/Interface.h"
1112
#include "Rest/Schema/InformationResponseDeserializer.h"
1213
#include "Rest/Schema/CommonRestConstants.h"
1314
#include <winget/HttpClientHelper.h>
@@ -22,7 +23,7 @@ using namespace AppInstaller::Http;
2223
namespace AppInstaller::Repository::Rest
2324
{
2425
// Supported versions
25-
std::set<Version> WingetSupportedContracts = { Version_1_0_0, Version_1_1_0, Version_1_4_0, Version_1_5_0, Version_1_6_0, Version_1_7_0 };
26+
std::set<Version> WingetSupportedContracts = { Version_1_0_0, Version_1_1_0, Version_1_4_0, Version_1_5_0, Version_1_6_0, Version_1_7_0, Version_1_9_0 };
2627

2728
constexpr std::string_view WindowsPackageManagerHeader = "Windows-Package-Manager"sv;
2829
constexpr size_t WindowsPackageManagerHeaderMaxLength = 1024;
@@ -176,6 +177,10 @@ namespace AppInstaller::Repository::Rest
176177
{
177178
return std::make_unique<Schema::V1_7::Interface>(api, helper, information, additionalHeaders, authArgs);
178179
}
180+
else if (version == Version_1_9_0)
181+
{
182+
return std::make_unique<Schema::V1_9::Interface>(api, helper, information, additionalHeaders, authArgs);
183+
}
179184

180185
THROW_HR(APPINSTALLER_CLI_ERROR_RESTSOURCE_INVALID_VERSION);
181186
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// Copyright (c) Microsoft Corporation.
2+
// Licensed under the MIT License.
3+
#pragma once
4+
#include "Rest/Schema/1_7/Interface.h"
5+
6+
namespace AppInstaller::Repository::Rest::Schema::V1_9
7+
{
8+
// Interface to this schema version exposed through IRestClient.
9+
struct Interface : public V1_7::Interface
10+
{
11+
Interface(const std::string& restApi, const Http::HttpClientHelper& helper, IRestClient::Information information, const Http::HttpClientHelper::HttpRequestHeaders& additionalHeaders = {}, Authentication::AuthenticationArguments authArgs = {});
12+
13+
Interface(const Interface&) = delete;
14+
Interface& operator=(const Interface&) = delete;
15+
16+
Interface(Interface&&) = default;
17+
Interface& operator=(Interface&&) = default;
18+
19+
Utility::Version GetVersion() const override;
20+
};
21+
}

0 commit comments

Comments
 (0)