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

Draft API proposal for #888 Support for UWP callers and a non command line interface API #889

Merged
merged 11 commits into from
Aug 27, 2021

Conversation

sreadingMSFT
Copy link
Contributor

@sreadingMSFT sreadingMSFT commented Apr 22, 2021

I'll be sharing this with the API design review team and will update this when that review has a scheduled date.

See the Files Changed tab for the Com Api.md.

Microsoft Reviewers: Open in CodeFlow

Merge microsoft/winget-cli changes.
Rest endpoint helper and json object field check - Bug fix (microsoft#821)
@github-actions
Copy link

Misspellings found, please review:

  • abifind
  • IApp
  • IFind
  • IGet
  • iinstall
  • implememented
  • MIDL
  • pseudocode
  • runtimeclass
  • UAC
  • Xaml
To accept these changes, run the following commands from this repository on this branch
pushd $(git rev-parse --show-toplevel)
perl -e '
my @expect_files=qw('".github/actions/spelling/expect.txt"');
@ARGV=@expect_files;
my @stale=qw('"IInstalled validator valijson valueiterator "');
my $re=join "|", @stale;
my $suffix=".".time();
my $previous="";
sub maybe_unlink { unlink($_[0]) if $_[0]; }
while (<>) {
  if ($ARGV ne $old_argv) { maybe_unlink($previous); $previous="$ARGV$suffix"; rename($ARGV, $previous); open(ARGV_OUT, ">$ARGV"); select(ARGV_OUT); $old_argv = $ARGV; }
  next if /^(?:$re)(?:(?:\r|\n)*$| .*)/; print;
}; maybe_unlink($previous);'
perl -e '
my $new_expect_file=".github/actions/spelling/expect.txt";
use File::Path qw(make_path);
make_path ".github/actions/spelling";
open FILE, q{<}, $new_expect_file; chomp(my @words = <FILE>); close FILE;
my @add=qw('"abifind IApp IFind IGet iinstall implememented MIDL pseudocode runtimeclass UAC Xaml "');
my %items; @items{@words} = @words x (1); @items{@add} = @add x (1);
@words = sort {lc($a) cmp lc($b)} keys %items;
open FILE, q{>}, $new_expect_file; for my $word (@words) { print FILE "$word\n" if $word =~ /\w/; };
close FILE;'
popd

doc/specs/#888 - Com Api.md Outdated Show resolved Hide resolved
doc/specs/#888 - Com Api.md Outdated Show resolved Hide resolved
doc/specs/#888 - Com Api.md Outdated Show resolved Hide resolved
doc/specs/#888 - Com Api.md Outdated Show resolved Hide resolved
doc/specs/#888 - Com Api.md Show resolved Hide resolved
doc/specs/#888 - Com Api.md Outdated Show resolved Hide resolved
doc/specs/#888 - Com Api.md Outdated Show resolved Hide resolved
doc/specs/#888 - Com Api.md Outdated Show resolved Hide resolved
doc/specs/#888 - Com Api.md Outdated Show resolved Hide resolved
doc/specs/#888 - Com Api.md Outdated Show resolved Hide resolved
@denelon denelon linked an issue Apr 23, 2021 that may be closed by this pull request
Copy link
Contributor

@jsoref jsoref left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The other items should just be added to expect.txt/allow.txt

doc/specs/#888 - Com Api.md Outdated Show resolved Hide resolved
First pass of updates from jonwis feedback.
@github-actions
Copy link

Misspellings found, please review:

  • apicontract
  • contractversion
  • rclsid
  • recieve
  • REFCLSID
  • TOutput
To accept these changes, run the following commands from this repository on this branch
pushd $(git rev-parse --show-toplevel)
perl -e '
my @expect_files=qw('".github/actions/spelling/expect.txt"');
@ARGV=@expect_files;
my @stale=qw('"validator valijson valueiterator "');
my $re=join "|", @stale;
my $suffix=".".time();
my $previous="";
sub maybe_unlink { unlink($_[0]) if $_[0]; }
while (<>) {
  if ($ARGV ne $old_argv) { maybe_unlink($previous); $previous="$ARGV$suffix"; rename($ARGV, $previous); open(ARGV_OUT, ">$ARGV"); select(ARGV_OUT); $old_argv = $ARGV; }
  next if /^(?:$re)(?:(?:\r|\n)*$| .*)/; print;
}; maybe_unlink($previous);'
perl -e '
my $new_expect_file=".github/actions/spelling/expect.txt";
use File::Path qw(make_path);
make_path ".github/actions/spelling";
open FILE, q{<}, $new_expect_file; chomp(my @words = <FILE>); close FILE;
my @add=qw('"apicontract contractversion rclsid recieve REFCLSID TOutput "');
my %items; @items{@words} = @words x (1); @items{@add} = @add x (1);
@words = sort {lc($a) cmp lc($b)} keys %items;
open FILE, q{>}, $new_expect_file; for my $word (@words) { print FILE "$word\n" if $word =~ /\w/; };
close FILE;'
popd

doc/specs/#888 - Com Api.md Outdated Show resolved Hide resolved
@github-actions

This comment has been minimized.

Copy link
Member

@jonwis jonwis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems OK to start API review, invite coming soon.

installOptions.Package(package);
installOptions.InstallMode(InstallMode::Silent);

return appInstaller.InstallPackageAsync(installOptions);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oopsie, you're right.

{
AppInstaller appInstaller = CreateAppInstaller();
AppCatalog catalog{ co_await appInstaller.GetAppCatalogAsync(packageSource) };
co_await catalog.OpenAsync();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See https://www.osgwiki.com/wiki/WinRT_API_Design_Guidelines#Specifying_Asynchronous_Operation_Objects_in_IDL (non-MSFT folks, I hope to have these publicly visible soon) for how to do it. The issue is that we want people to not wrap all their operations in try/catch. When an operation fails and returns an hresult it generates an exception in most langauges, so you'd have to write this:

AppCatalog ac{nullptr};
winrt::hresult ecode;
try {
    ac = co_await foo.FindSource(sourceName);
} catch (winrt::hresult_exception const& ex) {
    ecode = ex.code();
}
if (!ac) {
    // do something with 'ecode'
} else {
    // catalog ready
}

Compare that to:

FindAppCatalogResult found = co_await thing.FindSource(sourceName);
if (found.Catalog) {
    // use found.Catalog
} else {
    switch (found.Status()) {
    case FindCatalogResultStatus::AccessDenied:
    case FindCatalogResultStatus::NotFound:
    case FindCatalogResultStatus::ServerError:
    case FindCatalogResultStatus::MalformedResponse:
        // do whatever with those
        return;
    case FindCatalogResultStatus::Unknown:
        // Send telemetry using found.ExtendedError();
        return;
    }
}

doc/specs/#888 - Com Api.md Show resolved Hide resolved
doc/specs/#888 - Com Api.md Outdated Show resolved Hide resolved
doc/specs/#888 - Com Api.md Show resolved Hide resolved
doc/specs/#888 - Com Api.md Show resolved Hide resolved
doc/specs/#888 - Com Api.md Outdated Show resolved Hide resolved
doc/specs/#888 - Com Api.md Outdated Show resolved Hide resolved
doc/specs/#888 - Com Api.md Outdated Show resolved Hide resolved
doc/specs/#888 - Com Api.md Outdated Show resolved Hide resolved
doc/specs/#888 - Com Api.md Outdated Show resolved Hide resolved
doc/specs/#888 - Com Api.md Outdated Show resolved Hide resolved
Copy link
Member

@jonwis jonwis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

API review Left off on about line 486.

doc/specs/#888 - Com Api.md Show resolved Hide resolved
doc/specs/#888 - Com Api.md Outdated Show resolved Hide resolved
AppInstaller CreateAppInstaller() {
return ActivateByCoCreate<AppInstaller>(CLSID_AppInstaller);
}
InstallOptions CreateInstallOptions() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CONSIDER: Ask COM team if it's possible to have a DLL from the package loaded into the packaged-COM client to put the "brains" of the option object into the client side.

CONSIDER: Define a "low level" valueset based interface, and there's a Reunion wrapper that has the better thing that can be loaded into the caller.

filter.Field(PackageMatchField::Id);
filter.Type(MatchType::Exact);
filter.Value(packageId);
findPackagesOptions.Filters().Append(filter);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DISCUSSION: Yes, we should look into how we can reduce this set of calls

doc/specs/#888 - Com Api.md Show resolved Hide resolved
doc/specs/#888 - Com Api.md Show resolved Hide resolved
doc/specs/#888 - Com Api.md Show resolved Hide resolved
doc/specs/#888 - Com Api.md Show resolved Hide resolved
doc/specs/#888 - Com Api.md Outdated Show resolved Hide resolved
doc/specs/#888 - Com Api.md Outdated Show resolved Hide resolved
@github-actions
Copy link

Misspellings found, please review:

  • contoso
  • msdn
  • pkgmgr
To accept these changes, run the following commands from this repository on this branch
pushd $(git rev-parse --show-toplevel)
perl -e '
my @expect_files=qw('".github/actions/spelling/expect.txt"');
@ARGV=@expect_files;
my @stale=qw('"MIDL validator valijson valueiterator "');
my $re=join "|", @stale;
my $suffix=".".time();
my $previous="";
sub maybe_unlink { unlink($_[0]) if $_[0]; }
while (<>) {
  if ($ARGV ne $old_argv) { maybe_unlink($previous); $previous="$ARGV$suffix"; rename($ARGV, $previous); open(ARGV_OUT, ">$ARGV"); select(ARGV_OUT); $old_argv = $ARGV; }
  next if /^(?:$re)(?:(?:\r|\n)*$| .*)/; print;
}; maybe_unlink($previous);'
perl -e '
my $new_expect_file=".github/actions/spelling/expect.txt";
use File::Path qw(make_path);
make_path ".github/actions/spelling";
open FILE, q{<}, $new_expect_file; chomp(my @words = <FILE>); close FILE;
my @add=qw('"contoso midl msdn pkgmgr "');
my %items; @items{@words} = @words x (1); @items{@add} = @add x (1);
@words = sort {lc($a) cmp lc($b)} keys %items;
open FILE, q{>}, $new_expect_file; for my $word (@words) { print FILE "$word\n" if $word =~ /\w/; };
close FILE;'
popd

/// The name of the app catalog.
String Name { get; };
/// The type of the app catalog.
String Type { get; };
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DISCUSSION: This is set when someone adds a catalog at the command line. It should be an open-ended set.

RECOMMEND: Use the KnownFoo pattern, where you have KnownAppCatalogKinds::Rest which is a static property whose value can be assigned here. (Apply this more places.)

doc/specs/#888 - Com Api.md Outdated Show resolved Hide resolved
[contract(Microsoft.Management.Deployment.WindowsPackageManagerContract, 1)]
enum PackageVersionMetadata
{
/// The InstallerType of an installed package
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Recommend: Use the KnownAppInstallerKinds pattern here as well

doc/specs/#888 - Com Api.md Show resolved Hide resolved
doc/specs/#888 - Com Api.md Show resolved Hide resolved
doc/specs/#888 - Com Api.md Outdated Show resolved Hide resolved
doc/specs/#888 - Com Api.md Outdated Show resolved Hide resolved
doc/specs/#888 - Com Api.md Show resolved Hide resolved
doc/specs/#888 - Com Api.md Outdated Show resolved Hide resolved
[contract(Microsoft.Management.Deployment.WindowsPackageManagerContract, 1)]
runtimeclass AppInstaller
{
AppInstaller();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DISCUSSION: See earlier comments about CoCreate vs RoActivate here

@JohnMcPMS
Copy link
Member

@sreadingMSFT , can we get the spelling fixes and merge this?

@sreadingMSFT sreadingMSFT marked this pull request as ready for review August 18, 2021 21:28
@sreadingMSFT sreadingMSFT requested a review from a team as a code owner August 18, 2021 21:28
@denelon
Copy link
Contributor

denelon commented Aug 25, 2021

#888

@denelon denelon linked an issue Aug 25, 2021 that may be closed by this pull request
@JohnMcPMS JohnMcPMS merged commit e50438e into microsoft:master Aug 27, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support for UWP callers and a non command line interface API