-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
[wasm] Support network status information #71941
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 'arch-wasm': @lewing Issue DetailsSupport these network status related API on browser
Fixes #38988
|
Tagging subscribers to this area: @dotnet/ncl Issue DetailsSupport these network status related API on browser
Fixes #38988
|
/azp run runtime-wasm |
Azure Pipelines successfully started running 1 pipeline(s). |
src/libraries/System.Net.NetworkInformation/src/System.Net.NetworkInformation.csproj
Outdated
Show resolved
Hide resolved
...tem.Net.NetworkInformation/src/System/Net/NetworkInformation/NetworkAddressChange.Browser.cs
Show resolved
Hide resolved
/azp run runtime-wasm |
Azure Pipelines successfully started running 1 pipeline(s). |
/azp run runtime-wasm |
Azure Pipelines successfully started running 1 pipeline(s). |
The browser API is not supported on V8 and NodeJS. I'm not sure how to deal with this in general, throw or let it fail in JS? |
I would throw. Then tests can cleanly check for it |
Throw when the API is not available at runtime or throw "statically" when running on V8/nodejs? Do we have any general guidance for optional browser APIs? |
|
||
namespace System.Net.NetworkInformation | ||
{ | ||
public partial class NetworkChange |
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.
Why not do this like other platform specific partial classes like NetworkAddressChange.Unix.cs
?
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 understand what do you mean. Can you please give me a clue?
...tem.Net.NetworkInformation/src/System/Net/NetworkInformation/NetworkAddressChange.Browser.cs
Outdated
Show resolved
Hide resolved
@@ -39,6 +39,7 @@ public partial class NetworkChange | |||
private static readonly AutoResetEvent s_runLoopStartedEvent = new AutoResetEvent(false); | |||
private static readonly AutoResetEvent s_runLoopEndedEvent = new AutoResetEvent(false); | |||
|
|||
[UnsupportedOSPlatform("browser")] |
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.
IIUC, this shouldn't be needed in platform specific implementation files, since they are included in the build only for the relevant platforms. Same for others.
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.
Are you sure? If I hadn't have them, the ApiCompat was complaining.
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.
Make sure to include the main .cs file also. What was the output from apicompat?
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.
If I just drop this one and try to compile with
.\dotnet.cmd build /p:TargetOS=Browser /p:TargetArchitecture=wasm /p:Configuration=Debug .\src\libraries\System.Net.NetworkInformation\src\
it fails with
....\.nuget\packages\microsoft.dotnet.apicompat\7.0.0-beta.22358.3\build\Microsoft.DotNet.ApiCompat.targets(52,5): error : Compat issues with assembly System.Net.NetworkInformation: [....\src\libraries\System.Net.NetworkInformation\src\Sy
stem.Net.NetworkInformation.csproj]
....\.nuget\packages\microsoft.dotnet.apicompat\7.0.0-beta.22358.3\build\Microsoft.DotNet.ApiCompat.targets(52,5): error : CannotChangeAttribute : Attribute 'System.Runtime.Versioning.UnsupportedOSPlatformAttribute' on 'System.Net.NetworkInformation.NetworkChange
.NetworkAddressChanged' changed from '[UnsupportedOSPlatformAttribute("browser")]' in the contract to '[UnsupportedOSPlatformAttribute("illumos")]' in the implementation. [....\src\libraries\System.Net.NetworkInformation\src\System.Net.NetworkInformation
.csproj]
....\.nuget\packages\microsoft.dotnet.apicompat\7.0.0-beta.22358.3\build\Microsoft.DotNet.ApiCompat.targets(66,5): error : ApiCompat failed for '....\artifacts\bin\System.Net.NetworkInformation\Debug\net7.0-tvos\System.Net.NetworkInformat
ion.dll' [....\src\libraries\System.Net.NetworkInformation\src\System.Net.NetworkInformation.csproj]
....\.nuget\packages\microsoft.dotnet.apicompat\7.0.0-beta.22358.3\build\Microsoft.DotNet.ApiCompat.targets(52,5): error : Compat issues with assembly System.Net.NetworkInformation: [....\src\libraries\System.Net.NetworkInformation\src\Sy
stem.Net.NetworkInformation.csproj]
....\.nuget\packages\microsoft.dotnet.apicompat\7.0.0-beta.22358.3\build\Microsoft.DotNet.ApiCompat.targets(52,5): error : CannotChangeAttribute : Attribute 'System.Runtime.Versioning.UnsupportedOSPlatformAttribute' on 'System.Net.NetworkInformation.NetworkChange
.NetworkAddressChanged' changed from '[UnsupportedOSPlatformAttribute("browser")]' in the contract to '[UnsupportedOSPlatformAttribute("illumos")]' in the implementation. [....\src\libraries\System.Net.NetworkInformation\src\System.Net.NetworkInformation
.csproj]
....\.nuget\packages\microsoft.dotnet.apicompat\7.0.0-beta.22358.3\build\Microsoft.DotNet.ApiCompat.targets(66,5): error : ApiCompat failed for '....\artifacts\bin\System.Net.NetworkInformation\Debug\net7.0-ios\System.Net.NetworkInformati
on.dll' [....\src\libraries\System.Net.NetworkInformation\src\System.Net.NetworkInformation.csproj]
....\.nuget\packages\microsoft.dotnet.apicompat\7.0.0-beta.22358.3\build\Microsoft.DotNet.ApiCompat.targets(52,5): error : Compat issues with assembly System.Net.NetworkInformation: [....\src\libraries\System.Net.NetworkInformation\src\Sy
stem.Net.NetworkInformation.csproj]
....\.nuget\packages\microsoft.dotnet.apicompat\7.0.0-beta.22358.3\build\Microsoft.DotNet.ApiCompat.targets(52,5): error : CannotChangeAttribute : Attribute 'System.Runtime.Versioning.UnsupportedOSPlatformAttribute' on 'System.Net.NetworkInformation.NetworkChange
.NetworkAddressChanged' changed from '[UnsupportedOSPlatformAttribute("browser")]' in the contract to '[UnsupportedOSPlatformAttribute("illumos")]' in the implementation. [....\src\libraries\System.Net.NetworkInformation\src\System.Net.NetworkInformation
.csproj]
....\.nuget\packages\microsoft.dotnet.apicompat\7.0.0-beta.22358.3\build\Microsoft.DotNet.ApiCompat.targets(66,5): error : ApiCompat failed for '....\artifacts\bin\System.Net.NetworkInformation\Debug\net7.0-osx\System.Net.NetworkInformati
on.dll' [....\src\libraries\System.Net.NetworkInformation\src\System.Net.NetworkInformation.csproj]
...tem.Net.NetworkInformation/src/System/Net/NetworkInformation/NetworkAddressChange.Browser.cs
Show resolved
Hide resolved
add => throw new System.PlatformNotSupportedException(System.SR.SystemNetNetworkInformation_PlatformNotSupported); | ||
remove => throw new System.PlatformNotSupportedException(System.SR.SystemNetNetworkInformation_PlatformNotSupported); |
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 corresponding tests should be run for browser, and check for PNSE.
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.
Just curious, are we writing a test for every API that is not supported on any platform?
Because this is already not supported on illumos
and solaris
. Should I run the test also on these platforms?
...aries/System.Net.NetworkInformation/tests/FunctionalTests/NetworkAvailabilityChangedTests.cs
Outdated
Show resolved
Hide resolved
...tem.Net.NetworkInformation/src/System/Net/NetworkInformation/NetworkAddressChange.Browser.cs
Outdated
Show resolved
Hide resolved
…workInformation/NetworkInterfacePal.Browser.cs Co-authored-by: Ankit Jain <radical@gmail.com>
Co-authored-by: Ankit Jain <radical@gmail.com>
# Conflicts: # src/libraries/System.Net.NetworkInformation/ref/System.Net.NetworkInformation.cs # src/libraries/apicompat/ApiCompatBaseline.NetCoreAppLatestStable.txt # src/mono/wasm/runtime/exports.ts
/azp run runtime-wasm |
Azure Pipelines successfully started running 1 pipeline(s). |
Draft Pull Request was automatically closed for 30 days of inactivity. Please let us know if you'd like to reopen it. |
Draft Pull Request was automatically closed for 30 days of inactivity. Please let us know if you'd like to reopen it. |
Support these network status related API on browser
NetworkInterface.GetIsNetworkAvailable
NetworkChange.NetworkAvailabilityChanged
TODO
Try to control a devtools network status in unit testCloses #38988