@@ -106,7 +106,7 @@ public override async Task<ExternalSettingOperationResult<T>> GetValueAsync<T>(s
106106
107107 public override async Task < ExternalSettingOperationResult > SetValueAsync < T > ( string moniker , T value , CancellationToken cancellationToken )
108108 {
109- bool hasAnyHiddenPropertyChanged = false ;
109+ bool isRefreshNeeded = false ;
110110
111111 try
112112 {
@@ -122,19 +122,18 @@ public override async Task<ExternalSettingOperationResult> SetValueAsync<T>(stri
122122 return await Task . Run (
123123 ( ) =>
124124 {
125- ( ExternalSettingOperationResult result , bool hasAnyHiddenPropertyChanged ) savePackageSourcesResult = SavePackageSources ( packageSourcesList , cancellationToken ) ;
126- hasAnyHiddenPropertyChanged = savePackageSourcesResult . hasAnyHiddenPropertyChanged ;
127- return savePackageSourcesResult . result ;
125+ ExternalSettingOperationResult savePackageSourcesResult = SavePackageSources ( packageSourcesList , cancellationToken ) ;
126+ isRefreshNeeded = savePackageSourcesResult == ExternalSettingOperationResult . Success . Instance ;
127+ return savePackageSourcesResult ;
128128 } ,
129129 cancellationToken ) ;
130130 case MonikerAuditSources :
131131 var auditSourceList = ( IReadOnlyList < IDictionary < string , object > > ) value ;
132132 return await Task . Run (
133133 ( ) =>
134134 {
135- ( ExternalSettingOperationResult result , bool hasAnyHiddenPropertyChanged ) saveAuditSourcesResult = SaveAuditSources ( auditSourceList , cancellationToken ) ;
136- hasAnyHiddenPropertyChanged = saveAuditSourcesResult . hasAnyHiddenPropertyChanged ;
137- return saveAuditSourcesResult . result ;
135+ ExternalSettingOperationResult saveAuditSourcesResult = SaveAuditSources ( auditSourceList , cancellationToken ) ;
136+ return saveAuditSourcesResult ;
138137 } ,
139138 cancellationToken ) ;
140139 case MonikerMachineWideSources :
@@ -152,7 +151,7 @@ public override async Task<ExternalSettingOperationResult> SetValueAsync<T>(stri
152151 // Resume listening to setting changes after saving.
153152 _suppressSettingValuesChanged = false ;
154153
155- if ( hasAnyHiddenPropertyChanged )
154+ if ( isRefreshNeeded )
156155 {
157156 VsSettings_SettingsChanged ( this , EventArgs . Empty ) ;
158157 }
@@ -206,18 +205,16 @@ private ExternalSettingOperationResult SetIsEnabledOnMachineWidePackageSources(
206205 return result ;
207206 }
208207
209- private ( ExternalSettingOperationResult result , bool hasAnyHiddenPropertyChanged ) SavePackageSources (
208+ private ExternalSettingOperationResult SavePackageSources (
210209 IReadOnlyList < IDictionary < string , object > > packageSourceDictionaryList ,
211210 CancellationToken cancellationToken )
212211 {
213- bool hasAnyHiddenPropertyChanged = false ;
214212 ExternalSettingOperationResult result ;
215213
216214 try
217215 {
218216 List < PackageSource > packageSources = new List < PackageSource > ( capacity : packageSourceDictionaryList . Count ) ;
219217 IReadOnlyList < PackageSource > existingPackageSources = LoadPackageSources ( isMachineWide : false ) ;
220- bool hasAnyPackageSourceNameChanged = false ;
221218
222219 foreach ( Dictionary < string , object > packageSourceDictionary in packageSourceDictionaryList )
223220 {
@@ -230,12 +227,6 @@ private ExternalSettingOperationResult SetIsEnabledOnMachineWidePackageSources(
230227 if ( packageSourceDictionary . TryGetValue ( MonikerPackageSourceId , out object packageSourceIdObj ) )
231228 {
232229 lookupName = packageSourceIdObj . ToString ( ) ;
233-
234- if ( ! string . Equals ( lookupName , name , StringComparison . CurrentCultureIgnoreCase ) )
235- {
236- // Changing the ID needs to refresh Unified Settings since the ID is a hidden property.
237- hasAnyPackageSourceNameChanged = true ;
238- }
239230 }
240231 else // Newly added Package Sources will not have an ID yet.
241232 {
@@ -260,8 +251,6 @@ private ExternalSettingOperationResult SetIsEnabledOnMachineWidePackageSources(
260251
261252 _packageSourceProvider . SavePackageSources ( packageSources ) ;
262253
263- hasAnyHiddenPropertyChanged = hasAnyPackageSourceNameChanged ;
264-
265254 result = ExternalSettingOperationResult . Success . Instance ;
266255 }
267256#pragma warning disable CA1031 // Do not catch general exception types
@@ -272,21 +261,19 @@ private ExternalSettingOperationResult SetIsEnabledOnMachineWidePackageSources(
272261 ActivityLog . LogError ( ExceptionHelper . LogEntrySource , ex . ToString ( ) ) ;
273262 }
274263
275- return ( result , hasAnyHiddenPropertyChanged ) ;
264+ return result ;
276265 }
277266
278- private ( ExternalSettingOperationResult result , bool hasAnyHiddenPropertyChanged ) SaveAuditSources (
267+ private ExternalSettingOperationResult SaveAuditSources (
279268 IReadOnlyList < IDictionary < string , object > > auditSourceDictionaryList ,
280269 CancellationToken cancellationToken )
281270 {
282- bool hasAnyHiddenPropertyChanged = false ;
283271 ExternalSettingOperationResult result ;
284272
285273 try
286274 {
287275 List < PackageSource > auditSources = new List < PackageSource > ( capacity : auditSourceDictionaryList . Count ) ;
288276 IReadOnlyList < PackageSource > existingAuditSources = LoadAuditSources ( ) ;
289- bool hasAnyPackageSourceNameChanged = false ;
290277
291278 foreach ( Dictionary < string , object > packageSourceDictionary in auditSourceDictionaryList )
292279 {
@@ -299,12 +286,6 @@ private ExternalSettingOperationResult SetIsEnabledOnMachineWidePackageSources(
299286 if ( packageSourceDictionary . TryGetValue ( MonikerPackageSourceId , out object packageSourceIdObj ) )
300287 {
301288 lookupName = packageSourceIdObj . ToString ( ) ;
302-
303- if ( ! string . Equals ( lookupName , name , StringComparison . CurrentCultureIgnoreCase ) )
304- {
305- // Changing the ID needs to refresh Unified Settings since the ID is a hidden property.
306- hasAnyPackageSourceNameChanged = true ;
307- }
308289 }
309290 else // Newly added Package Sources will not have an ID yet.
310291 {
@@ -327,8 +308,6 @@ private ExternalSettingOperationResult SetIsEnabledOnMachineWidePackageSources(
327308
328309 _packageSourceProvider . SaveAuditSources ( auditSources ) ;
329310
330- hasAnyHiddenPropertyChanged = hasAnyPackageSourceNameChanged ;
331-
332311 result = ExternalSettingOperationResult . Success . Instance ;
333312 }
334313#pragma warning disable CA1031 // Do not catch general exception types
@@ -339,7 +318,7 @@ private ExternalSettingOperationResult SetIsEnabledOnMachineWidePackageSources(
339318 ActivityLog . LogError ( ExceptionHelper . LogEntrySource , ex . ToString ( ) ) ;
340319 }
341320
342- return ( result , hasAnyHiddenPropertyChanged ) ;
321+ return result ;
343322 }
344323
345324
0 commit comments