@@ -99,7 +99,7 @@ public V3ServerAPICalls(PSRepositoryInfo repository, PSCmdlet cmdletPassedIn, Ne
9999 public override Task < FindResults > FindVersionAsync ( string packageName , string version , ResourceType type , ConcurrentQueue < ErrorRecord > errorMsgs , ConcurrentQueue < string > warningMsgs , ConcurrentQueue < string > debugMsgs , ConcurrentQueue < string > verboseMsgs )
100100 {
101101 debugMsgs . Enqueue ( "In V3ServerAPICalls::FindVersionAsync()" ) ;
102- FindResults findResponse = FindVersionHelper ( packageName , version , tags : Utils . EmptyStrArray , type , out ErrorRecord errRecord ) ;
102+ FindResults findResponse = FindVersionHelper ( packageName , version , tags : Utils . EmptyStrArray , type , out ErrorRecord errRecord , debugMsgs ) ;
103103 if ( errRecord != null )
104104 {
105105 errorMsgs . Enqueue ( errRecord ) ;
@@ -119,7 +119,7 @@ public override Task<FindResults> FindVersionAsync(string packageName, string ve
119119 public override Task < FindResults > FindVersionGlobbingAsync ( string packageName , VersionRange versionRange , bool includePrerelease , ResourceType type , bool getOnlyLatest , ConcurrentQueue < ErrorRecord > errorMsgs , ConcurrentQueue < string > warningMsgs , ConcurrentQueue < string > debugMsgs , ConcurrentQueue < string > verboseMsgs )
120120 {
121121 debugMsgs . Enqueue ( "In V3ServerAPICalls::FindVersionGlobbingAsync()" ) ;
122- FindResults findResponse = FindVersionGlobbing ( packageName , versionRange , includePrerelease , type , getOnlyLatest , out ErrorRecord errRecord ) ;
122+ FindResults findResponse = FindVersionGlobbingHelper ( packageName , versionRange , includePrerelease , type , getOnlyLatest , out ErrorRecord errRecord , debugMsgs ) ;
123123 if ( errRecord != null )
124124 {
125125 errorMsgs . Enqueue ( errRecord ) ;
@@ -204,7 +204,7 @@ public override FindResults FindName(string packageName, bool includePrerelease,
204204 public override Task < FindResults > FindNameAsync ( string packageName , bool includePrerelease , ResourceType type , ConcurrentQueue < ErrorRecord > errorMsgs , ConcurrentQueue < string > warningMsgs , ConcurrentQueue < string > debugMsgs , ConcurrentQueue < string > verboseMsgs )
205205 {
206206 debugMsgs . Enqueue ( "In V3ServerAPICalls::FindNameAsync()" ) ;
207- FindResults findResponse = FindNameHelper ( packageName , tags : Utils . EmptyStrArray , includePrerelease , type , out ErrorRecord errRecord ) ;
207+ FindResults findResponse = FindNameHelper ( packageName , tags : Utils . EmptyStrArray , includePrerelease , type , out ErrorRecord errRecord , debugMsgs ) ;
208208 if ( errRecord != null )
209209 {
210210 errorMsgs . Enqueue ( errRecord ) ;
@@ -281,9 +281,13 @@ public override FindResults FindNameGlobbingWithTag(string packageName, string[]
281281 /// </summary>
282282 public override FindResults FindVersionGlobbing ( string packageName , VersionRange versionRange , bool includePrerelease , ResourceType type , bool getOnlyLatest , out ErrorRecord errRecord )
283283 {
284- // TODO: pass in ConcurrentQueue for debug messages so this is thread-safe when called from FindVersionGlobbingAsync().
285- _cmdletPassedIn . WriteDebug ( "In V3ServerAPICalls::FindVersionGlobbing()" ) ;
286- string [ ] versionedResponses = GetVersionedPackageEntriesFromRegistrationsResource ( packageName , catalogEntryProperty , isSearch : true , out errRecord ) ;
284+ return FindVersionGlobbingHelper ( packageName , versionRange , includePrerelease , type , getOnlyLatest , out errRecord ) ;
285+ }
286+
287+ private FindResults FindVersionGlobbingHelper ( string packageName , VersionRange versionRange , bool includePrerelease , ResourceType type , bool getOnlyLatest , out ErrorRecord errRecord , ConcurrentQueue < string > debugMsgs = null )
288+ {
289+ WriteDebug ( "In V3ServerAPICalls::FindVersionGlobbing()" , debugMsgs ) ;
290+ string [ ] versionedResponses = GetVersionedPackageEntriesFromRegistrationsResource ( packageName , catalogEntryProperty , isSearch : true , out errRecord , debugMsgs ) ;
287291 if ( errRecord != null )
288292 {
289293 return new FindResults ( stringResponse : Utils . EmptyStrArray , hashtableResponse : emptyHashResponses , responseType : v3FindResponseType ) ;
@@ -310,8 +314,7 @@ public override FindResults FindVersionGlobbing(string packageName, VersionRange
310314
311315 if ( NuGetVersion . TryParse ( pkgVersionElement . ToString ( ) , out NuGetVersion pkgVersion ) && versionRange . Satisfies ( pkgVersion ) )
312316 {
313- // TODO: pass in ConcurrentQueue for debug messages so this is thread-safe when called from FindVersionGlobbingAsync(). ?
314- _cmdletPassedIn . WriteDebug ( $ "Package version parsed as '{ pkgVersion } ' satisfies the version range") ;
317+ WriteDebug ( $ "Package version parsed as '{ pkgVersion } ' satisfies the version range", debugMsgs ) ;
315318 if ( ! pkgVersion . IsPrerelease || includePrerelease )
316319 {
317320 satisfyingVersions . Add ( response ) ;
@@ -581,11 +584,10 @@ private FindResults FindTagsFromNuGetRepo(string[] tags, bool includePrerelease,
581584 /// <summary>
582585 /// Helper method called by FindName() and FindNameWithTag()
583586 /// <summary>
584- private FindResults FindNameHelper ( string packageName , string [ ] tags , bool includePrerelease , ResourceType type , out ErrorRecord errRecord )
587+ private FindResults FindNameHelper ( string packageName , string [ ] tags , bool includePrerelease , ResourceType type , out ErrorRecord errRecord , ConcurrentQueue < string > debugMsgs = null )
585588 {
586- // TODO: pass in ConcurrentQueue for debug messages so this is thread-safe when called from FindNameAsync(). ?
587- _cmdletPassedIn . WriteDebug ( "In V3ServerAPICalls::FindNameHelper()" ) ;
588- string [ ] versionedResponses = GetVersionedPackageEntriesFromRegistrationsResource ( packageName , catalogEntryProperty , isSearch : true , out errRecord ) ;
589+ WriteDebug ( "In V3ServerAPICalls::FindNameHelper()" , debugMsgs ) ;
590+ string [ ] versionedResponses = GetVersionedPackageEntriesFromRegistrationsResource ( packageName , catalogEntryProperty , isSearch : true , out errRecord , debugMsgs ) ;
589591 if ( errRecord != null )
590592 {
591593 return new FindResults ( stringResponse : Utils . EmptyStrArray , hashtableResponse : emptyHashResponses , responseType : v3FindResponseType ) ;
@@ -623,8 +625,7 @@ private FindResults FindNameHelper(string packageName, string[] tags, bool inclu
623625
624626 if ( NuGetVersion . TryParse ( pkgVersionElement . ToString ( ) , out NuGetVersion pkgVersion ) )
625627 {
626- // ?
627- _cmdletPassedIn . WriteDebug ( $ "'{ packageName } ' version parsed as '{ pkgVersion } '") ;
628+ WriteDebug ( $ "'{ packageName } ' version parsed as '{ pkgVersion } '", debugMsgs ) ;
628629 if ( ! pkgVersion . IsPrerelease || includePrerelease )
629630 {
630631 // Versions are always in descending order i.e 5.0.0, 3.0.0, 1.0.0 so grabbing the first match suffices
@@ -679,10 +680,9 @@ private FindResults FindNameHelper(string packageName, string[] tags, bool inclu
679680 /// <summary>
680681 /// Helper method called by FindVersion() and FindVersionWithTag()
681682 /// </summary>
682- private FindResults FindVersionHelper ( string packageName , string version , string [ ] tags , ResourceType type , out ErrorRecord errRecord )
683+ private FindResults FindVersionHelper ( string packageName , string version , string [ ] tags , ResourceType type , out ErrorRecord errRecord , ConcurrentQueue < string > debugMsgs = null )
683684 {
684- // TODO: pass in ConcurrentQueue for debug messages so this is thread-safe when called from FindVersionAsync(). ?
685- _cmdletPassedIn . WriteDebug ( "In V3ServerAPICalls::FindVersionHelper()" ) ;
685+ WriteDebug ( "In V3ServerAPICalls::FindVersionHelper()" , debugMsgs ) ;
686686 if ( ! NuGetVersion . TryParse ( version , out NuGetVersion requiredVersion ) )
687687 {
688688 errRecord = new ErrorRecord (
@@ -695,7 +695,7 @@ private FindResults FindVersionHelper(string packageName, string version, string
695695 }
696696 //_cmdletPassedIn.WriteDebug($"'{packageName}' version parsed as '{requiredVersion}'");
697697
698- string [ ] versionedResponses = GetVersionedPackageEntriesFromRegistrationsResource ( packageName , catalogEntryProperty , isSearch : true , out errRecord ) ;
698+ string [ ] versionedResponses = GetVersionedPackageEntriesFromRegistrationsResource ( packageName , catalogEntryProperty , isSearch : true , out errRecord , debugMsgs ) ;
699699 if ( errRecord != null )
700700 {
701701 return new FindResults ( stringResponse : Utils . EmptyStrArray , hashtableResponse : emptyHashResponses , responseType : v3FindResponseType ) ;
@@ -989,7 +989,7 @@ private async Task<Stream> InstallHelperAsync(string packageName, NuGetVersion v
989989 /// i.e when the package Name being searched for does not contain wildcard
990990 /// This is called by FindNameHelper(), FindVersionHelper(), FindVersionGlobbing(), InstallHelper()
991991 /// </summary>
992- private string [ ] GetVersionedPackageEntriesFromRegistrationsResource ( string packageName , string propertyName , bool isSearch , out ErrorRecord errRecord )
992+ private string [ ] GetVersionedPackageEntriesFromRegistrationsResource ( string packageName , string propertyName , bool isSearch , out ErrorRecord errRecord , ConcurrentQueue < string > debugMsgs = null )
993993 {
994994 // TODO: pass in ConcurrentQueue to write out debug message.
995995 //_cmdletPassedIn.WriteDebug("In V3ServerAPICalls::GetVersionedPackageEntriesFromRegistrationsResource()");
@@ -1006,7 +1006,7 @@ private string[] GetVersionedPackageEntriesFromRegistrationsResource(string pack
10061006 return responses ;
10071007 }
10081008
1009- responses = GetVersionedResponsesFromRegistrationsResource ( registrationsBaseUrl , packageName , propertyName , isSearch , out errRecord ) ;
1009+ responses = GetVersionedResponsesFromRegistrationsResource ( registrationsBaseUrl , packageName , propertyName , isSearch , out errRecord , debugMsgs ) ;
10101010 if ( errRecord != null )
10111011 {
10121012 return Utils . EmptyStrArray ;
@@ -1452,7 +1452,7 @@ private string[] GetMetadataElementsFromResponse(string response, string propert
14521452 /// The "packageContent" property is used for download, and the value is a URI for the .nupkg file.
14531453 /// </param>
14541454 /// <summary>
1455- private string [ ] GetVersionedResponsesFromRegistrationsResource ( string registrationsBaseUrl , string packageName , string property , bool isSearch , out ErrorRecord errRecord )
1455+ private string [ ] GetVersionedResponsesFromRegistrationsResource ( string registrationsBaseUrl , string packageName , string property , bool isSearch , out ErrorRecord errRecord , ConcurrentQueue < string > debugMsgs = null )
14561456 {
14571457 // TODO: pass in ConcurrentQueue to write out debug message.
14581458 //_cmdletPassedIn.WriteDebug("In V3ServerAPICalls::GetVersionedResponsesFromRegistrationsResource()");
@@ -1490,7 +1490,7 @@ private string[] GetVersionedResponsesFromRegistrationsResource(string registrat
14901490
14911491 if ( isSearch )
14921492 {
1493- if ( ! IsLatestVersionFirstForSearch ( versionedResponseArr , out errRecord ) )
1493+ if ( ! IsLatestVersionFirstForSearch ( versionedResponseArr , out errRecord , debugMsgs ) )
14941494 {
14951495 Array . Reverse ( versionedResponseArr ) ;
14961496 }
@@ -1511,10 +1511,9 @@ private string[] GetVersionedResponsesFromRegistrationsResource(string registrat
15111511 /// ADO feeds usually return version entries in descending order, but Nuget.org repository returns them in ascending order.
15121512 /// Package versions will reflect prerelease preference, but upper version and lower version would not so we don't use them for comparison.
15131513 /// </summary>
1514- private bool IsLatestVersionFirstForSearch ( string [ ] versionedResponses , out ErrorRecord errRecord )
1514+ private bool IsLatestVersionFirstForSearch ( string [ ] versionedResponses , out ErrorRecord errRecord , ConcurrentQueue < string > debugMsgs = null )
15151515 {
1516- // TODO: pass in ConcurrentQueue for debug messages so this is thread-safe when reached from the async find methods. ?
1517- _cmdletPassedIn . WriteDebug ( "In V3ServerAPICalls::IsLatestVersionFirstForSearch()" ) ;
1516+ WriteDebug ( "In V3ServerAPICalls::IsLatestVersionFirstForSearch()" , debugMsgs ) ;
15181517 errRecord = null ;
15191518 bool latestVersionFirst = true ;
15201519 int versionResponsesCount = versionedResponses . Length ;
@@ -1606,6 +1605,18 @@ private bool IsLatestVersionFirstForSearch(string[] versionedResponses, out Erro
16061605 return latestVersionFirst ;
16071606 }
16081607
1608+ private void WriteDebug ( string message , ConcurrentQueue < string > debugMsgs = null )
1609+ {
1610+ if ( debugMsgs == null )
1611+ {
1612+ _cmdletPassedIn . WriteDebug ( message ) ;
1613+ }
1614+ else
1615+ {
1616+ debugMsgs . Enqueue ( message ) ;
1617+ }
1618+ }
1619+
16091620 /// <summary>
16101621 /// Returns true if the nupkg URI entries for each package version are arranged in descending order with respect to the package's version.
16111622 /// ADO feeds usually return version entries in descending order, but Nuget.org repository returns them in ascending order.
0 commit comments