@@ -221,7 +221,8 @@ public static void SetTheme(string theme, string themeOverridesFile)
221221 try
222222 {
223223 var resDic = new ResourceDictionary ( ) ;
224- var overrides = JsonSerializer . Deserialize ( File . ReadAllText ( themeOverridesFile ) , JsonCodeGen . Default . ThemeOverrides ) ;
224+ using var stream = File . OpenRead ( themeOverridesFile ) ;
225+ var overrides = JsonSerializer . Deserialize ( stream , JsonCodeGen . Default . ThemeOverrides ) ;
225226 foreach ( var kv in overrides . BasicColors )
226227 {
227228 if ( kv . Key . Equals ( "SystemAccentColor" , StringComparison . Ordinal ) )
@@ -449,31 +450,21 @@ private static bool TryLaunchAsRebaseTodoEditor(string[] args, out int exitCode)
449450 if ( ! File . Exists ( jobsFile ) )
450451 return true ;
451452
452- var collection = JsonSerializer . Deserialize ( File . ReadAllText ( jobsFile ) , JsonCodeGen . Default . InteractiveRebaseJobCollection ) ;
453+ using var stream = File . OpenRead ( jobsFile ) ;
454+ var collection = JsonSerializer . Deserialize ( stream , JsonCodeGen . Default . InteractiveRebaseJobCollection ) ;
453455 using var writer = new StreamWriter ( file ) ;
454456 foreach ( var job in collection . Jobs )
455457 {
456- switch ( job . Action )
458+ var code = job . Action switch
457459 {
458- case Models . InteractiveRebaseAction . Pick :
459- writer . WriteLine ( $ "p { job . SHA } ") ;
460- break ;
461- case Models . InteractiveRebaseAction . Edit :
462- writer . WriteLine ( $ "e { job . SHA } ") ;
463- break ;
464- case Models . InteractiveRebaseAction . Reword :
465- writer . WriteLine ( $ "r { job . SHA } ") ;
466- break ;
467- case Models . InteractiveRebaseAction . Squash :
468- writer . WriteLine ( $ "s { job . SHA } ") ;
469- break ;
470- case Models . InteractiveRebaseAction . Fixup :
471- writer . WriteLine ( $ "f { job . SHA } ") ;
472- break ;
473- default :
474- writer . WriteLine ( $ "d { job . SHA } ") ;
475- break ;
476- }
460+ Models . InteractiveRebaseAction . Pick => 'p' ,
461+ Models . InteractiveRebaseAction . Edit => 'e' ,
462+ Models . InteractiveRebaseAction . Reword => 'r' ,
463+ Models . InteractiveRebaseAction . Squash => 's' ,
464+ Models . InteractiveRebaseAction . Fixup => 'f' ,
465+ _ => 'd'
466+ } ;
467+ writer . WriteLine ( $ "{ code } { job . SHA } ") ;
477468 }
478469
479470 writer . Flush ( ) ;
@@ -506,7 +497,8 @@ private static bool TryLaunchAsRebaseMessageEditor(string[] args, out int exitCo
506497
507498 var origHead = File . ReadAllText ( origHeadFile ) . Trim ( ) ;
508499 var onto = File . ReadAllText ( ontoFile ) . Trim ( ) ;
509- var collection = JsonSerializer . Deserialize ( File . ReadAllText ( jobsFile ) , JsonCodeGen . Default . InteractiveRebaseJobCollection ) ;
500+ using var stream = File . OpenRead ( jobsFile ) ;
501+ var collection = JsonSerializer . Deserialize ( stream , JsonCodeGen . Default . InteractiveRebaseJobCollection ) ;
510502 if ( ! collection . Onto . Equals ( onto ) || ! collection . OrigHead . Equals ( origHead ) )
511503 return true ;
512504
@@ -626,7 +618,8 @@ private void Check4Update(bool manually = false)
626618 try
627619 {
628620 // Fetch latest release information.
629- var client = new HttpClient ( ) { Timeout = TimeSpan . FromSeconds ( 5 ) } ;
621+ using var client = new HttpClient ( ) ;
622+ client . Timeout = TimeSpan . FromSeconds ( 5 ) ;
630623 var data = await client . GetStringAsync ( "https://sourcegit-scm.github.io/data/version.json" ) ;
631624
632625 // Parse JSON into Models.Version.
0 commit comments