@@ -86,9 +86,9 @@ static async Task<int> Main(string[] args)
8686
8787 await AddTraceWriterAsync ( scopedServiceProvider , enableTrace ) ;
8888
89- scopedServiceProvider . GetService < BluetoothKernel > ( ) . BluetoothDeviceInfo = bluetoothDeviceInfo ;
89+ scopedServiceProvider . GetRequiredService < BluetoothKernel > ( ) . BluetoothDeviceInfo = bluetoothDeviceInfo ;
9090
91- var deviceListCli = scopedServiceProvider . GetService < DevicesList > ( ) ; // ServiceLocator ok: transient factory
91+ var deviceListCli = scopedServiceProvider . GetRequiredService < DevicesList > ( ) ; // ServiceLocator ok: transient factory
9292
9393 await deviceListCli . ExecuteAsync ( systemType ) ;
9494 }
@@ -138,11 +138,11 @@ static async Task<int> Main(string[] args)
138138
139139 await AddTraceWriterAsync ( scopedServiceProvider , enableTrace ) ;
140140
141- scopedServiceProvider . GetService < BluetoothKernel > ( ) . BluetoothDeviceInfo = bluetoothDeviceInfo ;
141+ scopedServiceProvider . GetRequiredService < BluetoothKernel > ( ) . BluetoothDeviceInfo = bluetoothDeviceInfo ;
142142
143- var dumpStaticPortInfoCommand = scopedServiceProvider . GetService < DumpStaticPortInfo > ( ) ; // ServiceLocator ok: transient factory
143+ var dumpStaticPortInfoCommand = scopedServiceProvider . GetRequiredService < DumpStaticPortInfo > ( ) ; // ServiceLocator ok: transient factory
144144
145- var port = byte . Parse ( portOption . Value ( ) ) ;
145+ var port = byte . TryParse ( portOption . Value ( ) , out var parsedPort ) ? parsedPort : ( byte ) 0 ;
146146
147147 await dumpStaticPortInfoCommand . ExecuteAsync ( systemType , port , headerEnabled ) ;
148148 }
@@ -193,7 +193,7 @@ static async Task<int> Main(string[] args)
193193
194194 await AddTraceWriterAsync ( scopedServiceProvider , enableTrace ) ;
195195
196- var prettyPrintCommand = scopedServiceProvider . GetService < PrettyPrint > ( ) ; // ServiceLocator ok: transient factory
196+ var prettyPrintCommand = scopedServiceProvider . GetRequiredService < PrettyPrint > ( ) ; // ServiceLocator ok: transient factory
197197
198198 TextReader reader = Console . In ;
199199
@@ -273,7 +273,7 @@ public static async Task AddTraceWriterAsync(IServiceProvider serviceProvider, b
273273 {
274274 if ( enableTrace )
275275 {
276- var traceMessages = serviceProvider . GetService < TraceMessages > ( ) ; // ServiceLocator ok: transient factory
276+ var traceMessages = serviceProvider . GetRequiredService < TraceMessages > ( ) ; // ServiceLocator ok: transient factory
277277
278278 await traceMessages . ExecuteAsync ( ) ;
279279 }
0 commit comments