Skip to content

Conversation

@ManickaP
Copy link
Member

@ManickaP ManickaP commented Jul 8, 2025

In #117367, I have overlooked existence of "non-validating" ctor, thinking all ctor calls went through the one I've changed.
Thankfully @skyoxZ noticed it in #117367 (comment).

This fix addresses that and expands the tests to check the properties of parsed IPNetwork.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes the unintended bypass of validation by removing the private non-validating constructor in IPNetwork and expands functional tests to verify parsed network properties.

  • Removed the private non-validating IPNetwork(IPAddress, int, bool) ctor and updated all TryParse calls to use the public validating ctor.
  • Enhanced tests in IPNetworkTest.cs to compute and assert BaseAddress, PrefixLength, and normalized ToString() for both string and UTF-8 parsing.

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
src/libraries/System.Net.Primitives/tests/FunctionalTests/IPNetworkTest.cs Added computation of expected values and detailed assertions in Parse and TryParse tests.
src/libraries/System.Net.Primitives/src/System/Net/IPNetwork.cs Removed the non-validating private ctor and updated TryParse to call the public ctor.

@ManickaP
Copy link
Member Author

ManickaP commented Jul 9, 2025

/ba-g unrelated and/or known errors

@ManickaP ManickaP merged commit baf534c into dotnet:main Jul 9, 2025
76 of 87 checks passed
@ManickaP ManickaP deleted the fix-ipnetwork branch July 9, 2025 06:52
@github-actions github-actions bot locked and limited conversation to collaborators Aug 8, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants