-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
New PhysicalAddress.TryParse methods taking span and string #1057
New PhysicalAddress.TryParse methods taking span and string #1057
Conversation
New PhysicalAddress.Parse overload taking span
...libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/PhysicalAddress.cs
Outdated
Show resolved
Hide resolved
/azp run runtime-libraries outerloop |
Azure Pipelines successfully started running 1 pipeline(s). |
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.
Looks good other than this one thing.
...libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/PhysicalAddress.cs
Outdated
Show resolved
Hide resolved
...libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/PhysicalAddress.cs
Outdated
Show resolved
Hide resolved
...libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/PhysicalAddress.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Net.NetworkInformation/tests/FunctionalTests/PhysicalAddressTest.cs
Outdated
Show resolved
Hide resolved
- TryParseInternal removed
/azp run runtime-libraries outerloop |
Azure Pipelines successfully started running 1 pipeline(s). |
@@ -103,22 +103,39 @@ public byte[] GetAddressBytes() | |||
return (byte[])_address.Clone(); | |||
} | |||
|
|||
public static PhysicalAddress Parse(string address) | |||
public static PhysicalAddress Parse(string address) => address != null ? Parse(address.AsSpan()) : None; |
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.
It seems before the PR Parse(null) throw.
For string.Empty we throw too so we could use implicit conversion string->ReadOnlySpan
public static PhysicalAddress Parse(string address) => Parse(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.
It seems before the PR Parse(null) throw.
No, it returned None:
https://github.com/dotnet/runtime/pull/1057/files#diff-74838e07dff5967e2e1173264255be64L112-L115
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.
I don't know what PowerShell is passing there, but passing in null
returns None.
using System;
using System.Net.NetworkInformation;
class Program
{
static void Main()
{
Console.WriteLine(PhysicalAddress.Parse(null) == PhysicalAddress.None);
}
}
outputs:
True
That's the case for .NET Framework as well.
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.
@stephentoub Thanks! I will open new issue in PowerShell repo.
@alnikola, you merged this with a bunch of failures due to this PR that are causing stack overflow exceptions. |
Sorry for the mistake I was confused by the CI run results. It reported 73 successful checks out of 83 which made me to believe that the code is fine since I didn't do anything platform specific. |
The build legs and the test legs are separate. Lots of build legs succeeded, but the legs that actually ran the tests failed. |
This PR introduces two new PhysicalAddress.TryParse methods taking span and string as well as adds an PhysicalAddress.Parse overload taking span.
Fixes dotnet/corefx#29780