@@ -37,7 +37,7 @@ public async Task<bool> StartAsync(StartupEventArgs e, IEnumerable<string> addit
3737
3838 SubscribeExceptions ( ) ;
3939
40- var ( success , response ) = StartupAgent . Start ( ProductInfo . Product , ProductInfo . StartupTaskId , OtherArguments ) ;
40+ var ( success , response ) = StartupAgent . Start ( ProductInfo . Product , ProductInfo . StartupTaskId , ForwardingArguments ) ;
4141 if ( ! success && ( response is not null ) )
4242 {
4343 ConsoleService . WriteLine ( response ) ;
@@ -66,6 +66,9 @@ public void Write(string content)
6666 public static IReadOnlyList < string > OtherArguments => _otherArguments ? . ToArray ( ) ?? [ ] ;
6767 private static string [ ] _otherArguments ;
6868
69+ public static IReadOnlyList < string > ForwardingArguments => _forwardingArguments ? . ToArray ( ) ?? [ ] ;
70+ private static string [ ] _forwardingArguments ;
71+
6972 public static IEnumerable < string > EnumerateStandardOptions ( ) =>
7073 new [ ]
7174 {
@@ -78,26 +81,32 @@ public static IEnumerable<string> EnumerateStandardOptions() =>
7881
7982 private async Task ParseArgumentsAsync ( StartupEventArgs e , string [ ] standardOptions )
8083 {
81- // Load persistent arguments.
82- var args = ( await LoadArgumentsAsync ( ) ) ? . Split ( ) ?? [ ] ;
83-
84- // Concatenate current and persistent arguments.
84+ // Divide current arguments.
8585 // The first element of StartupEventArgs.Args is not executing assembly's path unlike
8686 // that of arguments provided by Environment.GetCommandLineArgs method.
87- args = e . Args . Concat ( args . Select ( x => x . Trim ( '"' ) ) ) . ToArray ( ) ;
88- if ( args is not { Length : > 0 } )
89- return ;
87+ var ( currentStandard , currentOther ) = Divide ( e . Args ) ;
9088
91- const char optionMark = '/' ;
92- var isStandard = false ;
89+ // Divide persistent arguments.
90+ var persistentArgs = ( await LoadArgumentsAsync ( ) ) ? . Split ( ) . Select ( x => x . Trim ( '"' ) ) ;
91+ var ( persistentStandard , persistentOther ) = Divide ( persistentArgs ) ;
9392
94- var buffer = args
95- . Where ( x => ! string . IsNullOrWhiteSpace ( x ) )
96- . GroupBy ( x => ( x [ 0 ] == optionMark ) ? ( isStandard = standardOptions . Contains ( x . ToLower ( ) ) ) : isStandard )
97- . ToArray ( ) ;
93+ _standardArguments = persistentStandard . Concat ( currentStandard ) . ToArray ( ) ;
94+ _forwardingArguments = currentOther . ToArray ( ) ;
95+ _otherArguments = persistentOther . Concat ( _forwardingArguments ) . ToArray ( ) ;
9896
99- _standardArguments = buffer . SingleOrDefault ( x => x . Key ) ? . ToArray ( ) ;
100- _otherArguments = buffer . SingleOrDefault ( x => ! x . Key ) ? . ToArray ( ) ;
97+ ( IEnumerable < string > standard , IEnumerable < string > other ) Divide ( IEnumerable < string > args )
98+ {
99+ const char optionMark = '/' ;
100+ var isStandard = false ;
101+
102+ var buffer = args
103+ . Where ( x => ! string . IsNullOrWhiteSpace ( x ) )
104+ . GroupBy ( x => ( x [ 0 ] == optionMark ) ? ( isStandard = standardOptions . Contains ( x . ToLower ( ) ) ) : isStandard )
105+ . ToArray ( ) ?? [ ] ;
106+
107+ return ( standard : buffer . SingleOrDefault ( x => x . Key ) ?? Enumerable . Empty < string > ( ) ,
108+ other : buffer . SingleOrDefault ( x => ! x . Key ) ?? Enumerable . Empty < string > ( ) ) ;
109+ }
101110 }
102111
103112 private const string ArgumentsFileName = "arguments.txt" ;
0 commit comments