Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions src/Hosting.CommandLine/Internal/CommandLineLifetime.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ internal class CommandLineLifetime : IHostLifetime, IDisposable
public CommandLineLifetime(IApplicationLifetime applicationLifetime,
ICommandLineService cliService,
IConsole console,
IUnhandledExceptionHandler unhandledExceptionHandler)
IUnhandledExceptionHandler unhandledExceptionHandler = null)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this necessary? This service should always be defined, right?

services
.TryAddSingleton<IUnhandledExceptionHandler>(exceptionHandler);

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It currently is. Ultimately I hoped that #196 would render the handler optional and I then would have removed the quoted line. Also I wanted to know if you can have optionally injected dependencies and it is consistent with the call in

if (_unhandledExceptionHandler != null)

{
_applicationLifetime = applicationLifetime;
_cliService = cliService;
Expand Down Expand Up @@ -75,8 +75,10 @@ public Task WaitForStartAsync(CancellationToken cancellationToken)
ExceptionDispatchInfo.Capture(e).Throw();
}
}

_applicationLifetime.StopApplication();
finally
{
_applicationLifetime.StopApplication();
}
});

// Ensures services are disposed before the application exits.
Expand Down