Skip to content

Commit ec127fb

Browse files
authored
Merge pull request #385 from lduchosal/feat/v4-remove-obsoletes
feat!: remove obsolete static methods
2 parents f6b1469 + a5953a4 commit ec127fb

19 files changed

+3
-453
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,3 +289,6 @@ __pycache__/
289289
*.xsd.cs
290290
src/System.Net.IPNetwork.TestProject.NetCore/coverage.net5.0.opencover.xml
291291
coverage.xml
292+
293+
# macOS
294+
.DS_Store

src/System.Net.IPNetwork/Filter.cs

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,3 @@ public enum Filter
1515
/// </summary>
1616
Usable,
1717
}
18-
19-
/// <summary>
20-
/// Represents different filters for a collection of items.
21-
/// </summary>
22-
public enum FilterEnum
23-
{
24-
/// <summary>
25-
/// Every IPAdresses are returned
26-
/// </summary>
27-
All,
28-
29-
/// <summary>
30-
/// Returns only usable IPAdresses
31-
/// </summary>
32-
Usable,
33-
}

src/System.Net.IPNetwork/IPNetwork2Contains.cs

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -68,38 +68,6 @@ public bool Contains(IPNetwork2 contains)
6868
return result;
6969
}
7070

71-
/// <summary>
72-
/// return true if ipaddress is contained in network.
73-
/// </summary>
74-
/// <param name="network">The network.</param>
75-
/// <param name="ipaddress">The ip address to test.</param>
76-
/// <returns>true if ipaddress is contained into the IP Network; otherwise, false.</returns>
77-
public static bool Contains(IPNetwork2 network, IPAddress ipaddress)
78-
{
79-
if (network == null)
80-
{
81-
throw new ArgumentNullException(nameof(network));
82-
}
83-
84-
return network.Contains(ipaddress);
85-
}
86-
87-
/// <summary>
88-
/// return true is network2 is fully contained in network.
89-
/// </summary>
90-
/// <param name="network">The network.</param>
91-
/// <param name="network2">The network to test.</param>
92-
/// <returns>true if network2 is contained into the IP Network; otherwise, false.</returns>
93-
public static bool Contains(IPNetwork2 network, IPNetwork2 network2)
94-
{
95-
if (network == null)
96-
{
97-
throw new ArgumentNullException(nameof(network));
98-
}
99-
100-
return network.Contains(network2);
101-
}
102-
10371
private static BigInteger CreateBroadcast(ref BigInteger network, BigInteger netmask, AddressFamily family)
10472
{
10573
int width = family == AddressFamily.InterNetwork ? 4 : 16;

src/System.Net.IPNetwork/IPNetwork2IANAblock.cs

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -179,22 +179,6 @@ public static bool IsIANAReserved(IPAddress ipaddress)
179179
return IsIANAReservedIPv4(ipaddress);
180180
}
181181

182-
/// <summary>
183-
/// return true if ipnetwork is contained in
184-
/// any IANA reserved block (IPv4 or IPv6).
185-
/// </summary>
186-
/// <param name="ipnetwork">The IPNetwork to test.</param>
187-
/// <returns>true if the ipnetwork is in an IANA reserved block; otherwise, false.</returns>
188-
public static bool IsIANAReserved(IPNetwork2 ipnetwork)
189-
{
190-
if (ipnetwork == null)
191-
{
192-
throw new ArgumentNullException(nameof(ipnetwork));
193-
}
194-
195-
return ipnetwork.IsIANAReserved();
196-
}
197-
198182
/// <summary>
199183
/// return true if this ipnetwork is contained in
200184
/// any IANA reserved block (IPv4 or IPv6).

src/System.Net.IPNetwork/IPNetwork2ListIPAddress.cs

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,4 @@ public IPAddressCollection ListIPAddress(Filter filter = Filter.All)
1818
{
1919
return new IPAddressCollection(this, filter);
2020
}
21-
22-
/// <summary>
23-
/// List all ip addresses in a subnet.
24-
/// </summary>
25-
/// <param name="filter">Filter IPAdresses from IPNetwork.</param>
26-
/// <returns>The filterted IPAdresses contained in ipnetwork.</returns>
27-
public IPAddressCollection ListIPAddress(FilterEnum filter)
28-
{
29-
var newFilter = filter == FilterEnum.Usable ? Filter.Usable : Filter.All;
30-
return new IPAddressCollection(this, newFilter);
31-
}
3221
}

