Skip to content

Commit 7e5db2a

Browse files
authored
fix IPNetwork.cs error
1 parent 1e44ff7 commit 7e5db2a

File tree

1 file changed

+4
-10
lines changed

1 file changed

+4
-10
lines changed

src/Middleware/HttpOverrides/src/IPNetwork.cs

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33

44
using System.Diagnostics.CodeAnalysis;
55
using System.Net;
6-
using System.Net.Sockets;
76

87
namespace Microsoft.AspNetCore.HttpOverrides;
98

@@ -56,10 +55,7 @@ public IPNetwork(IPAddress prefix, int prefixLength)
5655
/// <exception cref="FormatException"><paramref name="networkSpan"/> is not in the correct format.</exception>
5756
/// <exception cref="ArgumentOutOfRangeException">The prefix length contained in <paramref name="networkSpan"/> is out of range.</exception>
5857
/// <inheritdoc cref="TryParseComponents(ReadOnlySpan{char}, out IPAddress?, out int)"/>
59-
public static IPNetwork Parse(ReadOnlySpan<char> networkSpan)
60-
{
61-
return System.Net.IPNetwork.Parse(networkSpan);
62-
}
58+
public static IPNetwork Parse(ReadOnlySpan<char> networkSpan) => System.Net.IPNetwork.Parse(networkSpan);
6359

6460
/// <summary>
6561
/// Converts the specified <see cref="ReadOnlySpan{T}"/> of <see langword="char"/> representation of
@@ -81,18 +77,16 @@ public static bool TryParse(ReadOnlySpan<char> networkSpan, [NotNullWhen(true)]
8177
{
8278
if (System.Net.IPNetwork.TryParse(networkSpan, out var ipNetwork))
8379
{
84-
network = ipNetwork;
80+
network = new(ipNetwork);
8581
return true;
8682
}
8783

84+
network = null;
8885
return false;
8986
}
9087

9188
/// <summary>
9289
/// Convert <see cref="System.Net.IPNetwork" /> to <see cref="Microsoft.AspNetCore.HttpOverrides.IPNetwork" /> implicitly
9390
/// </summary>
94-
public static implicit operator IPNetwork(System.Net.IPNetwork ipNetwork)
95-
{
96-
return new IPNetwork(ipNetwork);
97-
}
91+
public static implicit operator IPNetwork(System.Net.IPNetwork ipNetwork) => new IPNetwork(ipNetwork);
9892
}

0 commit comments

Comments
 (0)