2009-04-21 Sebastien Pouliot <sebastien@ximian.com>
authorSebastien Pouliot <sebastien@ximian.com>
Tue, 21 Apr 2009 11:58:26 +0000 (11:58 -0000)
committerSebastien Pouliot <sebastien@ximian.com>
Tue, 21 Apr 2009 11:58:26 +0000 (11:58 -0000)
* EndPoint.cs: Throw NotImplementedException instead of
NotSupportedException
* IPEndPoint.cs: Fix some validations.

svn path=/trunk/mcs/; revision=132244

mcs/class/System/System.Net/ChangeLog
mcs/class/System/System.Net/EndPoint.cs
mcs/class/System/System.Net/IPEndPoint.cs

index 31b8baf3d56ddf46ad5f1a1511a9d7254f22f907..5116fc0b89a8e7319cda5be2e59583534eb658e1 100644 (file)
@@ -1,3 +1,9 @@
+2009-04-21  Sebastien Pouliot  <sebastien@ximian.com>
+
+       * EndPoint.cs: Throw NotImplementedException instead of 
+       NotSupportedException
+       * IPEndPoint.cs: Fix some validations.
+
 2009-04-21 Gonzalo Paniagua Javier <gonzalo@novell.com>
 
        * WebConnection.cs:
index f1b0bc3b5c6a703e7706f4d0bdc0c1d6975f6a50..73b55c883541cb66de8dfbbc0c75bd61b4db918e 100644 (file)
@@ -35,27 +35,31 @@ namespace System.Net {
        public abstract class EndPoint {
 
                // NB: These methods really do nothing but throw
-               // NotSupportedException
+               // NotImplementedException
                
                public virtual AddressFamily AddressFamily {
-                       get {
-                               throw new NotSupportedException();
-                       }
+                       get { throw NotImplemented (); }
                }
                
                public virtual EndPoint Create (SocketAddress address)
                {
-                       throw new NotSupportedException();
+                       throw NotImplemented ();
                }
 
                public virtual SocketAddress Serialize ()
                {
-                       throw new NotSupportedException();
+                       throw NotImplemented ();
                }
 
                protected EndPoint ()
                {
                }
+
+               static Exception NotImplemented ()
+               {
+                       // hide the "normal" NotImplementedException from corcompare-like tools
+                       return new NotImplementedException ();
+               }
        }
 }
 
index 22aae683ec68d6f580f6be78723077c8163bf40f..27b816caef7002ad82bbc6204aeae9a0124dea60 100644 (file)
@@ -43,14 +43,16 @@ namespace System.Net {
                public IPEndPoint (IPAddress address, int port)
                {
                        if (address == null)
-                               throw new ArgumentNullException ("Value cannot be null");
+                               throw new ArgumentNullException ("address");
 
                        Address = address;
                        Port = port;
                }
                
-               public IPEndPoint (long iaddr, int port) : this (new IPAddress (iaddr), port)
+               public IPEndPoint (long iaddr, int port)
                {
+                       Address = new IPAddress (iaddr);
+                       Port = port;
                }
 
                public IPAddress Address {
@@ -84,18 +86,16 @@ namespace System.Net {
 
                // bytes 2 and 3 store the port, the rest
                // stores the address
-               public override EndPoint Create(SocketAddress sockaddr) {
-                       int size=sockaddr.Size;
-                       
-                       // LAMESPEC: no mention of what to do if
-                       // sockaddr is bogus
-                       if(size<8) {
-                               // absolute minimum amount needed for
-                               // an address family, buffer size,
-                               // port and address
-                               return(null);
-                       }
+               public override EndPoint Create (SocketAddress socketAddress)
+               {
+                       if (socketAddress == null)
+                               throw new ArgumentNullException ("socketAddress");
+
+                       if (socketAddress.Family != AddressFamily)
+                               throw new ArgumentException ("socketAddress");
 
+                       SocketAddress sockaddr = socketAddress;
+                       int size =sockaddr.Size;
                        AddressFamily family = sockaddr.Family;
                        int port;