@@ -19,9 +19,9 @@ internal class DrsSettingsMetaService
1919 private readonly CustomSettingNames _customSettings ;
2020 private readonly CustomSettingNames _referenceSettings ;
2121
22- private List < MetaServiceItem > MetaServices = new List < MetaServiceItem > ( ) ;
22+ private List < MetaServiceItem > MetaServices = [ ] ;
2323
24- private Dictionary < uint , SettingMeta > settingMetaCache = new Dictionary < uint , SettingMeta > ( ) ;
24+ private Dictionary < uint , SettingMeta > settingMetaCache = [ ] ;
2525
2626 public DrsSettingsMetaService ( CustomSettingNames customSettings , CustomSettingNames referenceSettings = null )
2727 {
@@ -33,8 +33,8 @@ public DrsSettingsMetaService(CustomSettingNames customSettings, CustomSettingNa
3333
3434 public void ResetMetaCache ( bool initOnly = false )
3535 {
36- settingMetaCache = new Dictionary < uint , SettingMeta > ( ) ;
37- MetaServices = new List < MetaServiceItem > ( ) ;
36+ settingMetaCache = [ ] ;
37+ MetaServices = [ ] ;
3838
3939 CustomMeta = new CustomSettingMetaService ( _customSettings ) ;
4040 MetaServices . Add ( new MetaServiceItem ( ) { ValueNamePrio = 1 , Service = CustomMeta } ) ;
@@ -174,9 +174,9 @@ private List<SettingValue<T>> MergeSettingValues<T>(List<SettingValue<T>> a, Lis
174174
175175 var atmp = a . FirstOrDefault ( ) ;
176176 if ( atmp != null && atmp is IComparable )
177- return a . OrderBy ( x => x . Value ) . ToList ( ) ;
177+ return [ .. a . OrderBy ( x => x . Value ) ] ;
178178 else
179- return a . ToList ( ) ;
179+ return [ .. a ] ;
180180 }
181181
182182 private List < SettingValue < byte [ ] > > GetBinaryValues ( uint settingId )
@@ -214,7 +214,7 @@ private List<SettingValue<uint>> GetDwordValues(uint settingId)
214214
215215 if ( result != null )
216216 {
217- result = ( from v in result . Where ( x => 1 == 1
217+ result = [ .. ( from v in result . Where ( x => 1 == 1
218218 && ! x . ValueName . EndsWith ( "_NUM" )
219219 && ! x . ValueName . EndsWith ( "_MASK" )
220220 && ( ! x . ValueName . EndsWith ( "_MIN" ) || x . ValueName . Equals ( "PREFERRED_PSTATE_PREFER_MIN" ) )
@@ -225,7 +225,7 @@ group v by v.ValueName into g
225225 select g . First ( t => t . ValueName == g . Key ) )
226226 . OrderBy ( v => v . ValueSource )
227227 . ThenBy ( v => v . ValuePos )
228- . ThenBy ( v => v . ValueName ) . ToList ( ) ;
228+ . ThenBy ( v => v . ValueName ) ] ;
229229
230230 }
231231
@@ -249,47 +249,42 @@ public List<uint> GetSettingIds(SettingViewMode viewMode)
249249
250250 private SettingMetaSource [ ] GetAllowedSettingIdMetaSourcesForViewMode ( SettingViewMode viewMode )
251251 {
252- switch ( viewMode )
252+ return viewMode switch
253253 {
254- case SettingViewMode . CustomSettingsOnly :
255- return new [ ] {
256- SettingMetaSource . CustomSettings
257- } ;
258- case SettingViewMode . IncludeScannedSetttings :
259- return new [ ] {
260- SettingMetaSource . ConstantSettings ,
254+ SettingViewMode . CustomSettingsOnly => [
255+ SettingMetaSource . CustomSettings
256+ ] ,
257+ SettingViewMode . IncludeScannedSetttings => [
258+ SettingMetaSource . ConstantSettings ,
261259 SettingMetaSource . ScannedSettings ,
262260 SettingMetaSource . CustomSettings ,
263261 SettingMetaSource . DriverSettings ,
264262 SettingMetaSource . ReferenceSettings ,
265- } ;
266- default :
267- return new [ ] {
263+ ] ,
264+ _ => [
268265 SettingMetaSource . CustomSettings ,
269266 SettingMetaSource . DriverSettings ,
270- } ;
271- }
267+ ] ,
268+ } ;
272269 }
273270
274271 private SettingMetaSource [ ] GetAllowedSettingValueMetaSourcesForViewMode ( SettingViewMode viewMode )
275272 {
276- switch ( viewMode )
273+ return viewMode switch
277274 {
278- case SettingViewMode . CustomSettingsOnly :
279- return new [ ] {
280- SettingMetaSource . CustomSettings ,
275+ SettingViewMode . CustomSettingsOnly => [
276+ SettingMetaSource . CustomSettings ,
281277 SettingMetaSource . ScannedSettings ,
282- } ;
283- default :
284- return new [ ] {
278+ ] ,
279+ _ => [
285280 SettingMetaSource . ConstantSettings ,
286281 SettingMetaSource . ScannedSettings ,
287282 SettingMetaSource . CustomSettings ,
288283 SettingMetaSource . DriverSettings ,
289284 SettingMetaSource . ReferenceSettings ,
290285
291- } ;
292- }
286+ ] ,
287+ } ;
293288 }
294289
295290 private SettingMeta CreateSettingMeta ( uint settingId )
@@ -298,8 +293,7 @@ private SettingMeta CreateSettingMeta(uint settingId)
298293 var settingName = GetSettingName ( settingId ) ;
299294 var groupName = GetGroupName ( settingId ) ;
300295
301- if ( groupName == null )
302- groupName = GetLegacyGroupName ( settingId , settingName ) ;
296+ groupName ??= GetLegacyGroupName ( settingId , settingName ) ;
303297
304298
305299
@@ -397,7 +391,9 @@ public SettingMeta GetSettingMeta(uint settingId, SettingViewMode viewMode = Set
397391 }
398392 }
399393
394+ #pragma warning disable IDE0060 // Remove unused parameter
400395 private string GetLegacyGroupName ( uint settingId , string settingName )
396+ #pragma warning restore IDE0060 // Remove unused parameter
401397 {
402398 if ( settingName == null )
403399 return null ;
@@ -428,7 +424,7 @@ private string GetDescription(uint settingId)
428424 {
429425 var csn = MetaServices . FirstOrDefault ( m => m . Service . Source == SettingMetaSource . CustomSettings ) ;
430426 var csnDescription = csn != null ? ( ( CustomSettingMetaService ) csn . Service ) . GetDescription ( settingId ) ?? "" : "" ;
431-
427+
432428 var refs = MetaServices . FirstOrDefault ( m => m . Service . Source == SettingMetaSource . ReferenceSettings ) ;
433429 var refsDescription = refs != null ? ( ( CustomSettingMetaService ) refs . Service ) . GetDescription ( settingId ) ?? "" : "" ;
434430
0 commit comments