@@ -128,10 +128,12 @@ protected override async Task<string> GetAssetsFilePathAsync(bool shouldThrow)
128128 return ( new [ ] { packageSpec } , null ) ;
129129 }
130130
131- private async Task < Dictionary < string , CentralPackageVersion > > GetCentralPackageVersionsAsync ( )
131+ private Dictionary < string , CentralPackageVersion > GetCentralPackageVersions ( )
132132 {
133+ ThreadHelper . ThrowIfNotOnUIThread ( ) ;
134+
133135 IEnumerable < ( string PackageId , string Version ) > packageVersions =
134- ( await _vsProjectAdapter . GetBuildItemInformationAsync ( ProjectBuildProperties . PackageVersion , ProjectBuildProperties . Version ) )
136+ _vsProjectAdapter . GetBuildItemInformation ( ProjectBuildProperties . PackageVersion , ProjectBuildProperties . Version )
135137 . Select ( item => ( PackageId : item . ItemId , Version : item . ItemMetadata . FirstOrDefault ( ) ) ) ;
136138
137139 return packageVersions
@@ -156,6 +158,57 @@ private CentralPackageVersion ToCentralPackageVersion(string packageId, string v
156158 return new CentralPackageVersion ( packageId , VersionRange . Parse ( version ) ) ;
157159 }
158160
161+ private RestoreAuditProperties GetRestoreAuditProperties ( )
162+ {
163+ ThreadHelper . ThrowIfNotOnUIThread ( ) ;
164+
165+ string enableAudit = _vsProjectAdapter . BuildProperties . GetPropertyValue ( ProjectBuildProperties . NuGetAudit ) ;
166+ string auditLevel = _vsProjectAdapter . BuildProperties . GetPropertyValue ( ProjectBuildProperties . NuGetAuditLevel ) ;
167+ string auditMode = _vsProjectAdapter . BuildProperties . GetPropertyValue ( ProjectBuildProperties . NuGetAuditMode ) ;
168+ HashSet < string > suppressedAdvisories = GetSuppressedAdvisories ( ) ;
169+
170+ return new RestoreAuditProperties ( )
171+ {
172+ EnableAudit = enableAudit ,
173+ AuditLevel = auditLevel ,
174+ AuditMode = auditMode ,
175+ SuppressedAdvisories = suppressedAdvisories ,
176+ } ;
177+ }
178+
179+ private HashSet < string > GetSuppressedAdvisories ( )
180+ {
181+ ThreadHelper . ThrowIfNotOnUIThread ( ) ;
182+
183+ IEnumerable < ( string ItemId , string [ ] ItemMetadata ) > buildItems = _vsProjectAdapter . GetBuildItemInformation ( ProjectBuildProperties . NuGetAuditSuppress ) ;
184+ if ( buildItems is null )
185+ {
186+ return null ;
187+ }
188+ else if ( buildItems is ICollection < ( string , string [ ] ) > collection )
189+ {
190+ if ( collection . Count == 0 ) return null ;
191+
192+ var suppressedAdvisories = new HashSet < string > ( collection . Count , StringComparer . OrdinalIgnoreCase ) ;
193+ foreach ( ( string itemId , _ ) in buildItems . NoAllocEnumerate ( ) )
194+ {
195+ suppressedAdvisories . Add ( itemId ) ;
196+ }
197+
198+ return suppressedAdvisories ;
199+ }
200+ else
201+ {
202+ var suppressedAdvisories = new HashSet < string > ( StringComparer . OrdinalIgnoreCase ) ;
203+ foreach ( ( string itemId , _ ) in buildItems . NoAllocEnumerate ( ) )
204+ {
205+ suppressedAdvisories . Add ( itemId ) ;
206+ }
207+
208+ return suppressedAdvisories . Count == 0 ? null : suppressedAdvisories ;
209+ }
210+ }
211+
159212 #endregion
160213
161214 #region NuGetProject
@@ -396,7 +449,7 @@ private async Task<PackageSpec> GetPackageSpecAsync(ISettings settings)
396449 if ( isCpvmEnabled )
397450 {
398451 // Add the central version information and merge the information to the package reference dependencies
399- projectTfi . CentralPackageVersions . AddRange ( await GetCentralPackageVersionsAsync ( ) ) ;
452+ projectTfi . CentralPackageVersions . AddRange ( GetCentralPackageVersions ( ) ) ;
400453 LibraryDependency . ApplyCentralVersionInformation ( projectTfi . Dependencies , projectTfi . CentralPackageVersions ) ;
401454 }
402455
@@ -441,17 +494,7 @@ private async Task<PackageSpec> GetPackageSpecAsync(ISettings settings)
441494 }
442495 }
443496
444- string enableAudit = _vsProjectAdapter . BuildProperties . GetPropertyValue ( ProjectBuildProperties . NuGetAudit ) ;
445- string auditLevel = _vsProjectAdapter . BuildProperties . GetPropertyValue ( ProjectBuildProperties . NuGetAuditLevel ) ;
446- string auditMode = _vsProjectAdapter . BuildProperties . GetPropertyValue ( ProjectBuildProperties . NuGetAuditMode ) ;
447- RestoreAuditProperties auditProperties = ! string . IsNullOrEmpty ( enableAudit ) || ! string . IsNullOrEmpty ( auditLevel )
448- ? new RestoreAuditProperties ( )
449- {
450- EnableAudit = enableAudit ,
451- AuditLevel = auditLevel ,
452- AuditMode = auditMode ,
453- }
454- : null ;
497+ RestoreAuditProperties auditProperties = GetRestoreAuditProperties ( ) ;
455498
456499 var msbuildProjectExtensionsPath = await GetMSBuildProjectExtensionsPathAsync ( ) ;
457500
0 commit comments