src/System.Net.IPNetwork/IPNetwork2Overlap.cs

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -11,22 +11,6 @@ namespace System.Net;
1111
/// </summary>
1212
public sealed partial class IPNetwork2
1313
{
14-
/// <summary>
15-
/// return true is network2 overlap network.
16-
/// </summary>
17-
/// <param name="network">The network.</param>
18-
/// <param name="network2">The network to test.</param>
19-
/// <returns>true if network2 overlaps into the IP Network; otherwise, false.</returns>
20-
public static bool Overlap(IPNetwork2 network, IPNetwork2 network2)
21-
{
22-
if (network == null)
23-
{
24-
throw new ArgumentNullException(nameof(network));
25-
}
26-
27-
return network.Overlap(network2);
28-
}
29-
3014
/// <summary>
3115
/// return true is network2 overlap network.
3216
/// </summary>

src/System.Net.IPNetwork/IPNetwork2Print.cs

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -11,21 +11,6 @@ namespace System.Net;
1111
/// </summary>
1212
public sealed partial class IPNetwork2
1313
{
14-
/// <summary>
15-
/// Print an ipnetwork in a clear representation string.
16-
/// </summary>
17-
/// <param name="ipnetwork">The IPNetwork to print.</param>
18-
/// <returns>Dump an IPNetwork representation as string.</returns>
19-
public static string Print(IPNetwork2 ipnetwork)
20-
{
21-
if (ipnetwork == null)
22-
{
23-
throw new ArgumentNullException(nameof(ipnetwork));
24-
}
25-
26-
return ipnetwork.Print();
27-
}
28-
2914
/// <summary>
3015
/// Print an ipnetwork in a clear representation string.
3116
/// </summary>

src/System.Net.IPNetwork/IPNetwork2Subnet.cs

Lines changed: 0 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -41,43 +41,6 @@ public IPNetworkCollection Subnet(byte cidr1)
4141
return ipnetworkCollection;
4242
}
4343

44-
/// <summary>
45-
/// Subnet a network into multiple nets of cidr mask
46-
/// Subnet 192.168.0.0/24 into cidr 25 gives 192.168.0.0/25, 192.168.0.128/25
47-
/// Subnet 10.0.0.0/8 into cidr 9 gives 10.0.0.0/9, 10.128.0.0/9.
48-
/// </summary>
49-
/// <param name="network">The network to subnet.</param>
50-
/// <param name="cidr">A byte representing the CIDR to be used to subnet the network.</param>
51-
/// <returns>A IPNetworkCollection split by CIDR.</returns>
52-
public static IPNetworkCollection Subnet(IPNetwork2 network, byte cidr)
53-
{
54-
if (!InternalSubnet(false, network, cidr, out IPNetworkCollection? ipnetworkCollection))
55-
{
56-
throw new ArgumentException("Invalid CIDR.", nameof(cidr));
57-
}
58-
59-
return ipnetworkCollection;
60-
}
61-
62-
/// <summary>
63-
/// Subnet a network into multiple nets of cidr mask
64-
/// Subnet 192.168.0.0/24 into cidr 25 gives 192.168.0.0/25, 192.168.0.128/25
65-
/// Subnet 10.0.0.0/8 into cidr 9 gives 10.0.0.0/9, 10.128.0.0/9.
66-
/// </summary>
67-
/// <param name="network">The network to subnet.</param>
68-
/// <param name="cidr">A byte representing the CIDR to be used to subnet the network.</param>
69-
/// <param name="ipnetworkCollection">The resulting subnetted IPNetwork.</param>
70-
/// <returns>true if network was split successfully; otherwise, false.</returns>
71-
public static bool TrySubnet(IPNetwork2 network, byte cidr, out IPNetworkCollection? ipnetworkCollection)
72-
{
73-
if (network == null)
74-
{
75-
throw new ArgumentNullException(nameof(network));
76-
}
77-
78-
return InternalSubnet(true, network, cidr, out ipnetworkCollection);
79-
}
80-
8144
/// <summary>
8245
/// Splits a given IP network into smaller subnets of the specified CIDR size.
8346
/// </summary>

src/System.Net.IPNetwork/IPNetwork2Supernet.cs

Lines changed: 0 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -44,50 +44,6 @@ public bool TrySupernet(IPNetwork2 network2, [NotNullWhen(true)] out IPNetwork2?
4444
return InternalSupernet(true, this, network2, out supernet);
4545
}
4646

47-
/// <summary>
48-
/// Supernet two consecutive cidr equal subnet into a single one
49-
/// 192.168.0.0/24 + 192.168.1.0/24 = 192.168.0.0/23
50-
/// 10.1.0.0/16 + 10.0.0.0/16 = 10.0.0.0/15
51-
/// 192.168.0.0/24 + 192.168.0.0/25 = 192.168.0.0/24.
52-
/// </summary>
53-
/// <param name="network1">The first network.</param>
54-
/// <param name="network2">The second network.</param>
55-
/// <returns>A super netted IP Network.</returns>
56-
public static IPNetwork2 Supernet(IPNetwork2 network1, IPNetwork2 network2)
57-
{
58-
if (!InternalSupernet(false, network1, network2, out IPNetwork2? supernet))
59-
{
60-
throw new ArgumentException("Failed to supernet networks.", nameof(network2));
61-
}
62-
63-
return supernet;
64-
}
65-
66-
/// <summary>
67-
/// Try to supernet two consecutive cidr equal subnet into a single one
68-
/// 192.168.0.0/24 + 192.168.1.0/24 = 192.168.0.0/23
69-
/// 10.1.0.0/16 + 10.0.0.0/16 = 10.0.0.0/15
70-
/// 192.168.0.0/24 + 192.168.0.0/25 = 192.168.0.0/24.
71-
/// </summary>
72-
/// <param name="network1">The first network.</param>
73-
/// <param name="network2">The second network.</param>
74-
/// <param name="supernet">The resulting IPNetwork.</param>
75-
/// <returns>true if network1 and network2 were super netted successfully; otherwise, false.</returns>
76-
public static bool TrySupernet(IPNetwork2 network1, IPNetwork2 network2, [NotNullWhen(true)] out IPNetwork2? supernet)
77-
{
78-
if (network1 == null)
79-
{
80-
throw new ArgumentNullException(nameof(network1));
81-
}
82-
83-
if (network2 == null)
84-
{
85-
throw new ArgumentNullException(nameof(network2));
86-
}
87-
88-
return InternalSupernet(true, network1, network2, out supernet);
89-
}
90-
9147
/// <summary>
9248
/// Attempts to merge two adjacent IP networks with equal CIDR values into a single supernet.
9349
/// </summary>

src/TestProject/ContainsUnitTest.cs

Lines changed: 0 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -49,35 +49,6 @@ public void TestContainsAdrress(string network1, string networkOrAddress, bool e
4949
Assert.AreEqual(expected, result, "contains");
5050
}
5151

52-
/// <summary>
53-
/// Test.
54-
/// </summary>
55-
[TestMethod]
56-
public void TestContainsStatic3()
57-
{
58-
IPNetwork2 ipnetwork = null;
59-
IPNetwork2 ipnetwork2 = null;
60-
61-
Assert.ThrowsExactly<ArgumentNullException>(() =>
62-
{
63-
IPNetwork2.Contains(ipnetwork, ipnetwork2);
64-
});
65-
}
66-
67-
/// <summary>
68-
/// Test.
69-
/// </summary>
70-
[TestMethod]
71-
public void TestContainsStatic4()
72-
{
73-
IPNetwork2 ipnetwork = IPNetwork2.IANA_CBLK_RESERVED1;
74-
IPNetwork2 ipnetwork2 = IPNetwork2.IANA_CBLK_RESERVED1;
75-
76-
bool result = IPNetwork2.Contains(ipnetwork, ipnetwork2);
77-
78-
Assert.IsTrue(result, "result");
79-
}
80-
8152
/// <summary>
8253
/// Test.
8354
/// </summary>
@@ -93,34 +64,6 @@ public void TestContains8()
9364
});
9465
}
9566

96-
/// <summary>
97-
/// Test.
98-
/// </summary>
99-
[TestMethod]
100-
public void TestContainsStatic1()
101-
{
102-
IPNetwork2 ipnetwork = null;
103-
IPAddress ipaddress = null;
104-
105-
Assert.ThrowsExactly<ArgumentNullException>(() =>
106-
{
107-
IPNetwork2.Contains(ipnetwork, ipaddress);
108-
});
109-
}
110-
111-
/// <summary>
112-
/// Test.
113-
/// </summary>
114-
[TestMethod]
115-
public void TestContainsStatic2()
116-
{
117-
IPNetwork2 ipnetwork = IPNetwork2.IANA_ABLK_RESERVED1;
118-
var ipaddress = IPAddress.Parse("10.0.0.1");
119-
120-
bool result = IPNetwork2.Contains(ipnetwork, ipaddress);
121-
Assert.IsTrue(result, "result");
122-
}
123-
12467
/// <summary>
12568
/// Test.
12669
/// </summary>

0 commit comments

Comments
 (0)