Skip to content

Commit 05dff48

Browse files
authored
Merge pull request #57 from tbdrake/enable-nullable-in-ping-pong
Enable <Nullable> in PingPonger.csproj and address warnings
2 parents 91084bd + c0ecbc9 commit 05dff48

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

PingPonger/PingPonger.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
<PropertyGroup>
44
<OutputType>Exe</OutputType>
55
<TargetFramework>net9.0</TargetFramework>
6+
<Nullable>enable</Nullable>
67
</PropertyGroup>
78
<ItemGroup>
89
<PackageReference Include="Serilog.Sinks.ColoredConsole" Version="3.0.1"/>

PingPonger/Program.cs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,11 @@ internal class Options
2121

2222
[Option('i', "ip", Required = false,
2323
HelpText = "IP to send to")]
24-
public string IP { get; set; }
24+
public string? IP { get; set; }
2525

2626
[Option('l', "url", Required = false,
2727
HelpText = "URL to send to")]
28-
public string Url { get; set; }
28+
public string? Url { get; set; }
2929

3030
[Option('p', "port", Required = false,
3131
HelpText = "the Port to send to")]
@@ -60,7 +60,7 @@ public static int Main(string[] args)
6060

6161
logConfig.WriteTo.ColoredConsole();
6262

63-
if (options.Url.Length > 0)
63+
if (options.Url?.Length > 0)
6464
{
6565
if (options.UDP)
6666
{
@@ -71,10 +71,9 @@ public static int Main(string[] args)
7171
logConfig.WriteTo.TCPSink(options.Url, options.Port, null, null, new LogstashJsonFormatter());
7272
}
7373
}
74-
else if (options.IP.Length > 0)
74+
else if (options.IP?.Length > 0)
7575
{
76-
IPAddress ipAddress;
77-
if (!IPAddress.TryParse(options.IP, out ipAddress))
76+
if (!IPAddress.TryParse(options.IP, out var ipAddress))
7877
{
7978
Console.WriteLine("Could not parse " + options.IP + " as an IP address");
8079
return 1;

Serilog.Sinks.Network/Sinks/TCP/TCPSocketWriter.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ private async Task Run(Func<Task<Stream?>> tryOpenStream)
206206
}
207207
}
208208

209-
private async Task FlushQueue(string entry)
209+
private async Task FlushQueue(string? entry)
210210
{
211211
while (_eventQueue.Count > 0)
212212
{
@@ -285,7 +285,7 @@ public class ExponentialBackoffTcpReconnectionPolicy
285285
{
286286
private const int Ceiling = 10 * 60; // 10 minutes in seconds
287287

288-
public static async Task<Stream> ConnectAsync(Func<Uri, Task<Stream>> connect, Uri host,
288+
public static async Task<Stream?> ConnectAsync(Func<Uri, Task<Stream>> connect, Uri host,
289289
CancellationToken cancellationToken)
290290
{
291291
int delay = 1; // in seconds

0 commit comments

Comments
 (0)