-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Create WinGetUtil functionality for running installed package correlation #2221
Conversation
…ext to repository
…rsing; needs AppsAndFeatures exposed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still reading the InstallerMetadataCollectionContext...
.github/actions/spelling/allow.txt
Outdated
@@ -109,6 +109,7 @@ denelon | |||
depersist | |||
deque | |||
deserialize | |||
deserializes | |||
Deserialize |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need both deserialize
and Deserialize
? Isn't it case insensitive?
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">$(ProjectDir);$(ProjectDir)Public;$(ProjectDir)Telemetry;$(ProjectDir)..\binver;$(ProjectDir)..\YamlCppLib\libyaml\include;$(ProjectDir)..\JsonCppLib\json;$(ProjectDir)..\JsonCppLib;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> | ||
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'">$(ProjectDir);$(ProjectDir)Public;$(ProjectDir)Telemetry;$(ProjectDir)..\binver;$(ProjectDir)..\YamlCppLib\libyaml\include;$(ProjectDir)..\JsonCppLib\json;$(ProjectDir)..\JsonCppLib;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> | ||
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(ProjectDir);$(ProjectDir)Public;$(ProjectDir)Telemetry;$(ProjectDir)..\binver;$(ProjectDir)..\YamlCppLib\libyaml\include;$(ProjectDir)..\JsonCppLib\json;$(ProjectDir)..\JsonCppLib;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> | ||
<PreprocessorDefinitions>_NO_ASYNCRTIMP;_DEBUG;%(PreprocessorDefinitions);CLICOREDLLBUILD</PreprocessorDefinitions> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What does _NO_ASYNCRTIMP
do?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It does this in cpprest_compat.h
:
#ifdef _NO_ASYNCRTIMP
#define _ASYNCRTIMP
#else // ^^^ _NO_ASYNCRTIMP ^^^ // vvv !_NO_ASYNCRTIMP vvv
#ifdef _ASYNCRT_EXPORT
#define _ASYNCRTIMP __declspec(dllexport)
#else // ^^^ _ASYNCRT_EXPORT ^^^ // vvv !_ASYNCRT_EXPORT vvv
#define _ASYNCRTIMP __declspec(dllimport)
#endif // _ASYNCRT_EXPORT
#endif // _NO_ASYNCRTIMP
Given that it means we don't import or export the functions tagged with this, we must be compiling them in.
void FromJson(const web::json::value& json); | ||
|
||
// Create a JSON value for the metadata using the given schema version. | ||
web::json::value ToJson(const Utility::Version& version, size_t maximumSizeInBytes); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: Maybe rename version -> schemaVersion? On a first reading I understood it as converting the version to JSON
return AddIfNotPresentAndNotEmpty(strings, strings, string); | ||
} | ||
|
||
void AddIfNotPresent(std::vector<std::string>& strings, std::vector<std::string>& filter, const std::vector<std::string>& inputs) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this is a common operation, why not use a set instead of a vector?
@@ -22,6 +22,7 @@ namespace AppInstaller::Utility | |||
Manifest, | |||
WinGetUtil, | |||
Installer, | |||
InstallerMetadataCollectionInput, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems like the only place where this is used is in the DO download to decide whether to use DO? I saw a comment there explaining why the other types don't use DO. Can you add this one?
|
||
namespace AppInstaller::JSON | ||
{ | ||
// For JSON CPP LIb |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: LIb
|
||
web::json::value GetStringValue(std::string_view value); | ||
|
||
std::vector<std::string> GetRawStringArrayFromJsonNode(const web::json::value& node, const utility::string_t& keyName); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: Could this be higher closer to the other GetRaw... functions?
|
||
utility::string_t GetUtilityString(std::string_view nodeName) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: Why Get instead of To?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's moved from rest helpers and there're a lot of places calling
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed, I only moved these and did not attempt to rename them.
if (success) | ||
{ | ||
break; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does breaking instead of setting success = true
not work?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed it in the code I copied from as well.
} | ||
catch (...) | ||
{ | ||
CollectErrorDataFromException(std::current_exception()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is cool. I didn't know std::current_exception()
existed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's great for making standardized exception handlers.
@@ -129,4 +129,46 @@ extern "C" | |||
WINGET_STRING versionA, | |||
WINGET_STRING versionB, | |||
INT* comparisonResult); | |||
|
|||
// A handle to the metadata collection object. | |||
typedef void* WINGET_INSTALLER_METADATA_COLLECTION_HANDLE; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we? I do like things being defined close to where they are used. If the type is being used in a broad fashion, the top makes sense to me. But if it is used narrowly, then immediately above the use feels better.
@@ -0,0 +1,59 @@ | |||
#pragma once |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: remove
utility::string_t InstallerHash = L"installerHash"; | ||
utility::string_t SubmissionIdentifier = L"submissionIdentifier"; | ||
utility::string_t Version = L"version"; | ||
utility::string_t AppsAndFeaturesEntries = L"AppsAndFeaturesEntries"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is in that those that start with upper case are the same names as from the manifest JSON schema.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OutputStatus statusToUse = m_outputStatus; | ||
if (statusToUse != OutputStatus::Success && statusToUse != OutputStatus::Error && statusToUse != OutputStatus::LowConfidence) | ||
{ | ||
statusToUse = OutputStatus::Unknown; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
} | ||
newEntry.Publisher = package->GetProperty(PackageVersionProperty::Publisher).get(); | ||
// TODO: Support upgrade code throughout the code base... | ||
//newEntry.UpgradeCode; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
{ | ||
TestInput() = default; | ||
|
||
TestInput(MinimalDefaults_t) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you mean a test case with a literal string input and verification as a string output looking for literal values?
@check-spelling-bot ReportUnrecognized words, please review:
Previously acknowledged words that are now absentactivatable amd Archs dsc enr FWW Globals hackathon lww mytool OSVERSION Packagedx parametermap symlink Uninitialize WDAG whatif wsbTo accept these unrecognized words as correct (and remove the previously acknowledged and now absent words), run the following commands... in a clone of the git@github.com:JohnMcPMS/winget-cli.git repository
|
@check-spelling-bot ReportUnrecognized words, please review:
Previously acknowledged words that are now absentactivatable amd Archs dsc enr FWW Globals hackathon lww mytool OSVERSION Packagedx parametermap symlink Uninitialize WDAG whatif wsbTo accept these unrecognized words as correct (and remove the previously acknowledged and now absent words), run the following commands... in a clone of the git@github.com:JohnMcPMS/winget-cli.git repository
|
Change
The goal of this change is to expose functionality to run the installed package correlation and gather the results. This will be used to validate and enhance manifests and allows us to use the same correlation code throughout the system.
The biggest changes to existing code are:
Beyond those changes, the majority of the work is in creating the JSON (de)serialization and handling updating the metadata that has been collected.
More work is still needed to:
Validation
Unit tests are added covering scenarios around updating the metadata with results.
Microsoft Reviewers: Open in CodeFlow