Skip to content

Fix a few more API compat inconsistencies #68834

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

Merged
merged 1 commit into from
May 5, 2022

Conversation

ericstj
Copy link
Member

@ericstj ericstj commented May 3, 2022

I encountered a few more Attribute inconsistencies on top of what I previously fixed in #68432

This will be necessary to pick up dotnet/arcade#9168 once it flows to runtime

@ghost
Copy link

ghost commented May 3, 2022

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 May 3, 2022

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

Issue Details

I encountered a few more Attribute inconsistencies on top of what I previously fixed in #68432

This will be necessary to pick up dotnet/arcade#9168 once it flows to runtime

Author: ericstj
Assignees: ericstj
Labels:

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

Milestone: -

@@ -1205,7 +1205,9 @@ internal void HandleAltSvc(IEnumerable<string> altSvcHeaderValues, TimeSpan? res

if (!nextAuthorityPersist)
{
#if !ILLUMOS && !SOLARIS
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 drag it here since neither OS is really supported.
cc: @am11

Copy link
Member

Choose a reason for hiding this comment

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

If I understand it correctly, we were previously using UnknownUnix.cs pattern and not anymore (in favor of supported / unsupporter platform attributes). The compat tool is indicating that this call shouldn't be compiled on unknown unix.

Copy link
Member

Choose a reason for hiding this comment

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

@ericstj, was this auto-generated? I know that we define TARGET_{OS} constants for OS specific projects, but I am not sure if we define {OS}.

<PropertyGroup>
<DefineConstants Condition="'$(TargetsUnix)' == 'true'">$(DefineConstants);TARGET_UNIX</DefineConstants>
<DefineConstants Condition="'$(TargetsWindows)' == 'true'">$(DefineConstants);TARGET_WINDOWS</DefineConstants>
<DefineConstants Condition="'$(TargetsOSX)' == 'true'">$(DefineConstants);TARGET_OSX</DefineConstants>
<DefineConstants Condition="'$(TargetsMacCatalyst)' == 'true'">$(DefineConstants);TARGET_MACCATALYST</DefineConstants>
<DefineConstants Condition="'$(TargetsiOS)' == 'true'">$(DefineConstants);TARGET_IOS</DefineConstants>
<DefineConstants Condition="'$(TargetstvOS)' == 'true'">$(DefineConstants);TARGET_TVOS</DefineConstants>
<DefineConstants Condition="'$(TargetsBrowser)' == 'true'">$(DefineConstants);TARGET_BROWSER</DefineConstants>
<DefineConstants Condition="'$(TargetsAndroid)' == 'true'">$(DefineConstants);TARGET_ANDROID</DefineConstants>
<DefineConstants Condition="'$(TargetsLinux)' == 'true'">$(DefineConstants);TARGET_LINUX</DefineConstants>
<DefineConstants Condition="'$(TargetsFreeBSD)' == 'true'">$(DefineConstants);TARGET_FREEBSD</DefineConstants>
<DefineConstants Condition="'$(TargetsNetBSD)' == 'true'">$(DefineConstants);TARGET_NETBSD</DefineConstants>
<DefineConstants Condition="'$(Targetsillumos)' == 'true'">$(DefineConstants);TARGET_ILLUMOS</DefineConstants>
<DefineConstants Condition="'$(TargetsSolaris)' == 'true'">$(DefineConstants);TARGET_SOLARIS</DefineConstants>
</PropertyGroup>

Copy link
Member

@ViktorHofer ViktorHofer May 4, 2022

Choose a reason for hiding this comment

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

Copy link
Member

@ViktorHofer ViktorHofer May 4, 2022

Choose a reason for hiding this comment

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

System.Private.CoreLib doesn't use the TargetPlatform feature which requires platform defines to be manually specified.

Copy link
Member

Choose a reason for hiding this comment

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

If some of our libraries manually pass in TARGETS_* define constants based on the target platform, then those should probably be cleaned-up (except for CoreLib).

Yup, there is #39174 tracking review of defined vs. used constants. We are using TARGET_{OS} and TARGET_{ARCH}, but then we also had examples of TARGETS_XXX (plural) and TargetsXxx. 😁

Copy link
Member Author

@ericstj ericstj May 4, 2022

Choose a reason for hiding this comment

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

The compat tool is indicating that this call shouldn't be compiled on unknown unix.

The compiler is actually flagging the illumos and solaris builds of S.N.Http as calling unsupported API. I chose these defines based on what I saw being passed into the compiler. I had to ifdef to avoid compiler warnings as error.

@am11 @wfurt can you please let me know if you'd like anything different here? I'm trying to keep this change as minimal as possible. I could just pragma suppress the compiler warnings. I chose not to do that since these APIs were actually throwing on the unsupported platforms and I didn't want to ignore that signal.

Copy link
Member

Choose a reason for hiding this comment

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

Minimal change looks good to me. There are only a few places which require such conditions, the rest of places are filtered out via Supported/Unsupported OS attributes.

Copy link
Member

Choose a reason for hiding this comment

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

I think it is ok. I wish we did not have to drag #ifs to the HTTP code but I understand the reasoning. It would be nice if the tool can simply ignore unfinished/incomplete targets like Solaris of FreeBSD.

Copy link
Member Author

Choose a reason for hiding this comment

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

I was imagining a slightly larger refactor with partial files might also work here but I didn't want to make the diff that large.

Copy link
Member

@adamsitnik adamsitnik left a comment

Choose a reason for hiding this comment

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

System.Diagnostics.Process part LGTM, thank you @ericstj !

Not related to your changes, but to the problem that have caused it: I think that we should try to avoid having multiple os-specific .cs files that define public types and properties with [UnsupportedOSPlatform] attributes. It forces us to duplicate all the annotations and also xml docs.

IMO it's better to have a public facade with all the annotations and docs, that calls os-specific internal helper.

@ViktorHofer ViktorHofer merged commit fd60ce8 into dotnet:main May 5, 2022
@ViktorHofer
Copy link
Member

Merging in as this starts to impact the Arcade ingestion PR.

@ghost ghost locked as resolved and limited conversation to collaborators Jun 4, 2022
@karelz karelz added this to the 7.0.0 milestone Jul 19, 2022
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.

6 participants