From 75876ad766fdb8df9ff8e0f9ed1afaedd743a365 Mon Sep 17 00:00:00 2001 From: Thomas Nieto <38873752+ThomasNieto@users.noreply.github.com> Date: Tue, 10 Dec 2024 13:41:08 -0600 Subject: [PATCH] Refactor GetPackage --- src/code/MsiProvider.cs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/code/MsiProvider.cs b/src/code/MsiProvider.cs index 4dee41b..bfa4dad 100644 --- a/src/code/MsiProvider.cs +++ b/src/code/MsiProvider.cs @@ -28,6 +28,14 @@ public void FindPackage(PackageRequest request) } public void GetPackage(PackageRequest request) + { + foreach (var package in GetPackageImpl(request)) + { + request.WritePackage(package); + } + } + + private IEnumerable GetPackageImpl(PackageRequest request) { using var powershell = PowerShell.Create(RunspaceMode.CurrentRunspace); powershell.AddCommand("Get-Package") @@ -62,15 +70,13 @@ public void GetPackage(PackageRequest request) source = null; } - var package = new PackageInfo(result.Name, + yield return new PackageInfo(result.Name, result.Version, source, result.Description, dependencies: null, result.Metadata.ToDictionary(x => x.Key, x => x.Value), ProviderInfo); - - request.WritePackage(package); } }