-
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
Correcting Mismatch between ref and src #39741
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: @safern, @ViktorHofer |
@@ -226,9 +226,9 @@ public static bool TryParse([NotNullWhen(true)] string? ipString, [NotNullWhen(t | |||
return (address != null); | |||
} | |||
|
|||
public static bool TryParse(ReadOnlySpan<char> ipSpan, [NotNullWhen(true)] out IPAddress? address) | |||
public static bool TryParse(ReadOnlySpan<char> ipString, [NotNullWhen(true)] out IPAddress? address) |
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.
@dotnet/ncl this looks like less desirable than what was previously here. If you intended to change the reference assembly prameter name, take that through API review and file a breaking change issue.
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.
Original API proposal: #22918
public static bool TryParse(ReadOnlySpan<char> ipChars, out IPAddress address);
According to the original issue, it should be ipChars
. The code is quite old (merged 3 years ago on Aug 22, 2017). @karelz is parameter name change breaking change? If not, should we align it with the original API proposal?
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 publicly documented API is ipString
https://docs.microsoft.com/en-us/dotnet/api/system.net.ipaddress.tryparse?view=netcore-3.1#System_Net_IPAddress_TryParse_System_ReadOnlySpan_System_Char__System_Net_IPAddress__
It's also what we've shipped since 2.1 dotnet/corefx@0029b32#diff-08121b9ae82947c9c21c6bb7c18202a4R223
is parameter name change breaking change?
It's source breaking when source uses named parameters. EG:
ReadOnlySpan<char> ip = "1.1.1.1";
IPAddress res;
IPAddress.TryParse(ipString: ip, out res);
If you were to correct the ref, this source would break.
Technically changing implementation is also observable, through reflection, but we typically prioritize avoiding source breaking changes on these issues.
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.
@dotnet/ncl please weigh in on what you'd like to do here.
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.
We should keep the same name we had in previous release 3.1 IMO ... at this stage of 5.0, I would avoid discussions about changing param name.
How was the discrepancy introduced?
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.
In the original PR, just overlooked when doing review I guess.
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.
@karelz we're weighing which way is less breaking (fixing ref vs fixing src). Currently we're thinking fixing ref is less breaking, and we still have a chance to do that. Are you suggesting that instead we don't make any changes and keep ref and src out of sync?
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.
OK, the original PR dotnet/corefx#23224 introduced the inconsistency: ref with ipString
, but implementation with ipSpan
(while approved API asked for ipChars
).
I agree that changing the implementation to match the ref name makes most sense at this point -- it is the least breaking.
I don't think it is worth to make the breaking change of parameter name in ref in 5.0 (and likely 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.
(our replies crossed and I didn't see your summary in #39741 (comment))
Honestly, it probably does not matter which way we go. I am fine to go with recommendation from API review folks. ipSpan
is not ideal ... if API review group is fine with such arg name, we can use it. Otherwise, let's stick to ipString
.
The risk of breaking customers is either way fairly small IMO.
@@ -66,10 +66,10 @@ public StackFrame() | |||
/// <summary> | |||
/// Constructs a StackFrame corresponding to the active stack frame. | |||
/// </summary> | |||
public StackFrame(bool needFileInfo) | |||
public StackFrame(bool fNeedFileInfo) |
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 another potentially undesirable change, however preserves compat. cc @tommcdon
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.
src/libraries/System.Private.CoreLib/src/System/Diagnostics/StackFrame.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Resources.Writer/ref/System.Resources.Writer.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.CodeDom/src/System/CodeDom/Compiler/CodeGenerator.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.IO.MemoryMappedFiles/ref/System.IO.MemoryMappedFiles.cs
Outdated
Show resolved
Hide resolved
@ericstj @safern @ViktorHofer can u approve this one ? |
...raries/System.IO.MemoryMappedFiles/src/Microsoft/Win32/SafeMemoryMappedFileHandle.Windows.cs
Outdated
Show resolved
Hide resolved
@ericstj I guess we will need to file breaking change issues for all parameter name changes in implementation given it is a reflection breaking change? |
Possibly, though as I mentioned we considered changing the ref more breaking than "fixing" the src to match the ref. I'd prefer we git area-owners to chime in on what's best for their own API and then based on that decide if they need to document a break. |
Actually thinking through this a bit more. It looks to me like largely the runtime side of these has better naming. The reference side, though more breaking, is less likely to block someone. If they happened to be using named parameters they'll see a compile error with an easy fix. Compare that to the runtime side which may result in different behavior or exception. At this point a developer may be blocked if they don't have the ability to recompile the code. I think I'm going to flip on this and reccomend we update refs to match src and just file the breaking change notice for refs. cc @terrajobst @stephentoub in case I'm missing something. |
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
Let's make sure to file a breaking change notice mentioning all the places where the parameter names change on references, noting it breaks source that referred to these using named-parameters.
Created the breaking change notice dotnet/docs#19763 |
* minor formatting * ref changes
working towards #26187
Changing src to match ref.
In order to change ref we need api approval.
Some small genapi related re ordering of members.
cc @buyaa-n @safern @tannergooding @carlossanlop @dotnet/ncl @tarekgh