Skip to content

Commit

Permalink
[Group 9] Enable nullable annotations for `Microsoft.Extensions.Hosti…
Browse files Browse the repository at this point in the history
…ng.WindowsServices` (dotnet#67512)

* Annotate

* Update Win32.cs
  • Loading branch information
maxkoshevoi authored and directhex committed Apr 21, 2022
1 parent 72d931c commit 0233ccd
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

<PropertyGroup>
<TargetFrameworks>$(NetCoreAppCurrent);$(NetCoreAppMinimum);netstandard2.1;netstandard2.0;$(NetFrameworkMinimum)</TargetFrameworks>
<Nullable>enable</Nullable>
<EnableDefaultItems>true</EnableDefaultItems>
</PropertyGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ namespace Microsoft.Extensions.Hosting.WindowsServices.Internal
[SupportedOSPlatform("windows")]
internal static class Win32
{
internal static Process GetParentProcess()
internal static Process? GetParentProcess()
{
var snapshotHandle = IntPtr.Zero;
try
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>$(NetCoreAppCurrent);$(NetCoreAppMinimum);netstandard2.1;netstandard2.0;$(NetFrameworkMinimum)</TargetFrameworks>
<Nullable>enable</Nullable>
<EnableDefaultItems>true</EnableDefaultItems>
<!-- Use targeting pack references instead of granular ones in the project file. -->
<DisableImplicitAssemblyReferences>false</DisableImplicitAssemblyReferences>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ namespace Microsoft.Extensions.Hosting.WindowsServices
[SupportedOSPlatform("windows")]
public class WindowsServiceLifetime : ServiceBase, IHostLifetime
{
private readonly TaskCompletionSource<object> _delayStart = new TaskCompletionSource<object>(TaskCreationOptions.RunContinuationsAsynchronously);
private readonly TaskCompletionSource<object?> _delayStart = new TaskCompletionSource<object?>(TaskCreationOptions.RunContinuationsAsynchronously);
private readonly ManualResetEventSlim _delayStop = new ManualResetEventSlim();
private readonly HostOptions _hostOptions;

Expand All @@ -23,19 +23,11 @@ public WindowsServiceLifetime(IHostEnvironment environment, IHostApplicationLife
{
}

public WindowsServiceLifetime(IHostEnvironment environment, IHostApplicationLifetime applicationLifetime, ILoggerFactory loggerFactory, IOptions<HostOptions> optionsAccessor, IOptions<WindowsServiceLifetimeOptions> windowsServiceOptionsAccessor)
public WindowsServiceLifetime(IHostEnvironment environment!!, IHostApplicationLifetime applicationLifetime!!, ILoggerFactory loggerFactory, IOptions<HostOptions> optionsAccessor!!, IOptions<WindowsServiceLifetimeOptions> windowsServiceOptionsAccessor!!)
{
Environment = environment ?? throw new ArgumentNullException(nameof(environment));
ApplicationLifetime = applicationLifetime ?? throw new ArgumentNullException(nameof(applicationLifetime));
Environment = environment;
ApplicationLifetime = applicationLifetime;
Logger = loggerFactory.CreateLogger("Microsoft.Hosting.Lifetime");
if (optionsAccessor == null)
{
throw new ArgumentNullException(nameof(optionsAccessor));
}
if (windowsServiceOptionsAccessor == null)
{
throw new ArgumentNullException(nameof(windowsServiceOptionsAccessor));
}
_hostOptions = optionsAccessor.Value;
ServiceName = windowsServiceOptionsAccessor.Value.ServiceName;
CanShutdown = true;
Expand Down

0 comments on commit 0233ccd

Please sign in to comment.