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

5
namespace System.Net;
6

7
using System.Diagnostics.CodeAnalysis;
8
using System.Net.Sockets;
9

10
/// <summary>
11
/// TryGuessCidr.
12
/// </summary>
13
public sealed partial class IPNetwork2
14
{
15
    /// <summary>
16
    /// Delegate to CidrGuess ClassFull guessing of cidr.
17
    /// </summary>
18
    /// <param name="ip">A string representing an IPAdress that will be used to guess the corresponding CIDR.</param>
19
    /// <param name="cidr">The resulting CIDR as byte.</param>
20
    /// <returns>true if cidr was guessed successfully; otherwise, false.</returns>
21
    public static bool TryGuessCidr(string ip, out byte cidr)
22
    {
×
23
        return CidrGuess.ClassFull.TryGuessCidr(ip, out cidr);
×
24
    }
×
25

26
    /// <summary>
27
    /// Try to parse cidr. Have to be >= 0 and &lt;= 32 or 128.
28
    /// </summary>
29
    /// <param name="sidr">A string representing a byte CIRD (/24).</param>
30
    /// <param name="family">Either IPv4 or IPv6.</param>
31
    /// <param name="cidr">The resulting CIDR as byte.</param>
32
    /// <returns>true if cidr was converted successfully; otherwise, false.</returns>
33
    public static bool TryParseCidr(string sidr, AddressFamily family, [NotNullWhen(true)] out byte? cidr)
34
    {
×
35
        if (!byte.TryParse(sidr, out byte b))
×
36
        {
×
37
            cidr = null;
×
38
            return false;
×
39
        }
40

41
        if (!TryToNetmask(b, family, out IPAddress? _))
×
42
        {
×
43
            cidr = null;
×
44
            return false;
×
45
        }
46

47
        cidr = b;
×
48
        return true;
×
49
    }
×
50
}
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