Skip to content

Conversation

ManickaP
Copy link
Member

All methods/properties unconditionally throwing PNSE annotated. Also all the call sites that reported an compilation error afterwards are annotated as well.

Fixes #51301

cc @buyaa-n

@ManickaP ManickaP requested review from wfurt and a team August 12, 2021 12:54
@ghost
Copy link

ghost commented Aug 12, 2021

Note regarding the new-api-needs-documentation label:

This serves as a reminder for when your PR is modifying a ref *.cs file and adding/modifying public APIs, to please make sure the API implementation in the src *.cs file is documented with triple slash comments, so the PR reviewers can sign off that change.

@ghost
Copy link

ghost commented Aug 12, 2021

Tagging subscribers to this area: @dotnet/ncl
See info in area-owners.md if you want to be subscribed.

Issue Details

All methods/properties unconditionally throwing PNSE annotated. Also all the call sites that reported an compilation error afterwards are annotated as well.

Fixes #51301

cc @buyaa-n

Author: ManickaP
Assignees: -
Labels:

area-System.Net, new-api-needs-documentation

Milestone: -

Copy link
Member

@wfurt wfurt left a comment

Choose a reason for hiding this comment

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

generally looks good to me.
Two questions posted.

Copy link
Member

Choose a reason for hiding this comment

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

Should this be specific OS? (I don't know)

Copy link
Member Author

Choose a reason for hiding this comment

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

@buyaa-n is it necessary? Let's say if the target OS is Linux will it be considered as "unix" here?

I know that's the way it works in the build system, but I'm not sure if the analyzer behaves the same way...

Copy link
Contributor

Choose a reason for hiding this comment

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

but I'm not sure if the analyzer behaves the same way...

No, there is no Unix is Linux kind of relation in the analyzer, why could not use [UnsupportedOSPlatform("Linux")] instead?

Copy link
Member Author

Choose a reason for hiding this comment

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

This file is conditionally compiled in for all Unixes (as the build system recognizes them - TargetsUnix property):

<ItemGroup Condition="'$(TargetsUnix)' == 'true'">
<Compile Include="System\Net\NetworkInformation\IPAddressUtil.cs" />
<Compile Include="System\Net\NetworkInformation\NetworkFiles.cs" />
<Compile Include="System\Net\NetworkInformation\SimpleGatewayIPAddressInformation.Unix.cs" />
<Compile Include="System\Net\NetworkInformation\SimpleTcpConnectionInformation.Unix.cs" />
<Compile Include="System\Net\NetworkInformation\StringParsingHelpers.Dns.cs" />
<Compile Include="System\Net\NetworkInformation\UnixIPGlobalProperties.cs" />

The TargetsUnix property is defined for all *nixes, it's not just Linux, you can see where it's set to true here:
https://github.com/dotnet/runtime/blob/main/eng/targetframeworksuffix.props

It's a long list: Linux, Android, OSX, iOS, tvOS, MacCatalyst, FreeBSD, NetBSD, ... I wanted to avoid to repeat the long list here, especially if it means replicating the same thing that's defined by the build system.

Copy link
Member Author

Choose a reason for hiding this comment

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

Replaced with unix-like OSes for which we target the dll.

Copy link
Contributor

Choose a reason for hiding this comment

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

Replaced with unix-like OSes for which we target the dll.

Thanks, that is better

Sorry somehow my reply to your previous comment was not posted, here is what i wrote:

It's a long list: Linux, Android, OSX, iOS, tvOS, MacCatalyst, FreeBSD, NetBSD, ... I wanted to avoid to repeat the long list here, especially if it means replicating the same thing that's defined by the build system.

The analyzer doesn't know that Unix is related to Linux, Android, OSX, iOS, tvOS, MacCatalyst, FreeBSD, NetBSD, ..., therefore [UnsupportedOSPlatform("unix")] annotation would not work for Linux, Android, OSX, iOS, tvOS, MacCatalyst, FreeBSD, NetBSD, ...

Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure if we need to care about unsupported OSes.
There is really now way how somebody can target them right now AFAIK.

Copy link
Member Author

Choose a reason for hiding this comment

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

We have them as targets for this project:
https://github.com/dotnet/runtime/blob/8e92a6fe4d89934eba274e2a247c800a725d6de9/src/libraries/System.Net.NetworkInformation/src/System.Net.NetworkInformation.csproj#L4
I assume that's the reason why it's firing the warnings.

@buyaa-n can probably share more detail about the inner working of the analyzer.

Copy link
Contributor

Choose a reason for hiding this comment

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

I assume that's the reason why it's firing the warnings.

Right when there is a target platform in the TFM that build going to be for that platform for the analyzer. Sounds like the case the API is supported on certain platforms and throws on all others, if you cannot use SupportedOSPlatform attributes with the realistic platforms then we can skip the warnings for these unrealistic platforms.

The PNSE analyzer will not be added to the repo its just one time run to detect missing annotations

@ManickaP ManickaP requested a review from buyaa-n August 12, 2021 18:28
@buyaa-n buyaa-n requested a review from marek-safar August 12, 2021 22:18
@ManickaP ManickaP force-pushed the mapichov/51301_unsupported_attributes branch from 8e92a6f to d39aa3f Compare August 16, 2021 14:17
@ManickaP ManickaP merged commit f159402 into dotnet:main Aug 17, 2021
@ManickaP ManickaP deleted the mapichov/51301_unsupported_attributes branch August 17, 2021 10:44
@karelz karelz added this to the 6.0.0 milestone Aug 20, 2021
@ghost ghost locked as resolved and limited conversation to collaborators Sep 19, 2021
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.

Missing [un]supported APIs annotations in System.Net.NetworkInformation
4 participants