Skip to content

Commit 31539e1

Browse files
authored
Enable nullable for dotnet test MTP implementation (#50731)
1 parent a037c33 commit 31539e1

38 files changed

+56
-133
lines changed

src/Cli/dotnet/Commands/Test/CliConstants.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
// Licensed to the .NET Foundation under one or more agreements.
22
// The .NET Foundation licenses this file to you under the MIT license.
33

4-
#nullable disable
5-
64
namespace Microsoft.DotNet.Cli.Commands.Test;
75

86
internal static class CliConstants

src/Cli/dotnet/Commands/Test/MTP/ExitCode.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
// Licensed to the .NET Foundation under one or more agreements.
22
// The .NET Foundation licenses this file to you under the MIT license.
33

4-
#nullable disable
5-
64
namespace Microsoft.DotNet.Cli.Commands.Test;
75

86
// IMPORTANT: The exit codes must match MTP:

src/Cli/dotnet/Commands/Test/MTP/IPC/INamedPipeBase.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
// Licensed to the .NET Foundation under one or more agreements.
22
// The .NET Foundation licenses this file to you under the MIT license.
33

4-
#nullable disable
5-
64
namespace Microsoft.DotNet.Cli.Commands.Test.IPC;
75

86
internal interface INamedPipeBase

src/Cli/dotnet/Commands/Test/MTP/IPC/INamedPipeSerializer.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
// Licensed to the .NET Foundation under one or more agreements.
22
// The .NET Foundation licenses this file to you under the MIT license.
33

4-
#nullable disable
5-
64
namespace Microsoft.DotNet.Cli.Commands.Test.IPC;
75

86
internal interface INamedPipeSerializer

src/Cli/dotnet/Commands/Test/MTP/IPC/IRequest.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
// Licensed to the .NET Foundation under one or more agreements.
22
// The .NET Foundation licenses this file to you under the MIT license.
33

4-
#nullable disable
5-
64
namespace Microsoft.DotNet.Cli.Commands.Test.IPC;
75

86
internal interface IRequest

src/Cli/dotnet/Commands/Test/MTP/IPC/IResponse.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
// Licensed to the .NET Foundation under one or more agreements.
22
// The .NET Foundation licenses this file to you under the MIT license.
33

4-
#nullable disable
5-
64
namespace Microsoft.DotNet.Cli.Commands.Test.IPC;
75

86
internal interface IResponse
Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
// Licensed to the .NET Foundation under one or more agreements.
22
// The .NET Foundation licenses this file to you under the MIT license.
33

4-
#nullable disable
5-
64
namespace Microsoft.DotNet.Cli.Commands.Test.IPC.Models;
75

86
internal sealed record class UnknownMessage(int SerializerId) : IRequest;

src/Cli/dotnet/Commands/Test/MTP/IPC/Models/VoidResponse.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
// Licensed to the .NET Foundation under one or more agreements.
22
// The .NET Foundation licenses this file to you under the MIT license.
33

4-
#nullable disable
5-
64
namespace Microsoft.DotNet.Cli.Commands.Test.IPC.Models;
75

86
internal sealed class VoidResponse : IResponse

src/Cli/dotnet/Commands/Test/MTP/IPC/NamedPipeBase.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
// Licensed to the .NET Foundation under one or more agreements.
22
// The .NET Foundation licenses this file to you under the MIT license.
33

4-
#nullable disable
5-
64
using System.Globalization;
75
using Microsoft.DotNet.Cli.Commands.Test.IPC.Serializers;
86

@@ -21,7 +19,7 @@ public void RegisterSerializer(INamedPipeSerializer namedPipeSerializer, Type ty
2119

2220
protected INamedPipeSerializer GetSerializer(int id, bool skipUnknownMessages = false)
2321
{
24-
if (_idSerializer.TryGetValue(id, out INamedPipeSerializer serializer))
22+
if (_idSerializer.TryGetValue(id, out INamedPipeSerializer? serializer))
2523
{
2624
return serializer;
2725
}
@@ -38,7 +36,7 @@ protected INamedPipeSerializer GetSerializer(int id, bool skipUnknownMessages =
3836

3937

4038
protected INamedPipeSerializer GetSerializer(Type type)
41-
=> _typeSerializer.TryGetValue(type, out INamedPipeSerializer serializer)
39+
=> _typeSerializer.TryGetValue(type, out INamedPipeSerializer? serializer)
4240
? serializer
4341
: throw new ArgumentException(string.Format(
4442
CultureInfo.InvariantCulture,

src/Cli/dotnet/Commands/Test/MTP/IPC/NamedPipeServer.cs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
// Licensed to the .NET Foundation under one or more agreements.
22
// The .NET Foundation licenses this file to you under the MIT license.
33

4-
#nullable disable
5-
64
using System.Buffers;
75
using System.Diagnostics;
6+
using System.Diagnostics.CodeAnalysis;
87
using System.Globalization;
98
using System.IO.Pipes;
109

@@ -22,7 +21,7 @@ internal sealed class NamedPipeServer : NamedPipeBase
2221
private readonly byte[] _readBuffer = new byte[250000];
2322
private readonly byte[] _sizeOfIntArray = new byte[sizeof(int)];
2423
private readonly bool _skipUnknownMessages;
25-
private Task _loopTask;
24+
private Task? _loopTask;
2625
private bool _disposed;
2726

2827
public NamedPipeServer(
@@ -238,7 +237,7 @@ public void Dispose()
238237
// This is unexpected and we throw an exception.
239238

240239
// To close gracefully we need to ensure that the client closed the stream line 103.
241-
if (!_loopTask.Wait(TimeSpan.FromSeconds(90)))
240+
if (!_loopTask!.Wait(TimeSpan.FromSeconds(90)))
242241
{
243242
throw new InvalidOperationException(CliCommandStrings.InternalLoopAsyncDidNotExitSuccessfullyErrorMessage);
244243
}

0 commit comments

Comments
 (0)