Skip to content
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: 2 additions & 0 deletions src/AppInstallerCLICore/AppInstallerCLICore.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,7 @@
<ClInclude Include="Commands\DscCommandBase.h" />
<ClInclude Include="Commands\DscComposableObject.h" />
<ClInclude Include="Commands\DscPackageResource.h" />
<ClInclude Include="Commands\DscSourceResource.h" />
<ClInclude Include="Commands\DscTestFileResource.h" />
<ClInclude Include="Commands\DscTestJsonResource.h" />
<ClInclude Include="Commands\ErrorCommand.h" />
Expand Down Expand Up @@ -392,6 +393,7 @@
<ClCompile Include="Commands\DscCommandBase.cpp" />
<ClCompile Include="Commands\DscComposableObject.cpp" />
<ClCompile Include="Commands\DscPackageResource.cpp" />
<ClCompile Include="Commands\DscSourceResource.cpp" />
<ClCompile Include="Commands\DscTestFileResource.cpp" />
<ClCompile Include="Commands\DscTestJsonResource.cpp" />
<ClCompile Include="Commands\ErrorCommand.cpp" />
Expand Down
6 changes: 6 additions & 0 deletions src/AppInstallerCLICore/AppInstallerCLICore.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,9 @@
<ClInclude Include="Commands\DscPackageResource.h">
<Filter>Commands\Configuration</Filter>
</ClInclude>
<ClInclude Include="Commands\DscSourceResource.h">
<Filter>Commands\Configuration</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="pch.cpp">
Expand Down Expand Up @@ -535,6 +538,9 @@
<ClCompile Include="Commands\DscPackageResource.cpp">
<Filter>Commands\Configuration</Filter>
</ClCompile>
<ClCompile Include="Commands\DscSourceResource.cpp">
<Filter>Commands\Configuration</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<None Include="PropertySheet.props" />
Expand Down
2 changes: 2 additions & 0 deletions src/AppInstallerCLICore/Commands/DscCommand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include "pch.h"
#include "DscCommand.h"
#include "DscPackageResource.h"
#include "DscSourceResource.h"

