-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
Keep Obsolete and EditorBrowsable attributes consistent between ref and src and DefineConst clean-up #65847
Conversation
Note regarding the 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. |
Tagging subscribers to this area: @dotnet/area-meta Issue DetailsContributes to #58163 Commit 1: NET5_0_OR_GREATER, NET6_0_OR_GREATER -> NETCOREAPP No manual change, only replace operations:
Commit 2: Sync ObsoleteAttribute between ref and src Also making sure that the ApiCompat run that compares the live build Commit 3: Sync EditorBrowsableAttribute between ref and src @eerhardt I hope it's ok that I ask you to review this PR.
|
src/libraries/System.Xml.ReaderWriter/src/System.Xml.ReaderWriter.csproj
Outdated
Show resolved
Hide resolved
...braries/System.Text.Encodings.Web/src/System/Text/Encodings/Web/OptimizedInboxTextEncoder.cs
Outdated
Show resolved
Hide resolved
...braries/System.Text.Encodings.Web/src/System/Text/Encodings/Web/OptimizedInboxTextEncoder.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Security.Permissions/src/System/Security/Policy/PolicyLevel.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Net.HttpListener/ref/System.Net.HttpListener.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Drawing.Common/ref/System.Drawing.Common.netcoreapp.cs
Show resolved
Hide resolved
src/libraries/System.Security.Cryptography/ref/System.Security.Cryptography.cs
Show resolved
Hide resolved
src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/Marshal.NoCom.cs
Outdated
Show resolved
Hide resolved
src/libraries/apicompat/ApiCompatBaselineExcludedAttributes.txt
Outdated
Show resolved
Hide resolved
The minimum supported .NETCoreApp version in the repository is 6.0, hence both defines can be replaced with the versionless NETCOREAPP one. There is no need to version APIs below the minimum supported .NETCoreApp version.
6066f2f
to
0c258e2
Compare
The builds are now passing (quite complex to build locally for all configurations targeting the different versions of System.Private.CoreLibs). It would be great if we could get the remaining discussions solved until EOD :) |
0c258e2
to
1aa7b87
Compare
src/libraries/System.Xml.ReaderWriter/ref/System.Xml.ReaderWriter.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Threading.Thread/ref/System.Threading.Thread.cs
Outdated
Show resolved
Hide resolved
@@ -12,6 +13,7 @@ namespace System.Xml.Serialization | |||
/// </devdoc> | |||
public interface IXmlSerializable | |||
{ | |||
[EditorBrowsable(EditorBrowsableState.Never)] |
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.
This one seems surprising. Are we sure GetSchema()
should be EBS.Never?
cc @dotnet/area-system-xml
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.
ping @dotnet/area-system-xml
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.
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.
This is the last open discussion. Would love to reach conclusion today.
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.
I think this falls into the
For the changes that are just updating src to match the ref, I'd be fine with opening a follow-up issue for each.
bucket. So I guess I wouldn't let this one discussion block you.
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.
Fair enough as System.Private.Xml is an internal assembly anyway so customers never bind on it.
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.
IApplicationResourceStreamResolver can't change from Obsolete-as-Error to Obsolete-as-Warning.
Until we can figure out a tooling approach that works for that, this will just have to be a ref vs source mismatch.
1aa7b87
to
1dfd741
Compare
@bartonjs Updated the PR. For the sake of this PR I kept the mismatch as is and added a config to make ApiCompat ignore the mismatch (without a big hammer approach as before). I still think we should find a way to avoid this mismatch and I'm not yet certain if the fault lies in tooling. Based on @ericstj's earlier investigation on this matter, the compiler emits the insuppressible CS error for
Did I miss something? We should come up with a strategy that works for other types as well as we will add more ObsoleteAttributes in the future. |
The EditorBrowsableAttribute attribute wasn't enabled to be checked by ApiCompat and in many cases there were mismatches. The most prominent were InteropServices.
24c3a8e
to
f16a2a1
Compare
Added When you commit this breaking change:
Tagging @dotnet/compat for awareness of the breaking change. |
I pinged a couple people. For the changes that are just updating But the changes to the |
I added In general I'm supportive of this change -- omitting these attributes from reference assemblies is an artifact of the past when treated our reference assemblies as authored contracts with intentional differences -- that's no longer the case and excluding these is more likely to result in bugs than any benefit. |
Actually we were not just omitting these attributes from reference assemblies but also from source assemblies. It's currently wild west in main and there's no protection for it as ApiCompat doesn't check compatibility of these attributes. What makes this really concerning is that since .NET 6 we aren't shipping the contract anymore for out-of-band projects which means that package consumers bind against the implementation assembly. In the extreme case, for libraries which ship both out-of-band and inbox, you might even get different results based on what is used.
@eerhardt we should treat source and ref changes equally going forward as package consumers bind against the implementation assembly and not the contract anymore. FWIW if we succeed in collapsing source and ref projects, this will be a no brainer anyway. |
I would need an approval please :) cc @eerhardt |
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.
These changes look good to me.
This is true, however we still ship reference assemblies and you introduced new obsolete attributes to those. Even though you're just resolving an inconsistency it will have impact to customers. We need folks that own that surface area to understand the changes you are making and approve of them. Specifically: all the additions of ObsoleteAttributes to System.Net reference assemblies. |
@ericstj I think you misunderstood what I meant. I don't deny that the changes that I made here are breaking changes and that they should be documented. Did I say something that made you assume that I wouldn't treat them as breaking? On the contrary, I'm pointing out that any type of public api change is breaking, irrelevant of if it's made in a reference assembly or in an implementation assembly (except for private assembly like System.Private.Uri which customers never bind on).
Didn't we already do that as part of the review process of this PR? @eerhardt was so kind to loop in area-owners and @karelz approved the System.Net surface area changes and other area-owners approved theirs. |
I read this exchange as @eerhardt asking for approval of ref changes (also something I asked for above), then a reply to him quoting that statement saying I see that now, that @karelz's feedback was hidden in the collapsed comments and didn't see any other signoffs or comments on the main thread so it appeared like we were missing that feedback/approval. Glad we had NCL have a look. I think we're on the same page now 👍. |
Doc was created as dotnet/docs#31401 |
Contributes to #58163
Commit 1: NET5_0_OR_GREATER, NET6_0_OR_GREATER -> NETCOREAPP
The minimum supported .NETCoreApp version in the repository is 6.0,
hence defines that check on older versions and above can be replaced
with the versionless NETCOREAPP define.
There is no need to version APIs below the minimum supported .NETCoreApp
version.
No manual change, only replace operations:
Commit 2: Sync ObsoleteAttribute between ref and src
ApiCompat wasn't enabled to check if the ObsoleteAttribute is in sync
between the ref and the src assembly. Enabling it showed numerous
mismatches which this commit fixes.
Also making sure that the ApiCompat run that compares the live build
against the previous version of .NETCoreApp and .NETStandard2.x doesn't
complain about ObsoleteAttribute API changes as those are intentional.
Commit 3: Sync EditorBrowsableAttribute between ref and src
The EditorBrowsableAttribute attribute wasn't enabled to be checked by
ApiCompat and in many cases there were mismatches. The most prominent
were InteropServices.
@eerhardt I hope it's ok that I ask you to review this PR.