-
Notifications
You must be signed in to change notification settings - Fork 20
Enable nullable reference type warnings #207
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -86,9 +86,9 @@ static async Task<int> Main(string[] args) | |
|
|
||
| await AddTraceWriterAsync(scopedServiceProvider, enableTrace); | ||
|
|
||
| scopedServiceProvider.GetService<BluetoothKernel>().BluetoothDeviceInfo = bluetoothDeviceInfo; | ||
| scopedServiceProvider.GetRequiredService<BluetoothKernel>().BluetoothDeviceInfo = bluetoothDeviceInfo; | ||
|
|
||
| var deviceListCli = scopedServiceProvider.GetService<DevicesList>(); // ServiceLocator ok: transient factory | ||
| var deviceListCli = scopedServiceProvider.GetRequiredService<DevicesList>(); // ServiceLocator ok: transient factory | ||
|
|
||
| await deviceListCli.ExecuteAsync(systemType); | ||
| } | ||
|
|
@@ -138,11 +138,11 @@ static async Task<int> Main(string[] args) | |
|
|
||
| await AddTraceWriterAsync(scopedServiceProvider, enableTrace); | ||
|
|
||
| scopedServiceProvider.GetService<BluetoothKernel>().BluetoothDeviceInfo = bluetoothDeviceInfo; | ||
| scopedServiceProvider.GetRequiredService<BluetoothKernel>().BluetoothDeviceInfo = bluetoothDeviceInfo; | ||
|
|
||
| var dumpStaticPortInfoCommand = scopedServiceProvider.GetService<DumpStaticPortInfo>(); // ServiceLocator ok: transient factory | ||
| var dumpStaticPortInfoCommand = scopedServiceProvider.GetRequiredService<DumpStaticPortInfo>(); // ServiceLocator ok: transient factory | ||
|
|
||
| var port = byte.Parse(portOption.Value()); | ||
| var port = byte.TryParse(portOption.Value(), out var parsedPort) ? parsedPort : (byte)0; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is not that a behavior change to the CLI?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I guess technically, yes. But wasn't the behavior before that omitting the |
||
|
|
||
| await dumpStaticPortInfoCommand.ExecuteAsync(systemType, port, headerEnabled); | ||
| } | ||
|
|
@@ -193,7 +193,7 @@ static async Task<int> Main(string[] args) | |
|
|
||
| await AddTraceWriterAsync(scopedServiceProvider, enableTrace); | ||
|
|
||
| var prettyPrintCommand = scopedServiceProvider.GetService<PrettyPrint>(); // ServiceLocator ok: transient factory | ||
| var prettyPrintCommand = scopedServiceProvider.GetRequiredService<PrettyPrint>(); // ServiceLocator ok: transient factory | ||
|
|
||
| TextReader reader = Console.In; | ||
|
|
||
|
|
@@ -273,7 +273,7 @@ public static async Task AddTraceWriterAsync(IServiceProvider serviceProvider, b | |
| { | ||
| if (enableTrace) | ||
| { | ||
| var traceMessages = serviceProvider.GetService<TraceMessages>(); // ServiceLocator ok: transient factory | ||
| var traceMessages = serviceProvider.GetRequiredService<TraceMessages>(); // ServiceLocator ok: transient factory | ||
|
|
||
| await traceMessages.ExecuteAsync(); | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -14,15 +14,24 @@ public HubFactory(IServiceProvider serviceProvider) | |
|
|
||
| public Hub CreateByBluetoothManufacturerData(byte[] manufacturerData) | ||
| { | ||
| var hub = (manufacturerData is null || manufacturerData.Length < 3) ? null : Create(GetTypeFromSystemType(GetSystemTypeFromManufacturerData((PoweredUpHubManufacturerData)manufacturerData[1]))); | ||
| if (manufacturerData is null) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am not sure if this is right change. Maybe the function needs a Hub? as a result. Obviously the init line needs to change.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I just tried to keep the changes minimal. |
||
| { | ||
| throw new ArgumentNullException(nameof(manufacturerData)); | ||
| } | ||
| if (manufacturerData.Length < 3) | ||
| { | ||
| throw new ArgumentException("Manufacturer data must be at least 3 bytes long.", nameof(manufacturerData)); | ||
| } | ||
|
|
||
| var hub = Create(GetTypeFromSystemType(GetSystemTypeFromManufacturerData((PoweredUpHubManufacturerData)manufacturerData[1]))); | ||
| hub.Configure(0x00); | ||
|
|
||
| return hub; | ||
| } | ||
|
|
||
| public THub Create<THub>() where THub : Hub | ||
| { | ||
| var hub = Create(typeof(THub)) as THub; | ||
| var hub = (THub)Create(typeof(THub)); | ||
| hub.Configure(0x00); | ||
|
|
||
| return hub; | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why was this change necessary?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With the additional variable, the compiler can no longer correctly infer that
actualListAdvertisingDatacannot benullifTryGetValuereturnstrue.