#ifndef AICLI_DISABLE_TEST_HOOKS
#include "DscTestFileResource.h"
Expand All @@ -15,6 +16,7 @@ namespace AppInstaller::CLI
{
return InitializeFromMoveOnly<std::vector<std::unique_ptr<Command>>>({
std::make_unique<DscPackageResource>(FullName()),
std::make_unique<DscSourceResource>(FullName()),
#ifndef AICLI_DISABLE_TEST_HOOKS
std::make_unique<DscTestFileResource>(FullName()),
std::make_unique<DscTestJsonResource>(FullName()),
Expand Down
20 changes: 10 additions & 10 deletions src/AppInstallerCLICore/Commands/DscComposableObject.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,13 +101,13 @@ namespace AppInstaller::CLI
//
// struct Property
// {
// using Type = { bool, std::string };
// using PropertyType = { bool, std::string };
// static std::string_view Name();
// static void FromJson(Property*, const Json::Value*);
// static std::optional<Json::Value> ToJson(const Property*);
//
// const Type& PROPERTY_NAME() const;
// void PROPERTY_NAME(const Type&);
// const PropertyType& PROPERTY_NAME() const;
// void PROPERTY_NAME(const PropertyType&);
// }
template <typename... Property>
struct DscComposableObject : public Property...
Expand Down Expand Up @@ -149,15 +149,15 @@ namespace AppInstaller::CLI
static Json::Value Schema(const std::string& title)
{
Json::Value result = details::GetBaseSchema(title);
(FoldHelper{}, ..., details::AddPropertySchema(result, Property::Name(), Property::Flags, GetJsonTypeValue<typename Property::Type>::SchemaType(), Property::Description(), Property::EnumValues(), Property::Default()));
(FoldHelper{}, ..., details::AddPropertySchema(result, Property::Name(), Property::Flags, GetJsonTypeValue<typename Property::PropertyType>::SchemaType(), Property::Description(), Property::EnumValues(), Property::Default()));
return result;
}
};

template <typename Derived, typename PropertyType, DscComposablePropertyFlag PropertyFlags>
template <typename Derived, typename PropertyTypeT, DscComposablePropertyFlag PropertyFlags>
struct DscComposableProperty
{
using Type = PropertyType;
using PropertyType = PropertyTypeT;
static constexpr DscComposablePropertyFlag Flags = PropertyFlags;

static void FromJson(Derived* self, const Json::Value* value, bool ignoreFieldRequirements)
Expand Down Expand Up @@ -201,7 +201,7 @@ namespace AppInstaller::CLI
}

protected:
std::optional<Type> m_value;
std::optional<PropertyType> m_value;
};

#define WINGET_DSC_DEFINE_COMPOSABLE_PROPERTY_IMPL_START(_property_type_, _value_type_, _property_name_, _json_name_, _flags_, _description_, _enum_vals_, _default_) \
Expand All @@ -211,9 +211,9 @@ namespace AppInstaller::CLI
static Resource::LocString Description() { return _description_; } \
static std::vector<std::string> EnumValues() { return std::vector<std::string> _enum_vals_; } \
static std::optional<std::string> Default() { return _default_; } \
std::optional<Type>& _property_name_() { return m_value; } \
const std::optional<Type>& _property_name_() const { return m_value; } \
void _property_name_(std::optional<Type> value) { m_value = std::move(value); } \
std::optional<PropertyType>& _property_name_() { return m_value; } \
const std::optional<PropertyType>& _property_name_() const { return m_value; } \
void _property_name_(std::optional<PropertyType> value) { m_value = std::move(value); } \

#define WINGET_DSC_DEFINE_COMPOSABLE_PROPERTY_IMPL(_property_type_, _value_type_, _property_name_, _json_name_, _flags_, _description_, _enum_vals_, _default_) \
WINGET_DSC_DEFINE_COMPOSABLE_PROPERTY_IMPL_START(_property_type_, _value_type_, _property_name_, _json_name_, _flags_, _description_, _enum_vals_, _default_) \
Expand Down
2 changes: 1 addition & 1 deletion src/AppInstallerCLICore/Commands/DscPackageResource.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ namespace AppInstaller::CLI
WINGET_DSC_DEFINE_COMPOSABLE_PROPERTY_ENUM(MatchOptionProperty, std::string, MatchOption, "matchOption", Resource::String::DscResourcePropertyDescriptionPackageMatchOption, ({ "equals", "equalsCaseInsensitive", "startsWithCaseInsensitive", "containsCaseInsensitive" }), "equalsCaseInsensitive");
WINGET_DSC_DEFINE_COMPOSABLE_PROPERTY_DEFAULT(UseLatestProperty, bool, UseLatest, "useLatest", Resource::String::DscResourcePropertyDescriptionPackageUseLatest, "false");
WINGET_DSC_DEFINE_COMPOSABLE_PROPERTY_ENUM(InstallModeProperty, std::string, InstallMode, "installMode", Resource::String::DscResourcePropertyDescriptionPackageInstallMode, ({ "default", "silent", "interactive" }), "silent");
WINGET_DSC_DEFINE_COMPOSABLE_PROPERTY(AcceptAgreementsProperty, bool, AcceptAgreements, "acceptAgreements", Resource::String::DscResourcePropertyDescriptionPackageAcceptAgreements);
WINGET_DSC_DEFINE_COMPOSABLE_PROPERTY(AcceptAgreementsProperty, bool, AcceptAgreements, "acceptAgreements", Resource::String::DscResourcePropertyDescriptionAcceptAgreements);

// TODO: To support Scope on this resource:
// 1. Change the installed source to pull in all package info for both scopes by default
Expand Down
Loading