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

lduchosal / ipnetwork / 581

02 Jun 2023 08:29AM CUT coverage: 94.615%. Remained the same
581

push

appveyor

web-flow
Merge pull request #271 from lduchosal/dependabot/nuget/Microsoft.CodeCoverage-17.6.1

Build(deps): Bump Microsoft.CodeCoverage from 17.6.0 to 17.6.1

1599 of 1690 relevant lines covered (94.62%)

1185099.52 hits per line

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

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

5
namespace System.Net
6
{
7
    using System.Net.Sockets;
8

9
    /// <summary>
10
    /// Try to guess a CIDR in a ClassLess way ie. ipv4 = 32, ipv6 = 128.
11
    /// </summary>
12
    public sealed class CidrClassLess : ICidrGuess
13
    {
14
        /// <summary>
15
        ///
16
        /// IPV4 : 32
17
        /// IPV6 : 128.
18
        ///
19
        /// </summary>
20
        /// <param name="ip">A string representing an ipadress that will be used to guess CIDR.</param>
21
        /// <param name="cidr">A byte representing the netmask in cidr format (/24).</param>
22
        /// <returns>true if ip was converted successfully; otherwise, false.</returns>
23
        public bool TryGuessCidr(string ip, out byte cidr)
24
        {
17✔
25
            IPAddress ipaddress = null;
17✔
26
            bool parsed = IPAddress.TryParse(string.Format("{0}", ip), out ipaddress);
17✔
27
            if (parsed == false)
17✔
28
            {
2✔
29
                cidr = 0;
2✔
30
                return false;
2✔
31
            }
32

33
            if (ipaddress.AddressFamily == AddressFamily.InterNetworkV6)
15✔
34
            {
6✔
35
                cidr = 128;
6✔
36
                return true;
6✔
37
            }
38

39
            cidr = 32;
9✔
40
            return true;
9✔
41
        }
17✔
42
    }
43
}
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

© 2025 Coveralls, Inc