From: Miguel de Icaza Date: Sat, 20 Mar 2010 22:49:18 +0000 (-0000) Subject: 2010-03-20 Miguel de Icaza X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=commitdiff_plain;h=f3fefd598b4cfd5a3ad999e3e1166ce24198d2dc;p=mono.git 2010-03-20 Miguel de Icaza * Uri.cs: Drop pre-2.0 support svn path=/trunk/mcs/; revision=153945 --- diff --git a/mcs/class/System/System/ChangeLog b/mcs/class/System/System/ChangeLog index 5c3fc86ceaf..62df47af16a 100644 --- a/mcs/class/System/System/ChangeLog +++ b/mcs/class/System/System/ChangeLog @@ -1,3 +1,7 @@ +2010-03-20 Miguel de Icaza + + * Uri.cs: Drop pre-2.0 support + 2010-03-19 Sebastien Pouliot * Uri.cs: Remove some MOONLIGHT defines diff --git a/mcs/class/System/System/Uri.cs b/mcs/class/System/System/Uri.cs index b5ace00284f..591c197b5d6 100644 --- a/mcs/class/System/System/Uri.cs +++ b/mcs/class/System/System/Uri.cs @@ -55,12 +55,8 @@ using System.Globalization; namespace System { [Serializable] -#if NET_2_0 [TypeConverter (typeof (UriTypeConverter))] public class Uri : ISerializable { -#else - public class Uri : MarshalByRefObject, ISerializable { -#endif // NOTES: // o scheme excludes the scheme delimiter // o port is -1 to indicate no port is defined @@ -106,10 +102,8 @@ namespace System { public static readonly string UriSchemeMailto = "mailto"; public static readonly string UriSchemeNews = "news"; public static readonly string UriSchemeNntp = "nntp"; -#if NET_2_0 public static readonly string UriSchemeNetPipe = "net.pipe"; public static readonly string UriSchemeNetTcp = "net.tcp"; -#endif // Constructors @@ -128,7 +122,6 @@ namespace System { { } -#if NET_2_0 public Uri (string uriString, UriKind uriKind) { source = uriString; @@ -212,17 +205,6 @@ namespace System { throw new UriFormatException("Invalid URI: The format of the URI could not be " + "determined: " + uriString); } -#else - public Uri (string uriString, bool dontEscape) - { - userEscaped = dontEscape; - source = uriString; - Parse (); - if (!isAbsoluteUri) - throw new UriFormatException("Invalid URI: The format of the URI could not be " - + "determined."); - } -#endif public Uri (Uri baseUri, string relativeUri) { @@ -230,9 +212,7 @@ namespace System { // FIXME: this should call UriParser.Resolve } -#if NET_2_0 [Obsolete ("dontEscape is always false")] -#endif public Uri (Uri baseUri, string relativeUri, bool dontEscape) { userEscaped = dontEscape; @@ -241,27 +221,19 @@ namespace System { private void Merge (Uri baseUri, string relativeUri) { -#if NET_2_0 if (baseUri == null) throw new ArgumentNullException ("baseUri"); if (!baseUri.IsAbsoluteUri) throw new ArgumentOutOfRangeException ("baseUri"); if (relativeUri == null) relativeUri = String.Empty; -#else - if (baseUri == null) - throw new NullReferenceException ("baseUri"); -#endif + // See RFC 2396 Par 5.2 and Appendix C // Check Windows UNC (for // it is scheme/host separator) if (relativeUri.Length >= 2 && relativeUri [0] == '\\' && relativeUri [1] == '\\') { source = relativeUri; -#if NET_2_0 ParseUri (UriKind.Absolute); -#else - Parse (); -#endif return; } @@ -286,11 +258,7 @@ namespace System { relativeUri.Length > pos + 1 && relativeUri [pos + 1] == '/') { source = relativeUri; -#if NET_2_0 ParseUri (UriKind.Absolute); -#else - Parse (); -#endif return; } else @@ -336,11 +304,7 @@ namespace System { if (relativeUri.Length > 0 && relativeUri [0] == '/') { if (relativeUri.Length > 1 && relativeUri [1] == '/') { source = scheme + ':' + relativeUri; -#if NET_2_0 ParseUri (UriKind.Absolute); -#else - Parse (); -#endif return; } else { path = relativeUri; @@ -421,7 +385,6 @@ namespace System { public string AbsolutePath { get { -#if NET_2_0 EnsureAbsoluteUri (); switch (Scheme) { case "mailto": @@ -438,9 +401,6 @@ namespace System { } return path; } -#else - return path; -#endif } } @@ -486,17 +446,12 @@ namespace System { UriHostNameType ret = CheckHostName (Host); if (ret != UriHostNameType.Unknown) return ret; -#if NET_2_0 switch (Scheme) { case "mailto": return UriHostNameType.Basic; default: return (IsFile) ? UriHostNameType.Basic : ret; } -#else - // looks it always returns Basic... - return UriHostNameType.Basic; //.Unknown; -#endif } } @@ -519,11 +474,7 @@ namespace System { EnsureAbsoluteUri (); if (Host.Length == 0) { -#if NET_2_0 return IsFile; -#else - return false; -#endif } if (host == "loopback" || host == "localhost") @@ -587,13 +538,9 @@ namespace System { else if (System.IO.Path.DirectorySeparatorChar == '\\') { string h = host; if (path.Length > 0) { -#if NET_2_0 if ((path.Length > 1) || (path[0] != '/')) { h += path.Replace ('/', '\\'); } -#else - h += path.Replace ('/', '\\'); -#endif } cachedLocalPath = "\\\\" + Unescape (h); } else @@ -684,7 +631,6 @@ namespace System { } } -#if NET_2_0 [MonoTODO ("add support for IPv6 address")] public string DnsSafeHost { get { @@ -696,18 +642,13 @@ namespace System { public bool IsAbsoluteUri { get { return isAbsoluteUri; } } -#endif + // LAMESPEC: source field is supplied in such case that this // property makes sense. For such case that source field is // not supplied (i.e. .ctor(Uri, string), this property // makes no sense. To avoid silly regression it just returns // ToString() value now. See bug #78374. -#if NET_2_0 - public -#else - internal -#endif - string OriginalString { + public string OriginalString { get { return source != null ? source : ToString (); } } @@ -744,16 +685,8 @@ namespace System { if (length == 0) return false; uint number; -#if NET_2_0 if (!UInt32.TryParse (captures [i], out number)) return false; -#else - try { - number = UInt32.Parse (captures [i]); - } catch (Exception) { - return false; - } -#endif if (number > 255) return false; } @@ -783,9 +716,7 @@ namespace System { } #if !NET_2_1 -#if NET_2_0 [Obsolete("This method does nothing, it has been obsoleted")] -#endif protected virtual void Canonicalize () { // @@ -795,9 +726,7 @@ namespace System { } [MonoTODO ("Find out what this should do")] -#if NET_2_0 [Obsolete] -#endif protected virtual void CheckSecurity () { } @@ -825,15 +754,10 @@ namespace System { private static bool IsAlpha (char c) { -#if NET_2_0 // as defined in rfc2234 // %x41-5A / %x61-7A (A-Z / a-z) int i = (int) c; return (((i >= 0x41) && (i <= 0x5A)) || ((i >= 0x61) && (i <= 0x7A))); -#else - // Fx 1.x got this too large - return Char.IsLetter (c); -#endif } public override bool Equals (object comparant) @@ -855,27 +779,19 @@ namespace System { // Assumes: uri != null bool InternalEquals (Uri uri) { -#if NET_2_0 if (this.isAbsoluteUri != uri.isAbsoluteUri) return false; if (!this.isAbsoluteUri) return this.source == uri.source; -#endif CultureInfo inv = CultureInfo.InvariantCulture; return this.scheme.ToLower (inv) == uri.scheme.ToLower (inv) && this.host.ToLower (inv) == uri.host.ToLower (inv) && this.port == uri.port -#if NET_2_0 && this.query == uri.query -#else - // Note: MS.NET 1.x has bug - ignores query check altogether - && this.query.ToLower (inv) == uri.query.ToLower (inv) -#endif && this.path == uri.path; } -#if NET_2_0 public static bool operator == (Uri u1, Uri u2) { return object.Equals(u1, u2); @@ -885,7 +801,6 @@ namespace System { { return !(u1 == u2); } -#endif public override int GetHashCode () { @@ -895,11 +810,7 @@ namespace System { cachedHashCode = scheme.ToLower (inv).GetHashCode () ^ host.ToLower (inv).GetHashCode () ^ port -#if NET_2_0 ^ query.GetHashCode () -#else - ^ query.ToLower (inv).GetHashCode () -#endif ^ path.GetHashCode (); } else { @@ -946,7 +857,6 @@ namespace System { sb.Append (':').Append (port); if (path.Length > 0) { -#if NET_2_0 switch (Scheme) { case "mailto": case "news": @@ -956,9 +866,6 @@ namespace System { sb.Append (Reduce (path)); break; } -#else - sb.Append (path); -#endif } return sb.ToString (); } @@ -1024,7 +931,6 @@ namespace System { IsHexDigit (pattern [index])); } -#if NET_2_0 // // Implemented by copying most of the MakeRelative code // @@ -1059,7 +965,6 @@ namespace System { } [Obsolete ("Use MakeRelativeUri(Uri uri) instead.")] -#endif public string MakeRelative (Uri toUri) { if ((this.Scheme != toUri.Scheme) || @@ -1113,12 +1018,10 @@ namespace System { return cachedToString; } -#if NET_2_0 protected void GetObjectData (SerializationInfo info, StreamingContext context) { info.AddValue ("AbsoluteUri", this.AbsoluteUri); } -#endif void ISerializable.GetObjectData (SerializationInfo info, StreamingContext context) { @@ -1128,9 +1031,7 @@ namespace System { // Internal Methods -#if NET_2_0 [Obsolete] -#endif protected virtual void Escape () { path = EscapeString (path); @@ -1139,9 +1040,7 @@ namespace System { #if MOONLIGHT static string EscapeString (string str) #else - #if NET_2_0 [Obsolete] - #endif protected static string EscapeString (string str) #endif { @@ -1196,14 +1095,9 @@ namespace System { // On .NET 1.x, this method is called from .ctor(). When overriden, we // can avoid the "absolute uri" constraints of the .ctor() by // overriding with custom code. -#if NET_2_0 [Obsolete("The method has been deprecated. It is not used by the system.")] -#endif protected virtual void Parse () { -#if !NET_2_0 - ParseUri (UriKind.Absolute); -#endif } private void ParseUri (UriKind kind) @@ -1227,9 +1121,7 @@ namespace System { #if MOONLIGHT string Unescape (string str) #else - #if NET_2_0 [Obsolete] - #endif protected virtual string Unescape (string str) #endif { @@ -1530,19 +1422,10 @@ namespace System { if (pos != -1 && pos != endpos - 1) { string portStr = uriString.Substring(pos + 1, endpos - (pos + 1)); if (portStr.Length > 0 && portStr[portStr.Length - 1] != ']') { -#if NET_2_0 if (!Int32.TryParse (portStr, NumberStyles.Integer, CultureInfo.InvariantCulture, out port) || port < 0 || port > UInt16.MaxValue) return "Invalid URI: Invalid port number"; endpos = pos; -#else - try { - port = (int) UInt32.Parse (portStr, CultureInfo.InvariantCulture); - endpos = pos; - } catch (Exception) { - return "Invalid URI: Invalid port number"; - } -#endif } else { if (port == -1) { port = GetDefaultPort (scheme); @@ -1591,7 +1474,6 @@ namespace System { else badhost = true; } -#if NET_2_0 if (badhost && (Parser is DefaultUriParser || Parser == null)) return Locale.GetText ("Invalid URI: The hostname could not be parsed. (" + host + ")"); @@ -1600,10 +1482,6 @@ namespace System { Parser.InitializeAndValidate (this, out ex); if (ex != null) return ex.Message; -#else - if (badhost) - return Locale.GetText ("Invalid URI: The hostname could not be parsed. (" + host + ")"); -#endif if ((scheme != Uri.UriSchemeMailto) && (scheme != Uri.UriSchemeNews) && @@ -1661,7 +1539,6 @@ namespace System { if (current == "..") { int resultCount = result.Count; -#if NET_2_0 // in 2.0 profile, skip leading ".." parts if (resultCount == 0) { continue; @@ -1669,16 +1546,6 @@ namespace System { result.RemoveAt (resultCount - 1); continue; -#else - // in 1.x profile, retain leading ".." parts, and only reduce - // URI is previous part is not ".." - if (resultCount > 0) { - if ((string) result[resultCount - 1] != "..") { - result.RemoveAt (resultCount - 1); - continue; - } - } -#endif } result.Add (current); @@ -1831,17 +1698,10 @@ namespace System { internal static int GetDefaultPort (string scheme) { -#if NET_2_0 UriParser parser = UriParser.GetParser (scheme); if (parser == null) return -1; return parser.DefaultPort; -#else - for (int i = 0; i < schemes.Length; i++) - if (schemes [i].scheme == scheme) - return schemes [i].defaultPort; - return -1; -#endif } private string GetOpaqueWiseSchemeDelimiter () @@ -1852,9 +1712,7 @@ namespace System { return GetSchemeDelimiter (scheme); } -#if NET_2_0 [Obsolete] -#endif protected virtual bool IsBadFileSystemCharacter (char ch) { // It does not always overlap with InvalidPathChars. @@ -1877,9 +1735,7 @@ namespace System { return false; } -#if NET_2_0 [Obsolete] -#endif protected static bool IsExcludedCharacter (char ch) { if (ch <= 32 || ch >= 127) @@ -1916,19 +1772,15 @@ namespace System { case "gopher": case "mailto": case "news": -#if NET_2_0 case "net.pipe": case "net.tcp": -#endif return true; default: return false; } } -#if NET_2_0 [Obsolete] -#endif protected virtual bool IsReservedCharacter (char ch) { if (ch == '$' || ch == '&' || ch == '+' || ch == ',' || @@ -1937,7 +1789,7 @@ namespace System { return true; return false; } -#if NET_2_0 + [NonSerialized] private UriParser parser; @@ -2226,10 +2078,5 @@ namespace System { if (!IsAbsoluteUri) throw new InvalidOperationException ("This operation is not supported for a relative URI."); } -#else - private void EnsureAbsoluteUri () - { - } -#endif } }