Skip to content

Consider adding IPNetwork.Parse #8606

Closed
@svick

Description

@svick

Is your feature request related to a problem? Please describe.

I've been reading a blog post by Jon Skeet and noticed this code in it:

options.KnownNetworks.Add(new IPNetwork(IPAddress.Parse("130.211.0.0"), 22));

I think that this code is quite verbose and it would be easier to understand if it would be possible to use IP subnet syntax here.

Describe the solution you'd like

A new method:

public class IPNetwork
{
    public static IPNetwork Parse(string subnetString);
}

It could be used like this:

options.KnownNetworks.Add(IPNetwork.Parse("130.211.0.0/22")));

If this method was added, it would probably also make sense to add a Try version of it:

public static bool TryParse(string subnetString, out IPNetwork network);

What do you think?

Metadata

Metadata

Assignees

No one assigned

    Labels

    affected-very-fewThis issue impacts very few customersapi-approvedAPI was approved in API review, it can be implementedarea-middlewareIncludes: URL rewrite, redirect, response cache/compression, session, and other general middlewaresenhancementThis issue represents an ask for new feature or an enhancement to an existing onehelp wantedUp for grabs. We would accept a PR to help resolve this issueseverity-nice-to-haveThis label is used by an internal tool

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions