Skip to content

Commit 09af161

Browse files
authored
Enable nullable on Hosting.Systemd (#90495)
- Passing null into the hosting lifetimes' loggerFactory parameters would result in a NRE Contributes to #90400
1 parent 9a9d110 commit 09af161

File tree

5 files changed

+4
-9
lines changed

5 files changed

+4
-9
lines changed

src/libraries/Microsoft.Extensions.Hosting.Systemd/ref/Microsoft.Extensions.Hosting.Systemd.csproj

-4
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,6 @@
33
<PropertyGroup>
44
<TargetFrameworks>$(NetCoreAppCurrent);$(NetCoreAppPrevious);$(NetCoreAppMinimum);netstandard2.1</TargetFrameworks>
55
<EnableDefaultItems>true</EnableDefaultItems>
6-
7-
<!-- TODO https://github.com/dotnet/runtime/issues/90400: Annotate for nullable reference types -->
8-
<Nullable>disable</Nullable>
9-
<NoWarn>$(NoWarn);nullable</NoWarn>
106
</PropertyGroup>
117

128
<ItemGroup>

src/libraries/Microsoft.Extensions.Hosting.Systemd/src/Microsoft.Extensions.Hosting.Systemd.csproj

-4
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,6 @@
66
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
77
<IsPackable>true</IsPackable>
88
<PackageDescription>.NET hosting infrastructure for Systemd Services.</PackageDescription>
9-
10-
<!-- TODO https://github.com/dotnet/runtime/issues/90400: Annotate for nullable reference types -->
11-
<Nullable>disable</Nullable>
12-
<NoWarn>$(NoWarn);nullable</NoWarn>
139
</PropertyGroup>
1410

1511
<ItemGroup Condition="'$(TargetFrameworkIdentifier)' != '.NETCoreApp'">

src/libraries/Microsoft.Extensions.Hosting.Systemd/src/SystemdLifetime.cs

+1
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ public SystemdLifetime(IHostEnvironment environment, IHostApplicationLifetime ap
3434
ThrowHelper.ThrowIfNull(environment);
3535
ThrowHelper.ThrowIfNull(applicationLifetime);
3636
ThrowHelper.ThrowIfNull(systemdNotifier);
37+
ThrowHelper.ThrowIfNull(loggerFactory);
3738

3839
Environment = environment;
3940
ApplicationLifetime = applicationLifetime;

src/libraries/Microsoft.Extensions.Hosting.WindowsServices/src/WindowsServiceLifetime.cs

+1
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ public WindowsServiceLifetime(IHostEnvironment environment, IHostApplicationLife
4747
{
4848
ThrowHelper.ThrowIfNull(environment);
4949
ThrowHelper.ThrowIfNull(applicationLifetime);
50+
ThrowHelper.ThrowIfNull(loggerFactory);
5051
ThrowHelper.ThrowIfNull(optionsAccessor);
5152
ThrowHelper.ThrowIfNull(windowsServiceOptionsAccessor);
5253

src/libraries/Microsoft.Extensions.Hosting/src/Internal/ConsoleLifetime.cs

+2-1
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,14 @@ public ConsoleLifetime(IOptions<ConsoleLifetimeOptions> options, IHostEnvironmen
4242
/// <param name="applicationLifetime">An object that allows consumers to be notified of application lifetime events.</param>
4343
/// <param name="hostOptions">An object used to retrieve <see cref="HostOptions"/> instances.</param>
4444
/// <param name="loggerFactory">An object to configure the logging system and create instances of <see cref="ILogger"/> from the registered <see cref="ILoggerProvider"/>.</param>
45-
/// <exception cref="ArgumentNullException"><paramref name="options"/> or <paramref name="environment"/> or <paramref name="applicationLifetime"/> or <paramref name="hostOptions"/> is <see langword="null"/>.</exception>
45+
/// <exception cref="ArgumentNullException"><paramref name="options"/> or <paramref name="environment"/> or <paramref name="applicationLifetime"/> or <paramref name="hostOptions"/> or <paramref name="loggerFactory"/> is <see langword="null"/>.</exception>
4646
public ConsoleLifetime(IOptions<ConsoleLifetimeOptions> options, IHostEnvironment environment, IHostApplicationLifetime applicationLifetime, IOptions<HostOptions> hostOptions, ILoggerFactory loggerFactory)
4747
{
4848
ThrowHelper.ThrowIfNull(options?.Value, nameof(options));
4949
ThrowHelper.ThrowIfNull(applicationLifetime);
5050
ThrowHelper.ThrowIfNull(environment);
5151
ThrowHelper.ThrowIfNull(hostOptions?.Value, nameof(hostOptions));
52+
ThrowHelper.ThrowIfNull(loggerFactory);
5253

5354
Options = options.Value;
5455
Environment = environment;

0 commit comments

Comments
 (0)