• 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/IPNetwork2Ctor.cs
1
// <copyright file="IPNetwork2Ctor.cs" company="IPNetwork">
2
// Copyright (c) IPNetwork. All rights reserved.
3
// </copyright>
4

5
namespace System.Net;
6

7
using System.Net.Sockets;
8
using System.Numerics;
9

10
/// <summary>
11
/// The constructors of IPNetwork2.
12
/// </summary>
13
public partial class IPNetwork2
14
{
15
    /// <summary>
16
    /// Initializes a new instance of the <see cref="IPNetwork2"/> class with the specified IP address, address family, and CIDR.
17
    /// </summary>
18
    /// <param name="ipaddress">The IP address of the network.</param>
19
    /// <param name="family">The address family of the network.</param>
20
    /// <param name="cidr">The CIDR (Classless Inter-Domain Routing) notation of the network.</param>
21
    internal IPNetwork2(BigInteger ipaddress, AddressFamily family, byte cidr)
×
22
    {
×
23
        this.Init(ipaddress, family, cidr);
×
24
        this.cachedHashCode = new Lazy<int>(this.ComputeHashCode);
×
25
    }
×
26

27
    /// <summary>
28
    /// Initializes a new instance of the <see cref="IPNetwork2"/> class.
29
    /// Creates a new IPNetwork.
30
    /// </summary>
31
    /// <param name="ipaddress">An ipaddress.</param>
32
    /// <param name="cidr">A byte representing the netmask in cidr format (/24).</param>
33
    /// <exception cref="ArgumentNullException">ipaddress is null.</exception>
34
    public IPNetwork2(IPAddress ipaddress, byte cidr)
×
35
    {
×
36
        if (ipaddress == null)
×
37
        {
×
38
            throw new ArgumentNullException(nameof(ipaddress));
×
39
        }
40

41
        BigInteger uintIpAddress = ToBigInteger(ipaddress);
×
42

43
        this.Init(uintIpAddress, ipaddress.AddressFamily, cidr);
×
44
        this.cachedHashCode = new Lazy<int>(this.ComputeHashCode);
×
45
    }
×
46

47
    private void Init(BigInteger ipaddress1, AddressFamily family1, byte cidr1)
48
    {
×
49
        int maxCidr = family1 == AddressFamily.InterNetwork ? 32 : 128;
×
50
        if (cidr1 > maxCidr)
×
51
        {
×
52
            throw new ArgumentOutOfRangeException(nameof(cidr1));
×
53
        }
54

55
        this.ipaddress = ipaddress1;
×
56
        this.family = family1;
×
57
        this.cidr = cidr1;
×
58
    }
×
59
}
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