-
Notifications
You must be signed in to change notification settings - Fork 5.1k
Unify reading from procfs to get network related information #63696
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Tagging subscribers to this area: @dotnet/area-infrastructure-libraries Issue DetailsThis PR makes sure undocumented exceptions like I am still a bit unsure whether using Another candidate would be Opinions welcome. fixes #22927
|
b099b55
to
70dd58d
Compare
...System.Net.NetworkInformation/src/System/Net/NetworkInformation/StringParsingHelpers.Misc.cs
Show resolved
Hide resolved
<PropertyGroup> | ||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks> | ||
<StringResourcesPath>../../src/Resources/Strings.resx</StringResourcesPath> | ||
<TargetFrameworks>$(NetCoreAppCurrent)</TargetFrameworks> | ||
<IgnoreForCI Condition="'$(TargetOS)' == 'Browser'">true</IgnoreForCI> | ||
<DefineConstants>$(DefineConstants);NETWORKINFORMATION_TEST</DefineConstants> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should name it UnitTest?
Tagging subscribers to this area: @dotnet/ncl Issue DetailsThis PR makes sure undocumented exceptions like We will throw Fixes #62513
|
} | ||
|
||
string tcp4FileContents = File.ReadAllText(tcp4ConnectionsFile); | ||
string tcp4FileContents = ReadAllText(tcp4ConnectionsFile); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are we getting rid of the file existence checks?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The reason was to change the type of exception thrown to something more appropriate. PNSE is not mentioned by the docs and feels more appropriate for cases when there is no (implemented?) way of accessing the information in question.
Omitting the file existence checks will still make the code throw, but it will throw NetworkInformationException
instead (which is mentioned in the docs), and its inner exception will provide more info to the user.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changing the exception type is technically breaking change. But same argument as above could be applicable here. It feels it would be better and perhaps make the helper nullable and deal with lack of the file more gracefully.
...Net.NetworkInformation/src/System/Net/NetworkInformation/StringParsingHelpers.Connections.cs
Show resolved
Hide resolved
} | ||
|
||
string tcp4FileContents = File.ReadAllText(tcp4ConnectionsFile); | ||
string tcp4FileContents = ReadAllText(tcp4ConnectionsFile); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changing the exception type is technically breaking change. But same argument as above could be applicable here. It feels it would be better and perhaps make the helper nullable and deal with lack of the file more gracefully.
...System.Net.NetworkInformation/src/System/Net/NetworkInformation/StringParsingHelpers.Misc.cs
Show resolved
Hide resolved
...System.Net.NetworkInformation/src/System/Net/NetworkInformation/StringParsingHelpers.Misc.cs
Show resolved
Hide resolved
/azp run runtime-libraries-coreclr outerloop |
Azure Pipelines successfully started running 1 pipeline(s). |
Outerloop CI failures are unrelated:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
24c5100
to
20bb873
Compare
Rebasing to restart CI checks |
CI failures are #65841, others unrelated. |
This PR makes sure undocumented exceptions like
UnauthorizedAccessException
does not bubble to user code when querying network interface information.We will throw
NetworkInformationException
with the message "An error was encountered while querying information from the operating system." and pass the inner exception along. It seems more appropriate thanPlatformNotSupportedException
(which is currently thrown when the files do not exist).Fixes #62513