Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit a409f24

Browse filesBrowse files
committed
fix nullability
1 parent ba783e4 commit a409f24
Copy full SHA for a409f24

File tree

Expand file treeCollapse file tree

2 files changed

+7
-7
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+7
-7
lines changed

‎src/System.CommandLine/Binding/BindingContext.cs

Copy file name to clipboardExpand all lines: src/System.CommandLine/Binding/BindingContext.cs
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public BindingContext(
3131

3232
internal IConsoleFactory? ConsoleFactory { get; set; }
3333

34-
internal IHelpBuilder HelpBuilder => (IHelpBuilder)ServiceProvider.GetService(typeof(IHelpBuilder));
34+
internal IHelpBuilder HelpBuilder => (IHelpBuilder)ServiceProvider.GetService(typeof(IHelpBuilder))!;
3535

3636
public IConsole Console
3737
{
@@ -70,7 +70,7 @@ public void AddService<T>(Func<IServiceProvider, T> factory)
7070
throw new ArgumentNullException(nameof(factory));
7171
}
7272

73-
ServiceProvider.AddService(typeof(T), s => factory(s)!);
73+
ServiceProvider.AddService(typeof(T), s => factory(s));
7474
}
7575

7676
internal bool TryGetValueSource(

‎src/System.CommandLine/Invocation/ServiceProvider.cs

Copy file name to clipboardExpand all lines: src/System.CommandLine/Invocation/ServiceProvider.cs
+5-5Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@ namespace System.CommandLine.Invocation
1313
{
1414
internal class ServiceProvider : IServiceProvider
1515
{
16-
private readonly Dictionary<Type, Func<IServiceProvider, object>> _services;
16+
private readonly Dictionary<Type, Func<IServiceProvider, object?>> _services;
1717

1818
public ServiceProvider(BindingContext bindingContext)
1919
{
20-
_services = new Dictionary<Type, Func<IServiceProvider, object>>
20+
_services = new Dictionary<Type, Func<IServiceProvider, object?>>
2121
{
2222
[typeof(ParseResult)] = _ => bindingContext.ParseResult,
2323
[typeof(IConsole)] = _ => bindingContext.Console,
@@ -29,18 +29,18 @@ public ServiceProvider(BindingContext bindingContext)
2929

3030
public void AddService<T>(Func<IServiceProvider, T> factory) => _services[typeof(T)] = p => factory(p)!;
3131

32-
public void AddService(Type serviceType, Func<IServiceProvider, object> factory) => _services[serviceType] = factory;
32+
public void AddService(Type serviceType, Func<IServiceProvider, object?> factory) => _services[serviceType] = factory;
3333

3434
public IReadOnlyCollection<Type> AvailableServiceTypes => _services.Keys;
3535

36-
public object GetService(Type serviceType)
36+
public object? GetService(Type serviceType)
3737
{
3838
if (_services.TryGetValue(serviceType, out var factory))
3939
{
4040
return factory(this);
4141
}
4242

43-
return null!;
43+
return null;
4444
}
4545
}
4646
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.