[System*] Throw a PlatformNotSupported exception when using the networking stack...
authorRolf Bjarne Kvinge <rolf@xamarin.com>
Tue, 27 Sep 2016 11:13:38 +0000 (13:13 +0200)
committerMarek Safar <marek.safar@gmail.com>
Tue, 27 Sep 2016 11:13:38 +0000 (13:13 +0200)
commite6536dd5e118a16cdca12840d6529ef9d01aaaad
treee998dac34514397f2f97beb16e1a2f10848c829d
parent59b6fde1b375e82de1a62ee772c1808cd379a53c
[System*] Throw a PlatformNotSupported exception when using the networking stack on watchOS. (#3606)

* [System] Fix line endings for a few files.

Best reviewed by not showing whitespace changes (should be empty diff in that case).

* [System] Fix potential crash in CookieParserTests.

Socket.EndAccept can throw an exception, which will crash the process if it
happens on a threadpool. So handle any exceptions when calling
Socket.EndAccept, and propagate those exceptions out of any threadpool code.

* [System.Net.Http] Throw a PlatformNotSupported exception when using HttpClientHandler on watchOS.

* [System.Net.Http] Tweak tests after watchOS API change.

Unfortunately the [ExpectedException] attribute can't be put on an entire
class, so remove the [Category ("RequiresBSDSockets")] attribute on the class
and instead decorate each test with an [ExpectedException] attribute.

* [System] Extract the HttpListenerResponseHelper class to a separate file.

Extract the HttpListenerResponseHelper class to a separate file so that it's
easier to replace the HttpListenerResponse implementation by using a different
file.

* [System] Throw a PlatformNotSupported exception when using the networking stack on watchOS.

* [System] Tweak tests after watchOS API changes.

Unfortunately the [ExpectedException] attribute can't be put on an entire
class, so remove the [Category ("RequiresBSDSockets")] attribute on the class
and instead decorate each test with an [ExpectedException] attribute.

* [System] Fix potential crash in SocketAcceptAsyncTest.

Fix potential crash in SocketAcceptAsyncTest by catching any exceptions in
code executed on the threadpool so that we never end up with unhandled
exceptions (which may terminate the process).

* [System] Avoid logic in SetUp attributes in tests.

Any type of exception in [SetUp] attributes causes all tests to fail with that
exception.

This even happens for tests that do not need the logic in the [SetUp]
attribute.

So rewrite tests a bit to not use [SetUp] when we can reasonably avoid it, and
instead instantiate class-level variables on first use. This ensures that any
exceptions that occur when initializing those variables are attributed to the
corresponding test, and not all of them.

* [System] Make exception handler (for test) catch more exceptions to avoid unhandled exceptions causing process termination.

* [System] Remove Obsolete attribute on API that throws PNSE.
54 files changed:
mcs/build/profiles/monotouch_watch.make
mcs/build/profiles/monotouch_watch_runtime.make
mcs/class/System.Net.Http/System.Net.Http/HttpClientHandler.platformnotsupported.cs [new file with mode: 0644]
mcs/class/System.Net.Http/Test/System.Net.Http/HttpClientHandlerTest.cs
mcs/class/System.Net.Http/Test/System.Net.Http/HttpClientTest.cs
mcs/class/System.Net.Http/monotouch_watch_System.Net.Http.dll.exclude.sources [new file with mode: 0644]
mcs/class/System.Net.Http/monotouch_watch_System.Net.Http.dll.sources [new file with mode: 0644]
mcs/class/System/System.Net.Mail/SmtpClient.platformnotsupported.cs [new file with mode: 0644]
mcs/class/System/System.Net.Sockets/Socket.cs
mcs/class/System/System.Net.Sockets/TcpClient.platformnotsupported.cs [new file with mode: 0644]
mcs/class/System/System.Net.Sockets/TcpListener.platformnotsupported.cs [new file with mode: 0644]
mcs/class/System/System.Net.Sockets/UdpClient.platformnotsupported.cs [new file with mode: 0644]
mcs/class/System/System.Net.WebSockets/ClientWebSocket.platformnotsupported.cs [new file with mode: 0644]
mcs/class/System/System.Net/Dns.cs
mcs/class/System/System.Net/FtpRequestCreator.platformnotsupported.cs [new file with mode: 0644]
mcs/class/System/System.Net/FtpWebRequest.platformnotsupported.cs [new file with mode: 0644]
mcs/class/System/System.Net/FtpWebResponse.platformnotsupported.cs [new file with mode: 0644]
mcs/class/System/System.Net/HttpListener.platformnotsupported.cs [new file with mode: 0644]
mcs/class/System/System.Net/HttpListenerContext.platformnotsupported.cs [new file with mode: 0644]
mcs/class/System/System.Net/HttpListenerPrefixCollection.platformnotsupported.cs [new file with mode: 0644]
mcs/class/System/System.Net/HttpListenerRequest.platformnotsupported.cs [new file with mode: 0644]
mcs/class/System/System.Net/HttpListenerResponse.cs
mcs/class/System/System.Net/HttpListenerResponse.platformnotsupported.cs [new file with mode: 0644]
mcs/class/System/System.Net/HttpListenerResponseHelper.cs [new file with mode: 0644]
mcs/class/System/System.Net/HttpWebRequest.platformnotsupported.cs [new file with mode: 0644]
mcs/class/System/System.Net/HttpWebResponse.platformnotsupported.cs [new file with mode: 0644]
mcs/class/System/System.dll.sources
mcs/class/System/Test/System.Net.Mail/SmtpClientTest.cs
mcs/class/System/Test/System.Net.Security/SslStreamTest.cs
mcs/class/System/Test/System.Net.Sockets/NetworkStreamTest.cs
mcs/class/System/Test/System.Net.Sockets/SocketAcceptAsyncTest.cs
mcs/class/System/Test/System.Net.Sockets/SocketAsyncTest.cs
mcs/class/System/Test/System.Net.Sockets/SocketTest.cs
mcs/class/System/Test/System.Net.Sockets/TcpClientTest.cs
mcs/class/System/Test/System.Net.Sockets/TcpListenerTest.cs
mcs/class/System/Test/System.Net.Sockets/UdpClientTest.cs
mcs/class/System/Test/System.Net.WebSockets/ClientWebSocketTest.cs
mcs/class/System/Test/System.Net/CookieParserTest.cs
mcs/class/System/Test/System.Net/DnsTest.cs
mcs/class/System/Test/System.Net/FileWebRequestTest.cs
mcs/class/System/Test/System.Net/FtpWebRequestTest.cs
mcs/class/System/Test/System.Net/HttpListener2Test.cs
mcs/class/System/Test/System.Net/HttpListenerPrefixCollectionTest.cs
mcs/class/System/Test/System.Net/HttpListenerRequestTest.cs
mcs/class/System/Test/System.Net/HttpListenerTest.cs
mcs/class/System/Test/System.Net/HttpWebRequestTest.cs
mcs/class/System/Test/System.Net/HttpWebResponseTest.cs
mcs/class/System/Test/System.Net/ServicePointTest.cs
mcs/class/System/Test/System.Net/WebClientTest.cs
mcs/class/System/Test/System.Net/WebHeaderCollectionTest.cs
mcs/class/System/Test/System.Net/WebRequestTest.cs
mcs/class/System/mobile_System.dll.sources
mcs/class/System/monotouch_watch_System.dll.exclude.sources [new file with mode: 0644]
mcs/class/System/monotouch_watch_System.dll.sources