• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

lduchosal / ipnetwork / 960

15 May 2026 07:18AM UTC coverage: 0.0% (-94.1%) from 94.053%
960

Pull #411

appveyor

web-flow
Merge ef6b054ce into 4cec191ae
Pull Request #411: Bump MSTest.TestFramework from 4.2.2 to 4.2.3

0 of 2438 relevant lines covered (0.0%)

0.0 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/System.Net.IPNetwork/IPAddressExtensions.cs
1
// <copyright file="IPAddressExtensions.cs" company="IPNetwork">
2
// Copyright (c) IPNetwork. All rights reserved.
3
// </copyright>
4

5
namespace System.Net;
6

7
/// <summary>
8
/// A collection of extension functions applied to an IPAddress value.
9
/// </summary>
10
public static class IPAddressExtensions
11
{
12
    /// <summary>
13
    /// Convert an IPAddress value into a single-address IPNetwork for that address.
14
    /// </summary>
15
    /// <param name="addr">IPAddress to convert.</param>
16
    /// <returns>IPNetwork object covering that IPAddress only.</returns>
17
    public static IPNetwork2 AsIPNetwork(this IPAddress addr)
18
    {
×
19
            /* IPv4? */
20
            if (addr.AddressFamily == Sockets.AddressFamily.InterNetwork)
×
21
            {
×
22
                /* Return address as a /32 network, the size of an IPv4 address. */
23
                return new IPNetwork2(addr, 32);
×
24
            }
25

26
            /* IPV6? */
27
            if (addr.AddressFamily == Sockets.AddressFamily.InterNetworkV6)
×
28
            {
×
29
                /* Return address as a /128 network, the size of an IPv6 address. */
30
                return new IPNetwork2(addr, 128);
×
31
            }
32

33
            /* No other families are supported. */
34
            throw new ArgumentException(
×
35
                $"AsIPNetwork does not support addresses in the {addr.AddressFamily} family.");
×
36
        }
×
37
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc