@@ -221,7 +221,8 @@ public static void SetTheme(string theme, string themeOverridesFile)
221
221
try
222
222
{
223
223
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 ) ;
225
226
foreach ( var kv in overrides . BasicColors )
226
227
{
227
228
if ( kv . Key . Equals ( "SystemAccentColor" , StringComparison . Ordinal ) )
@@ -449,31 +450,21 @@ private static bool TryLaunchAsRebaseTodoEditor(string[] args, out int exitCode)
449
450
if ( ! File . Exists ( jobsFile ) )
450
451
return true ;
451
452
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 ) ;
453
455
using var writer = new StreamWriter ( file ) ;
454
456
foreach ( var job in collection . Jobs )
455
457
{
456
- switch ( job . Action )
458
+ var code = job . Action switch
457
459
{
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 } ") ;
477
468
}
478
469
479
470
writer . Flush ( ) ;
@@ -506,7 +497,8 @@ private static bool TryLaunchAsRebaseMessageEditor(string[] args, out int exitCo
506
497
507
498
var origHead = File . ReadAllText ( origHeadFile ) . Trim ( ) ;
508
499
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 ) ;
510
502
if ( ! collection . Onto . Equals ( onto ) || ! collection . OrigHead . Equals ( origHead ) )
511
503
return true ;
512
504
@@ -626,7 +618,8 @@ private void Check4Update(bool manually = false)
626
618
try
627
619
{
628
620
// 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 ) ;
630
623
var data = await client . GetStringAsync ( "https://sourcegit-scm.github.io/data/version.json" ) ;
631
624
632
625
// Parse JSON into Models.Version.
0 commit comments