diff options
author | Chris Toshok <toshok@novell.com> | 2010-02-17 02:06:08 +0300 |
---|---|---|
committer | Chris Toshok <toshok@novell.com> | 2010-02-17 02:06:08 +0300 |
commit | d8ba19059dc8da2af1b5c2447e3230162afdcd34 (patch) | |
tree | e8d67599454154ae8d4bc96ae4c16275c9d3327c | |
parent | 05a51d4bfe9f974144d3fa6b95bca849347f6d48 (diff) |
merge -r151658:151801 from mono-2-6 branch
svn path=/branches/moon-2-99-0-3/mcs/; revision=151879
14 files changed, 157 insertions, 21 deletions
diff --git a/mcs/class/System.Core/System.Collections.Generic/ChangeLog b/mcs/class/System.Core/System.Collections.Generic/ChangeLog index 79d1c058803..8536cee6d17 100644 --- a/mcs/class/System.Core/System.Collections.Generic/ChangeLog +++ b/mcs/class/System.Core/System.Collections.Generic/ChangeLog @@ -1,3 +1,8 @@ +2010-02-13 Gonzalo Paniagua Javier <gonzalo@novell.com> + + * HashSet.cs: fix and test for bug #579791. Patch from Tiaan + Geldenhuys. + 2009-07-30 Raja R Harinath <harinath@hurrynot.org> * HashSet.cs (Enumerator.CheckCurrent): Inline into ... diff --git a/mcs/class/System.Core/System.Collections.Generic/HashSet.cs b/mcs/class/System.Core/System.Collections.Generic/HashSet.cs index 91c5a5c15f1..355ae247f8c 100644 --- a/mcs/class/System.Core/System.Collections.Generic/HashSet.cs +++ b/mcs/class/System.Core/System.Collections.Generic/HashSet.cs @@ -157,7 +157,7 @@ namespace System.Collections.Generic { int current = table [index] - 1; while (current != NO_SLOT) { Link link = links [current]; - if (link.HashCode == hash && comparer.Equals (item, slots [current])) + if (link.HashCode == hash && ((hash == HASH_FLAG && (item == null || null == slots [current])) ? (item == null && null == slots [current]) : comparer.Equals (item, slots [current]))) return true; current = link.Next; @@ -230,6 +230,8 @@ namespace System.Collections.Generic { int GetItemHashCode (T item) { + if (item == null) + return HASH_FLAG; return comparer.GetHashCode (item) | HASH_FLAG; } @@ -311,7 +313,7 @@ namespace System.Collections.Generic { int prev = NO_SLOT; do { Link link = links [current]; - if (link.HashCode == hashCode && comparer.Equals (slots [current], item)) + if (link.HashCode == hashCode && ((hashCode == HASH_FLAG && (item == null || null == slots [current])) ? (item == null && null == slots [current]) : comparer.Equals (slots [current], item))) break; prev = current; diff --git a/mcs/class/System.Core/Test/System.Collections.Generic/ChangeLog b/mcs/class/System.Core/Test/System.Collections.Generic/ChangeLog index c3d792cbfd9..f05e5271321 100644 --- a/mcs/class/System.Core/Test/System.Collections.Generic/ChangeLog +++ b/mcs/class/System.Core/Test/System.Collections.Generic/ChangeLog @@ -1,3 +1,8 @@ +2010-02-13 Gonzalo Paniagua Javier <gonzalo@novell.com> + + * System.Collections.Generic/HashSetTest.cs: fix and test for bug + #579791. Patch from Tiaan Geldenhuys. + 2009-08-30 Zoltan Varga <vargaz@gmail.com> * HashSetTest.cs: Fix warnings. diff --git a/mcs/class/System.Core/Test/System.Collections.Generic/HashSetTest.cs b/mcs/class/System.Core/Test/System.Collections.Generic/HashSetTest.cs index 267ee77e251..5cb8a7e7387 100644 --- a/mcs/class/System.Core/Test/System.Collections.Generic/HashSetTest.cs +++ b/mcs/class/System.Core/Test/System.Collections.Generic/HashSetTest.cs @@ -406,5 +406,48 @@ namespace MonoTests.System.Collections.Generic { Assert.IsTrue (Throws (delegate { var x = e4.Current; })); #pragma warning restore 0168 } + + [Test] + public void TestNullsWithComparerThrowingException () + { + // NOTE: We should get the same errors when using StringComparer.Ordinal on Mono 2.6.1, but the look-alike gives us more control over this test case + var set = new HashSet<string> (new StringComparerOrdinalLookAlike ()); + Assert.IsTrue (set.Add (string.Empty), "#1a"); + Assert.IsFalse (set.Contains (null), "#2a"); + Assert.IsTrue (set.Add (null), "#2b"); + Assert.IsTrue (set.Contains (null), "#2c"); + Assert.AreEqual (2, set.Count, "#3"); + Assert.IsTrue (set.Add ("a"), "#4"); + AssertContainsOnly (new string [] { string.Empty, null, "a" }, set); + Assert.IsFalse (set.Add (null), "#5"); + Assert.IsTrue (set.Add ("b"), "#6"); + Assert.IsFalse (set.Add ("b"), "#7"); + Assert.IsFalse (set.Add (string.Empty), "#8"); + Assert.IsFalse (set.Add ("a"), "#9"); + Assert.IsFalse (set.Add (null), "#10"); + Assert.IsTrue (set.Add ("c"), "#11"); + Assert.IsFalse (set.Add ("c"), "#12"); + Assert.AreEqual (5, set.Count, "#13"); + Assert.IsTrue (set.Remove (null), "#14"); + Assert.IsTrue (set.Remove ("b"), "#15"); + Assert.IsFalse (set.Remove (null), "#16"); + Assert.AreEqual (3, set.Count, "#17"); + AssertContainsOnly (new string [] { string.Empty, "a", "c" }, set); + } + + private class StringComparerOrdinalLookAlike : IEqualityComparer<string> + { + public bool Equals(string x, string y) + { + return string.CompareOrdinal(x, y) == 0; + } + + public int GetHashCode(string str) + { + if (str != null) + return str.GetHashCode(); + throw new ArgumentNullException (); // Important aspect for test (same as what StringComparer.Ordinal does, and different from GenericEqualityComparer<string>) + } + } } } diff --git a/mcs/class/System.Net/System.Net/ChangeLog b/mcs/class/System.Net/System.Net/ChangeLog index 55a828b0d93..9cf8db05cbc 100644 --- a/mcs/class/System.Net/System.Net/ChangeLog +++ b/mcs/class/System.Net/System.Net/ChangeLog @@ -1,3 +1,10 @@ +2010-02-16 Sebastien Pouliot <sebastien@ximian.com> + + * WebClient_2_1.cs: Keep a copy of 'userToken' since we need to + supply it when calling OnDownloadProgressChanged + * WebRequest_2_1.cs (SetupProgressDelegate): Simplify signature + [Backport r151800] + 2010-01-29 Rolf Bjarne Kvinge <RKvinge@novell.com> * WebClient_2_1.cs: Ensure the WriteStreamClosed event is emitted on diff --git a/mcs/class/System.Net/System.Net/WebClient_2_1.cs b/mcs/class/System.Net/System.Net/WebClient_2_1.cs index 9873b48a5e0..2c749bd7c50 100644 --- a/mcs/class/System.Net/System.Net/WebClient_2_1.cs +++ b/mcs/class/System.Net/System.Net/WebClient_2_1.cs @@ -49,6 +49,7 @@ namespace System.Net { bool allow_read_buffering = true; WebRequest request; object locker; + object user_token; public WebClient () { @@ -148,8 +149,9 @@ namespace System.Net { public event UploadStringCompletedEventHandler UploadStringCompleted; public event WriteStreamClosedEventHandler WriteStreamClosed; - WebRequest SetupRequest (Uri uri, string method) + WebRequest SetupRequest (Uri uri, string method, object userToken) { + user_token = userToken; WebRequest request = GetWebRequest (uri); request.Method = DetermineMethod (uri, method); foreach (string header in Headers.AllKeys) @@ -223,7 +225,7 @@ namespace System.Net { SetBusy (); try { - request = SetupRequest (address, "GET"); + request = SetupRequest (address, "GET", userToken); request.BeginGetResponse (new AsyncCallback (DownloadStringAsyncCallback), new CallbackData (userToken)); } catch (Exception e) { @@ -278,7 +280,7 @@ namespace System.Net { SetBusy (); try { - request = SetupRequest (address, "GET"); + request = SetupRequest (address, "GET", userToken); request.BeginGetResponse (new AsyncCallback (OpenReadAsyncCallback), new CallbackData (userToken)); } catch (Exception e) { @@ -334,7 +336,7 @@ namespace System.Net { SetBusy (); try { - request = SetupRequest (address, method); + request = SetupRequest (address, method, userToken); request.BeginGetRequestStream (new AsyncCallback (OpenWriteAsyncCallback), new CallbackData (userToken)); } catch (Exception e) { @@ -421,7 +423,7 @@ namespace System.Net { SetBusy (); try { - request = SetupRequest (address, method); + request = SetupRequest (address, method, userToken); request.BeginGetRequestStream (new AsyncCallback (UploadStringRequestAsyncCallback), new CallbackData (userToken, encoding.GetBytes (data))); } catch (Exception e) { @@ -541,8 +543,8 @@ namespace System.Net { WebRequest request = WebRequest.Create (uri); - request.SetupProgressDelegate (delegate (long read, long length, object state) { - OnDownloadProgressChanged (new DownloadProgressChangedEventArgs (read, length, state)); + request.SetupProgressDelegate (delegate (long read, long length) { + OnDownloadProgressChanged (new DownloadProgressChangedEventArgs (read, length, user_token)); }); return request; } diff --git a/mcs/class/System.Net/System.Net/WebRequest_2_1.cs b/mcs/class/System.Net/System.Net/WebRequest_2_1.cs index 9ec8fba4983..2ba83dcdc2a 100644 --- a/mcs/class/System.Net/System.Net/WebRequest_2_1.cs +++ b/mcs/class/System.Net/System.Net/WebRequest_2_1.cs @@ -132,7 +132,7 @@ namespace System.Net { return true; } - internal void SetupProgressDelegate (Action<long,long,object> progress) + internal void SetupProgressDelegate (Action<long,long> progress) { FieldInfo fi = GetType ().GetField ("progress", BindingFlags.Instance | BindingFlags.NonPublic); if (fi != null) diff --git a/mcs/class/System.Web.Services/System.Web.Services.Protocols/ChangeLog b/mcs/class/System.Web.Services/System.Web.Services.Protocols/ChangeLog index 697ac84e9c0..9976c65b6f6 100644 --- a/mcs/class/System.Web.Services/System.Web.Services.Protocols/ChangeLog +++ b/mcs/class/System.Web.Services/System.Web.Services.Protocols/ChangeLog @@ -1,3 +1,8 @@ +2010-02-15 Gonzalo Paniagua Javier <gonzalo@novell.com> + + * SoapDocumentationHandler.cs: use IndexOf() instead of LastIndexOf() + when removing the querystring from the url. + 2009-09-30 Miguel de Icaza <miguel@novell.com> * Methods.cs: Empty extensions for MonoTouch for now. diff --git a/mcs/class/System.Web.Services/System.Web.Services.Protocols/SoapDocumentationHandler.cs b/mcs/class/System.Web.Services/System.Web.Services.Protocols/SoapDocumentationHandler.cs index 73265c9f628..178161b1c95 100644 --- a/mcs/class/System.Web.Services/System.Web.Services.Protocols/SoapDocumentationHandler.cs +++ b/mcs/class/System.Web.Services/System.Web.Services.Protocols/SoapDocumentationHandler.cs @@ -59,7 +59,7 @@ namespace System.Web.Services.Protocols public SoapDocumentationHandler (Type type, HttpContext context): base (type) { _url = context.Request.Url.ToString(); - int i = _url.LastIndexOf ('?'); + int i = _url.IndexOf ('?'); if (i != -1) _url = _url.Substring (0,i); _typeStubInfo = (SoapTypeStubInfo) TypeStubManager.GetTypeStub (ServiceType, "Soap"); diff --git a/mcs/class/System/System.Net.Mail/ChangeLog b/mcs/class/System/System.Net.Mail/ChangeLog index 240f3b0dd38..1dde195c8fa 100644 --- a/mcs/class/System/System.Net.Mail/ChangeLog +++ b/mcs/class/System/System.Net.Mail/ChangeLog @@ -1,9 +1,21 @@ +2010-02-15 Gonzalo Paniagua Javier <gonzalo@novell.com> + + * SmtpClient.cs: generate correct MIME when there are text and html + linked resources. Fixes bug #579984. Patch by Ásgeir Halldórsson. + 2010-01-21 Gonzalo Paniagua Javier <gonzalo@novell.com> * SmtpClient.cs: rethrow inner exception so that AsyncCompletedEventArgs.Error gets the right value on error. Patch by Dimitar Dobrev. +2009-12-11 Miguel de Icaza <miguel@novell.com> + + * SmtpClient.cs: Add half-implemented feature, TargetName for the + SPN SMTP system. + + * SmtpClient.cs, MailMessage.cs: Add 4.0 APIs. + 2009-08-20 Sebastien Pouliot <sebastien@ximian.com> * SmtpClient.cs: Honor ServicePointManager. diff --git a/mcs/class/System/System.Net.Mail/SmtpClient.cs b/mcs/class/System/System.Net.Mail/SmtpClient.cs index 67dcc506266..9e72daf77ea 100644 --- a/mcs/class/System/System.Net.Mail/SmtpClient.cs +++ b/mcs/class/System/System.Net.Mail/SmtpClient.cs @@ -123,6 +123,12 @@ namespace System.Net.Mail { if (cfg != null) { this.host = cfg.Network.Host; this.port = cfg.Network.Port; +#if false + TargetName = cfg.Network.TargetName; + if (this.TargetName == null) + TargetName = "SMTPSVC/" + (host != null ? host : ""); +#endif + if (cfg.Network.UserName != null) { string password = String.Empty; @@ -159,6 +165,11 @@ namespace System.Net.Mail { } #endif +#if NET_4_0 + public +#endif + string TargetName { get; set; } + public ICredentialsByHost Credentials { get { return credentials; } set { @@ -669,12 +680,18 @@ namespace System.Net.Mail { SendHeader ("Priority", v); if (message.Sender != null) SendHeader ("Sender", EncodeAddress (message.Sender)); - if (message.ReplyTo != null) - SendHeader ("ReplyTo", EncodeAddress (message.ReplyTo)); - +#if false + if (message.ReplyToList.Count > 0) + SendHeader ("ReplyTo", EncodeAddresses (message.ReplyToList)); +#endif +#if NET_4_0 + foreach (string s in message.Headers.AllKeys) + SendHeader (s, ContentType.EncodeSubjectRFC2047 (message.Headers [s], message.HeadersEncoding)); +#else foreach (string s in message.Headers.AllKeys) SendHeader (s, message.Headers [s]); - +#endif + AddPriorityHeader (message); boundaryIndex = 0; @@ -881,8 +898,10 @@ try { alt_boundary = GenerateBoundary (); contentType = new ContentType ("multipart/related"); contentType.Boundary = alt_boundary; - contentType.Parameters ["type"] = "application/octet-stream"; + + contentType.Parameters ["type"] = av.ContentType.ToString (); StartSection (inner_boundary, contentType); + StartSection (alt_boundary, av.ContentType, av.TransferEncoding); } else { contentType = new ContentType (av.ContentType.ToString ()); StartSection (inner_boundary, contentType, av.TransferEncoding); @@ -930,8 +949,7 @@ try { private void SendLinkedResources (MailMessage message, LinkedResourceCollection resources, string boundary) { foreach (LinkedResource lr in resources) { - ContentType contentType = new ContentType (lr.ContentType.ToString ()); - StartSection (boundary, contentType, lr.TransferEncoding); + StartSection (boundary, lr.ContentType, lr.TransferEncoding, lr); switch (lr.TransferEncoding) { case TransferEncoding.Base64: @@ -1021,6 +1039,18 @@ try { SendData (string.Empty); } + private void StartSection(string section, ContentType sectionContentType, TransferEncoding transferEncoding, LinkedResource lr) + { + SendData (String.Format("--{0}", section)); + SendHeader ("content-type", sectionContentType.ToString ()); + SendHeader ("content-transfer-encoding", GetTransferEncodingName (transferEncoding)); + + if (lr.ContentId != null && lr.ContentId.Length > 0) + SendHeader("content-ID", "<" + lr.ContentId + ">"); + + SendData (string.Empty); + } + private void StartSection (string section, ContentType sectionContentType, TransferEncoding transferEncoding, ContentDisposition contentDisposition) { SendData (String.Format ("--{0}", section)); SendHeader ("content-type", sectionContentType.ToString ()); diff --git a/mcs/class/corlib/System.IO/ChangeLog b/mcs/class/corlib/System.IO/ChangeLog index df27667bf65..6ec3e41429b 100644 --- a/mcs/class/corlib/System.IO/ChangeLog +++ b/mcs/class/corlib/System.IO/ChangeLog @@ -1,3 +1,9 @@ +2010-02-15 Gonzalo Paniagua Javier <gonzalo@novell.com> + + * StreamWriter.cs: + * FileStream.cs: if flushing fails when disposing the stream, make + sure it is closed before throwing the exception. Fixes bug #579146. + 2010-01-31 Zoltan Varga <vargaz@gmail.com> * Directory.cs (Exists): Never throw an exception. Fixes #565152. diff --git a/mcs/class/corlib/System.IO/FileStream.cs b/mcs/class/corlib/System.IO/FileStream.cs index 3542b8c4e64..f2a6d3d8d6c 100644 --- a/mcs/class/corlib/System.IO/FileStream.cs +++ b/mcs/class/corlib/System.IO/FileStream.cs @@ -914,8 +914,13 @@ namespace System.IO protected virtual void Dispose (bool disposing) #endif { + Exception exc = null; if (handle != MonoIO.InvalidHandle) { - FlushBuffer (); + try { + FlushBuffer (); + } catch (Exception e) { + exc = e; + } if (owner) { MonoIOError error; @@ -937,6 +942,8 @@ namespace System.IO } if (disposing) GC.SuppressFinalize (this); + if (exc != null) + throw exc; } #if NET_2_0 && !NET_2_1 diff --git a/mcs/class/corlib/System.IO/StreamWriter.cs b/mcs/class/corlib/System.IO/StreamWriter.cs index 00f4586c511..3e4349c42fb 100644 --- a/mcs/class/corlib/System.IO/StreamWriter.cs +++ b/mcs/class/corlib/System.IO/StreamWriter.cs @@ -156,16 +156,28 @@ namespace System.IO { protected override void Dispose (bool disposing)
{
+ Exception exc = null;
if (!DisposedAlready && disposing && internalStream != null) {
- Flush();
+ try {
+ Flush();
+ } catch (Exception e) {
+ exc = e;
+ }
DisposedAlready = true;
- internalStream.Close ();
+ try {
+ internalStream.Close ();
+ } catch (Exception e) {
+ if (exc == null)
+ exc = e;
+ }
}
internalStream = null;
byte_buf = null;
internalEncoding = null;
decode_buf = null;
+ if (exc != null)
+ throw exc;
}
public override void Flush ()
|