Skip to content

Commit c094270

Browse files
authored
Merge pull request #1541 from microsoftgraph/po/PagingImprovements
Paging Improvements
2 parents 2fc6c87 + b5c01a8 commit c094270

File tree

2 files changed

+14
-7
lines changed

2 files changed

+14
-7
lines changed

tools/Custom/ListCmdlet.cs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ public void InitializeCmdlet(ref global::System.Management.Automation.Invocation
9898

9999
if (invocationInfo.BoundParameters.ContainsKey("Top"))
100100
{
101-
if ((top > MaxPageSize) || invocationInfo.BoundParameters.ContainsKey("All") || invocationInfo.BoundParameters.ContainsKey("PageSize"))
101+
if ((top > MaxPageSize) || IsAllPresent(invocationInfo.BoundParameters) || invocationInfo.BoundParameters.ContainsKey("PageSize"))
102102
{
103103
limit = top;
104104
}
@@ -116,6 +116,11 @@ public void InitializeCmdlet(ref global::System.Management.Automation.Invocation
116116
top = PageSize;
117117
}
118118
}
119+
else if (invocationInfo.BoundParameters.ContainsKey("PageSize"))
120+
{
121+
invocationInfo.BoundParameters["Top"] = PageSize;
122+
top = PageSize;
123+
}
119124

120125
if ((!invocationInfo.BoundParameters.ContainsKey("Count")) && invocationInfo.BoundParameters.ContainsKey("CountVariable"))
121126
{
@@ -146,7 +151,7 @@ public bool ShouldIteratePages(global::System.Collections.Generic.Dictionary<str
146151
iteratedPages++;
147152
totalFetchedItems += itemsCount;
148153

149-
return (boundParameters.ContainsKey("All") && limit == default) || totalFetchedItems < limit;
154+
return (IsAllPresent(boundParameters) && limit == default) || totalFetchedItems < limit;
150155
}
151156

152157
/// <summary>
@@ -208,5 +213,10 @@ internal void OnBeforeWriteObject(global::System.Collections.Generic.Dictionary<
208213
psVI.Set(new PSVariable(CountVariable.Contains(":") ? CountVariable : $"global:{CountVariable}", odataCount));
209214
}
210215
}
216+
217+
private bool IsAllPresent(global::System.Collections.Generic.Dictionary<string, object> boundParameters)
218+
{
219+
return boundParameters.ContainsKey("All") && All.IsPresent;
220+
}
211221
}
212222
}

tools/GenerateModules.ps1

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -85,11 +85,8 @@ if (!$SkipGeneration)
8585

8686
# Install module locally in order to specify it as a dependency for other modules down the generation pipeline.
8787
# https://stackoverflow.com/questions/46216038/how-do-i-define-requiredmodules-in-a-powershell-module-manifest-psd1.
88-
$ExistingAuthModule = Find-Module "Microsoft.Graph.Authentication" -Repository $RepositoryName -AllowPrerelease:$AllowPreRelease
89-
Write-Host -ForegroundColor Green "Auth Module: $($ExistingAuthModule.Name), $($ExistingAuthModule.Version)"
90-
if (!(Get-Module -Name $ExistingAuthModule.Name -ListAvailable)) {
91-
Install-Module $ExistingAuthModule.Name -Repository $RepositoryName -Force -AllowClobber -AllowPrerelease:$AllowPreRelease
92-
}
88+
$AuthModuleManifest = Join-Path $ModulesOutputDir "Authentication" "Authentication" "artifacts" "Microsoft.Graph.Authentication.psd1"
89+
$ExistingAuthModule = Import-Module $AuthModuleManifest -PassThru -ErrorAction SilentlyContinue
9390
if ($ExistingAuthModule.Version -like '*preview*' ) {
9491
$version = $ExistingAuthModule.Version.Remove($ExistingAuthModule.Version.IndexOf('-'))
9592
Write-Warning "Required Version: $ModulePrefix.$RequiredModule Version: $version"

0 commit comments

Comments
 (0)