diff options
Diffstat (limited to 'mcs/class/corlib')
70 files changed, 1131 insertions, 267 deletions
diff --git a/mcs/class/corlib/Mono.Security.Authenticode/AuthenticodeBase.cs b/mcs/class/corlib/Mono.Security.Authenticode/AuthenticodeBase.cs index 9e5923667b5..c2d609ecec2 100755 --- a/mcs/class/corlib/Mono.Security.Authenticode/AuthenticodeBase.cs +++ b/mcs/class/corlib/Mono.Security.Authenticode/AuthenticodeBase.cs @@ -5,10 +5,6 @@ // Sebastien Pouliot <sebastien@ximian.com> // // (C) 2003 Motus Technologies Inc. (http://www.motus.com) -// (C) 2004 Novell (http://www.novell.com) -// - -// // Copyright (C) 2004 Novell, Inc (http://www.novell.com) // // Permission is hereby granted, free of charge, to any person obtaining @@ -60,63 +56,167 @@ namespace Mono.Security.Authenticode { public const string spcIndirectDataContext = "1.3.6.1.4.1.311.2.1.4"; - internal byte[] rawData; + private byte[] fileblock; + private FileStream fs; + private int blockNo; + private int blockLength; + private int peOffset; + private int dirSecurityOffset; + private int dirSecuritySize; public AuthenticodeBase () { + fileblock = new byte [4096]; } - protected byte[] HashFile (string fileName, string hashName) + internal void Open (string filename) { - FileStream fs = new FileStream (fileName, FileMode.Open, FileAccess.Read, FileShare.Read); - byte[] file = new byte [fs.Length]; - fs.Read (file, 0, file.Length); - fs.Close (); + if (fs != null) + Close (); + fs = new FileStream (filename, FileMode.Open, FileAccess.Read, FileShare.Read); + } - // MZ - DOS header - if (BitConverterLE.ToUInt16 (file, 0) != 0x5A4D) - return null; + internal void Close () + { + if (fs != null) { + fs.Close (); + fs = null; + blockNo = 0; + } + } - // find offset of PE header - int peOffset = BitConverterLE.ToInt32 (file, 60); - if (peOffset > file.Length) - return null; + internal bool ReadFirstBlock () + { + if (fs == null) + return false; + + fs.Position = 0; + // read first block - it will include (100% sure) + // the MZ header and (99.9% sure) the PE header + blockLength = fs.Read (fileblock, 0, fileblock.Length); + blockNo = 1; + if (blockLength < 64) + return false; // invalid PE file + + // 1. Validate the MZ header informations + // 1.1. Check for magic MZ at start of header + if (BitConverterLE.ToUInt16 (fileblock, 0) != 0x5A4D) + return false; + + // 1.2. Find the offset of the PE header + peOffset = BitConverterLE.ToInt32 (fileblock, 60); + if (peOffset > fileblock.Length) { + // just in case (0.1%) this can actually happen + string msg = String.Format (Locale.GetText ( + "Header size too big (> {0} bytes)."), + fileblock.Length); + throw new NotSupportedException (msg); + } + if (peOffset > fs.Length) + return false; - // PE - NT header - if (BitConverterLE.ToUInt16 (file, peOffset) != 0x4550) - return null; + // 2. Read between DOS header and first part of PE header + // 2.1. Check for magic PE at start of header + if (BitConverterLE.ToUInt16 (fileblock, peOffset) != 0x4550) + return false; - // IMAGE_DIRECTORY_ENTRY_SECURITY - int dirSecurityOffset = BitConverterLE.ToInt32 (file, peOffset + 152); - int dirSecuritySize = BitConverterLE.ToInt32 (file, peOffset + 156); + // 2.2. Locate IMAGE_DIRECTORY_ENTRY_SECURITY (offset and size) + dirSecurityOffset = BitConverterLE.ToInt32 (fileblock, peOffset + 152); + dirSecuritySize = BitConverterLE.ToInt32 (fileblock, peOffset + 156); + + return true; + } + + internal byte[] GetSecurityEntry () + { + if (blockNo < 1) + ReadFirstBlock (); if (dirSecuritySize > 8) { - rawData = new byte [dirSecuritySize - 8]; - Buffer.BlockCopy (file, dirSecurityOffset + 8, rawData, 0, rawData.Length); -/* DEBUG - FileStream debug = new FileStream (fileName + ".sig", FileMode.Create, FileAccess.Write); - debug.Write (rawData, 0, rawData.Length); - debug.Close ();*/ + // remove header from size (not ASN.1 based) + byte[] secEntry = new byte [dirSecuritySize - 8]; + // position after header and read entry + fs.Position = dirSecurityOffset + 8; + fs.Read (secEntry, 0, secEntry.Length); + return secEntry; + } + return null; + } + + // returns null if the file isn't signed + internal byte[] GetHash (HashAlgorithm hash) + { + if (blockNo < 1) + ReadFirstBlock (); + fs.Position = blockLength; + + // hash the rest of the file + long n = fs.Length - blockLength; + // minus any authenticode signature (with 8 bytes header) + if (dirSecurityOffset > 0) { + // it is also possible that the signature block + // starts within the block in memory (small EXE) + if (dirSecurityOffset < blockLength) { + blockLength = dirSecurityOffset; + n = 0; + } + else + n -= (dirSecuritySize); } - else - rawData = null; - HashAlgorithm hash = HashAlgorithm.Create (hashName); - // 0 to 215 (216) then skip 4 (checksum) + // Authenticode(r) gymnastics + // Hash from (generally) 0 to 215 (216 bytes) int pe = peOffset + 88; - hash.TransformBlock (file, 0, pe, file, 0); + hash.TransformBlock (fileblock, 0, pe, fileblock, 0); + // then skip 4 for checksum pe += 4; - // 220 to 279 (60) then skip 8 (IMAGE_DIRECTORY_ENTRY_SECURITY) - hash.TransformBlock (file, pe, 60, file, pe); + // Continue hashing from (generally) 220 to 279 (60 bytes) + hash.TransformBlock (fileblock, pe, 60, fileblock, pe); + // then skip 8 bytes for IMAGE_DIRECTORY_ENTRY_SECURITY pe += 68; - // 288 to end of file - int n = file.Length - pe; - // minus any authenticode signature (with 8 bytes header) - if (dirSecurityOffset != 0) - n -= (dirSecuritySize); - hash.TransformFinalBlock (file, pe, n); + // everything is present so start the hashing + if (n == 0) { + // hash the (only) block + hash.TransformFinalBlock (fileblock, pe, blockLength - pe); + } + else { + // hash the last part of the first (already in memory) block + hash.TransformBlock (fileblock, pe, blockLength - pe, fileblock, 0); + + // hash by blocks of 4096 bytes + long blocks = (n >> 12); + int remainder = (int)(n - (blocks << 12)); + if (remainder == 0) { + blocks--; + remainder = 4096; + } + // blocks + while (blocks-- > 0) { + fs.Read (fileblock, 0, fileblock.Length); + hash.TransformBlock (fileblock, 0, fileblock.Length, fileblock, 0); + } + // remainder + if (fs.Read (fileblock, 0, remainder) != remainder) + return null; + hash.TransformFinalBlock (fileblock, 0, remainder); + } return hash.Hash; } + + // for compatibility only + protected byte[] HashFile (string fileName, string hashName) + { + try { + Open (fileName); + HashAlgorithm hash = HashAlgorithm.Create (hashName); + byte[] result = GetHash (hash); + Close (); + return result; + } + catch { + return null; + } + } } } diff --git a/mcs/class/corlib/Mono.Security.Authenticode/AuthenticodeDeformatter.cs b/mcs/class/corlib/Mono.Security.Authenticode/AuthenticodeDeformatter.cs index 803781954f7..ea0bd30e242 100755 --- a/mcs/class/corlib/Mono.Security.Authenticode/AuthenticodeDeformatter.cs +++ b/mcs/class/corlib/Mono.Security.Authenticode/AuthenticodeDeformatter.cs @@ -2,12 +2,9 @@ // AuthenticodeDeformatter.cs: Authenticode signature validator // // Author: -// Sebastien Pouliot (spouliot@motus.com) +// Sebastien Pouliot <sebastien@ximian.com> // // (C) 2003 Motus Technologies Inc. (http://www.motus.com) -// - -// // Copyright (C) 2004 Novell, Inc (http://www.novell.com) // // Permission is hereby granted, free of charge, to any person obtaining @@ -57,6 +54,9 @@ namespace Mono.Security.Authenticode { private DateTime timestamp; private X509Certificate signingCertificate; private int reason; + private bool trustedRoot; + private bool trustedTimestampRoot; + private byte[] entry; private X509Chain signerChain; private X509Chain timestampChain; @@ -70,17 +70,20 @@ namespace Mono.Security.Authenticode { public AuthenticodeDeformatter (string fileName) : this () { - if (!CheckSignature (fileName)) { - // invalid or no signature - if (signedHash != null) - throw new COMException ("Invalid signature"); - // no exception is thrown when there's no signature in the PE file - } + FileName = fileName; } public string FileName { get { return filename; } - set { CheckSignature (value); } + set { + Reset (); + try { + CheckSignature (value); + } + catch { + reason = 1; + } + } } public byte[] Hash { @@ -101,7 +104,7 @@ namespace Mono.Security.Authenticode { public bool IsTrusted () { - if (rawData == null) { + if (entry == null) { reason = 1; return false; } @@ -111,13 +114,13 @@ namespace Mono.Security.Authenticode { return false; } - if (signerChain.Root == null) { + if ((signerChain.Root == null) || !trustedRoot) { reason = 6; return false; } if (timestamp != DateTime.MinValue) { - if (timestampChain.Root == null) { + if ((timestampChain.Root == null) || !trustedTimestampRoot) { reason = 6; return false; } @@ -139,7 +142,11 @@ namespace Mono.Security.Authenticode { } public byte[] Signature { - get { return (byte[]) rawData.Clone (); } + get { + if (entry == null) + return null; + return (byte[]) entry.Clone (); + } } public DateTime Timestamp { @@ -157,43 +164,58 @@ namespace Mono.Security.Authenticode { private bool CheckSignature (string fileName) { filename = fileName; - - // by default we try with MD5 - string hashName = "MD5"; - // compare the signature's hash with the hash of the file - hash = HashFile (filename, hashName); - - // is a signature present ? - if (rawData == null) + base.Open (filename); + entry = base.GetSecurityEntry (); + if (entry == null) { + // no signature is present + reason = 1; + base.Close (); return false; + } - PKCS7.ContentInfo ci = new PKCS7.ContentInfo (rawData); - if (ci.ContentType != PKCS7.Oid.signedData) + PKCS7.ContentInfo ci = new PKCS7.ContentInfo (entry); + if (ci.ContentType != PKCS7.Oid.signedData) { + base.Close (); return false; + } PKCS7.SignedData sd = new PKCS7.SignedData (ci.Content); - if (sd.ContentInfo.ContentType != spcIndirectDataContext) + if (sd.ContentInfo.ContentType != spcIndirectDataContext) { + base.Close (); return false; + } coll = sd.Certificates; ASN1 spc = sd.ContentInfo.Content; signedHash = spc [0][1][1]; - if (signedHash.Length == 20) { - // seems to be SHA-1, restart hashing - hashName = "SHA1"; - hash = HashFile (filename, hashName); + + HashAlgorithm ha = null; + switch (signedHash.Length) { + case 16: + ha = HashAlgorithm.Create ("MD5"); + hash = GetHash (ha); + break; + case 20: + ha = HashAlgorithm.Create ("SHA1"); + hash = GetHash (ha); + break; + default: + reason = 5; + base.Close (); + return false; } + base.Close (); if (!signedHash.CompareValue (hash)) return false; // messageDigest is a hash of spcIndirectDataContext (which includes the file hash) byte[] spcIDC = spc [0].Value; - HashAlgorithm ha = HashAlgorithm.Create (hashName); + ha.Initialize (); // re-using hash instance byte[] messageDigest = ha.ComputeHash (spcIDC); - return VerifySignature (sd, messageDigest, hashName); + return VerifySignature (sd, messageDigest, ha); } private bool CompareIssuerSerial (string issuer, byte[] serial, X509Certificate x509) @@ -213,7 +235,7 @@ namespace Mono.Security.Authenticode { } //private bool VerifySignature (ASN1 cs, byte[] calculatedMessageDigest, string hashName) - private bool VerifySignature (PKCS7.SignedData sd, byte[] calculatedMessageDigest, string hashName) + private bool VerifySignature (PKCS7.SignedData sd, byte[] calculatedMessageDigest, HashAlgorithm ha) { string contentType = null; ASN1 messageDigest = null; @@ -242,7 +264,7 @@ namespace Mono.Security.Authenticode { case "1.3.6.1.4.1.311.2.1.12": // spcSpOpusInfo (Microsoft code signing) try { - spcSpOpusInfo = System.Text.Encoding.UTF8.GetString (attr[1][0][1][0].Value); + spcSpOpusInfo = System.Text.Encoding.UTF8.GetString (attr[1][0][0][0].Value); } catch (NullReferenceException) { spcSpOpusInfo = null; @@ -262,13 +284,13 @@ namespace Mono.Security.Authenticode { return false; // verify signature - string hashOID = CryptoConfig.MapNameToOID (hashName); + string hashOID = CryptoConfig.MapNameToOID (ha.ToString ()); // change to SET OF (not [0]) as per PKCS #7 1.5 ASN1 aa = new ASN1 (0x31); foreach (ASN1 a in sd.SignerInfo.AuthenticatedAttributes) aa.Add (a); - HashAlgorithm ha = HashAlgorithm.Create (hashName); + ha.Initialize (); byte[] p7hash = ha.ComputeHash (aa.GetBytes ()); byte[] signature = sd.SignerInfo.Signature; @@ -282,10 +304,9 @@ namespace Mono.Security.Authenticode { RSACryptoServiceProvider rsa = (RSACryptoServiceProvider) x509.RSA; if (rsa.VerifyHash (p7hash, hashOID, signature)) { signerChain.LoadCertificates (coll); - if (signerChain.Build (x509)) - signingCertificate = x509; - else - return false; + trustedRoot = signerChain.Build (x509); + signingCertificate = x509; + break; } } } @@ -301,17 +322,18 @@ namespace Mono.Security.Authenticode { // countersignature (1 2 840 113549 1 9 6) // SET { PKCS7.SignerInfo cs = new PKCS7.SignerInfo (attr [1]); - return VerifyCounterSignature (cs, signature, hashName); + trustedTimestampRoot = VerifyCounterSignature (cs, signature); + break; default: // we don't support other unauthenticated attributes break; } } - return true; + return (trustedRoot && trustedTimestampRoot); } - private bool VerifyCounterSignature (PKCS7.SignerInfo cs, byte[] signature, string hashName) + private bool VerifyCounterSignature (PKCS7.SignerInfo cs, byte[] signature) { // SEQUENCE { // INTEGER 1 @@ -358,6 +380,7 @@ namespace Mono.Security.Authenticode { if (messageDigest == null) return false; // TODO: must be read from the ASN.1 structure + string hashName = null; switch (messageDigest.Length) { case 16: hashName = "MD5"; @@ -398,5 +421,20 @@ namespace Mono.Security.Authenticode { // no certificate can verify this signature! return false; } + + private void Reset () + { + filename = null; + entry = null; + hash = null; + signedHash = null; + signingCertificate = null; + reason = -1; + trustedRoot = false; + trustedTimestampRoot = false; + signerChain.Reset (); + timestampChain.Reset (); + timestamp = DateTime.MinValue; + } } } diff --git a/mcs/class/corlib/Mono.Security.Authenticode/ChangeLog b/mcs/class/corlib/Mono.Security.Authenticode/ChangeLog index 7f9398815f2..da0e586a096 100755 --- a/mcs/class/corlib/Mono.Security.Authenticode/ChangeLog +++ b/mcs/class/corlib/Mono.Security.Authenticode/ChangeLog @@ -1,3 +1,8 @@ +2004-09-07 Sebastien Pouliot <sebastien@ximian.com> + + * AuthenticodeBase.cs: Merge optimizations from HEAD. + * AuthenticodeDeformatter.cs: Merge optimizations from HEAD. + 2004-04-28 Sebastien Pouliot <sebastien@ximian.com> * AuthenticodeBase.cs: In sync with Mono.Security.dll version. diff --git a/mcs/class/corlib/Mono.Security.Cryptography/ChangeLog b/mcs/class/corlib/Mono.Security.Cryptography/ChangeLog index 4162be45b05..1515435dce9 100644 --- a/mcs/class/corlib/Mono.Security.Cryptography/ChangeLog +++ b/mcs/class/corlib/Mono.Security.Cryptography/ChangeLog @@ -1,3 +1,8 @@ +2004-09-29 Sebastien Pouliot <sebastien@ximian.com> + + * RSAManaged.cs: KeySize is now always a multiple of 8 bits. + Fix #66929. + 2004-06-23 Sebastien Pouliot <sebastien@ximian.com> * SymmetricTransform.cs: Reduce by one the number of block when diff --git a/mcs/class/corlib/Mono.Security.Cryptography/RSAManaged.cs b/mcs/class/corlib/Mono.Security.Cryptography/RSAManaged.cs index 40f58801dce..82b16f6b291 100644 --- a/mcs/class/corlib/Mono.Security.Cryptography/RSAManaged.cs +++ b/mcs/class/corlib/Mono.Security.Cryptography/RSAManaged.cs @@ -149,8 +149,12 @@ namespace Mono.Security.Cryptography { public override int KeySize { get { // in case keypair hasn't been (yet) generated - if (keypairGenerated) - return n.BitCount (); + if (keypairGenerated) { + int ks = n.BitCount (); + if ((ks & 7) != 0) + ks = ks + (8 - (ks & 7)); + return ks; + } else return base.KeySize; } diff --git a/mcs/class/corlib/Mono.Security.X509/ChangeLog b/mcs/class/corlib/Mono.Security.X509/ChangeLog index 5cfdfbd7a78..add41ab01a7 100644 --- a/mcs/class/corlib/Mono.Security.X509/ChangeLog +++ b/mcs/class/corlib/Mono.Security.X509/ChangeLog @@ -1,3 +1,7 @@ +2004-09-07 Sebastien Pouliot <sebastien@ximian.com> + + * X509Chain.cs: Merge bug fixes from HEAD. + 2004-05-27 Sebastien Pouliot <sebastien@ximian.com> * X509Certificate.cs: Rethrow original exception when parsing X.509 diff --git a/mcs/class/corlib/Mono.Security.X509/X509Chain.cs b/mcs/class/corlib/Mono.Security.X509/X509Chain.cs index 0ff5d875ac5..f8035e6c661 100755 --- a/mcs/class/corlib/Mono.Security.X509/X509Chain.cs +++ b/mcs/class/corlib/Mono.Security.X509/X509Chain.cs @@ -9,10 +9,6 @@ // Sebastien Pouliot <sebastien@ximian.com> // // (C) 2003 Motus Technologies Inc. (http://www.motus.com) -// (C) 2004 Novell (http://www.novell.com) -// - -// // Copyright (C) 2004 Novell, Inc (http://www.novell.com) // // Permission is hereby granted, free of charge, to any person obtaining @@ -136,7 +132,7 @@ namespace Mono.Security.X509 { tmp = FindCertificateParent (x); if (x != null) { _chain.Add (x); - tmp = x; // last valid + x = tmp; // last valid } } // find a trusted root @@ -193,7 +189,8 @@ namespace Mono.Security.X509 { _status = X509ChainStatusFlags.NoError; roots = null; // this force a reload certs.Clear (); - _chain.Clear (); + if (_chain != null) + _chain.Clear (); } // private stuff diff --git a/mcs/class/corlib/System.Collections/ChangeLog b/mcs/class/corlib/System.Collections/ChangeLog index 8782bc457f8..f269e646470 100644 --- a/mcs/class/corlib/System.Collections/ChangeLog +++ b/mcs/class/corlib/System.Collections/ChangeLog @@ -1,3 +1,13 @@ +2004-07-21 Geoff Norton <gnorton@customerdna.com> + + * Hashtable.cs: lock the SyncRoot when Cloning a Synchronized hashtable to avoid + a snapshot out of sync error. + +2004-07-21 Duncan Mak <duncan@ximian.com> + + * DictionaryBase.cs: Rename the dictionary field to hashtable, + which causes a serialization interop bug. Fixes bug #61721. + 2004-06-18 Ben Maurer <bmaurer@ximian.com> * IKeyComparer.cs: v2 class diff --git a/mcs/class/corlib/System.Collections/DictionaryBase.cs b/mcs/class/corlib/System.Collections/DictionaryBase.cs index af6b19f2617..9e814d1fab9 100755 --- a/mcs/class/corlib/System.Collections/DictionaryBase.cs +++ b/mcs/class/corlib/System.Collections/DictionaryBase.cs @@ -51,11 +51,11 @@ namespace System.Collections { [Serializable] public abstract class DictionaryBase : IDictionary, ICollection, IEnumerable { - Hashtable dictionary; + Hashtable hashtable; protected DictionaryBase () { - dictionary = new Hashtable (); + hashtable = new Hashtable (); } /// <summary> @@ -64,7 +64,7 @@ namespace System.Collections { public void Clear () { OnClear (); - dictionary.Clear (); + hashtable.Clear (); OnClearComplete (); } @@ -73,7 +73,7 @@ namespace System.Collections { /// </summary> public int Count { get { - return dictionary.Count; + return hashtable.Count; } } @@ -91,7 +91,7 @@ namespace System.Collections { /// </summary> protected Hashtable InnerHashtable { get { - return dictionary; + return hashtable; } } @@ -129,7 +129,7 @@ namespace System.Collections { /// </summary> private void DoCopy (Array array, int index) { - foreach (DictionaryEntry de in dictionary) + foreach (DictionaryEntry de in hashtable) array.SetValue (de, index++); } @@ -138,7 +138,7 @@ namespace System.Collections { /// </summary> public IDictionaryEnumerator GetEnumerator () { - return dictionary.GetEnumerator (); + return hashtable.GetEnumerator (); } /// <summary> @@ -311,20 +311,20 @@ namespace System.Collections { object IDictionary.this [object key] { get { - OnGet (key, dictionary[key]); - object value = dictionary [key]; + OnGet (key, hashtable [key]); + object value = hashtable [key]; return value; } set { OnValidate (key, value); - object current_value = dictionary [key]; + object current_value = hashtable [key]; OnSet (key, current_value, value); - dictionary [key] = value; + hashtable [key] = value; try { OnSetComplete (key, current_value, value); } catch { - dictionary [key] = current_value; + hashtable [key] = current_value; throw; } } @@ -332,13 +332,13 @@ namespace System.Collections { ICollection IDictionary.Keys { get { - return dictionary.Keys; + return hashtable.Keys; } } ICollection IDictionary.Values { get { - return dictionary.Values; + return hashtable.Values; } } @@ -349,11 +349,11 @@ namespace System.Collections { { OnValidate (key, value); OnInsert (key, value); - dictionary.Add (key, value); + hashtable.Add (key, value); try { OnInsertComplete (key, value); } catch { - dictionary.Remove(key); + hashtable.Remove (key); throw; } } @@ -363,10 +363,10 @@ namespace System.Collections { /// </summary> void IDictionary.Remove (object key) { - object value = dictionary [key]; + object value = hashtable [key]; OnValidate (key, value); OnRemove (key, value); - dictionary.Remove (key); + hashtable.Remove (key); OnRemoveComplete (key, value); } @@ -375,24 +375,24 @@ namespace System.Collections { /// </summary> bool IDictionary.Contains (object key) { - return dictionary.Contains (key); + return hashtable.Contains (key); } bool ICollection.IsSynchronized { get { - return dictionary.IsSynchronized; + return hashtable.IsSynchronized; } } object ICollection.SyncRoot { get { - return dictionary.SyncRoot; + return hashtable.SyncRoot; } } IEnumerator IEnumerable.GetEnumerator () { - return dictionary.GetEnumerator (); + return hashtable.GetEnumerator (); } } } diff --git a/mcs/class/corlib/System.Collections/Hashtable.cs b/mcs/class/corlib/System.Collections/Hashtable.cs index 36575c8e024..270bbef13ca 100644 --- a/mcs/class/corlib/System.Collections/Hashtable.cs +++ b/mcs/class/corlib/System.Collections/Hashtable.cs @@ -1114,8 +1114,9 @@ namespace System.Collections { public override object Clone () { - Hashtable ht = (Hashtable) host.Clone (); - return new SyncHashtable (ht); + lock(host.SyncRoot) { + return new SyncHashtable( (Hashtable) host.Clone () ); + } } } // SyncHashtable diff --git a/mcs/class/corlib/System.IO.IsolatedStorage/ChangeLog b/mcs/class/corlib/System.IO.IsolatedStorage/ChangeLog index 2b295ce72fa..c27c01f582e 100644 --- a/mcs/class/corlib/System.IO.IsolatedStorage/ChangeLog +++ b/mcs/class/corlib/System.IO.IsolatedStorage/ChangeLog @@ -1,3 +1,7 @@ +2004-07-11 Gonzalo Paniagua Javier <gonzalo@ximian.com> + + * IsolatedStorageInfo.cs: useGetFolderPath instead of getting "HOME". + 2004-06-13 Gert Driesen <drieseng@users.sourceforge.net> * IsolatedStorage.cs: really mark the storage_scope field private diff --git a/mcs/class/corlib/System.IO.IsolatedStorage/IsolatedStorageInfo.cs b/mcs/class/corlib/System.IO.IsolatedStorage/IsolatedStorageInfo.cs index a3a1ae0e8a3..d1107269a1b 100644 --- a/mcs/class/corlib/System.IO.IsolatedStorage/IsolatedStorageInfo.cs +++ b/mcs/class/corlib/System.IO.IsolatedStorage/IsolatedStorageInfo.cs @@ -37,7 +37,7 @@ namespace System.IO.IsolatedStorage { [MonoTODO("Unix Specific; generalize for Win32")] internal static string GetIsolatedStorageDirectory () { - string home = Environment.GetEnvironmentVariable ("HOME"); + string home = Environment.GetFolderPath (Environment.SpecialFolder.Personal); if (home == null) home = "~"; diff --git a/mcs/class/corlib/System.IO/ChangeLog b/mcs/class/corlib/System.IO/ChangeLog index 6818c37ad82..2a98da3be31 100644 --- a/mcs/class/corlib/System.IO/ChangeLog +++ b/mcs/class/corlib/System.IO/ChangeLog @@ -1,3 +1,51 @@ +2004-09-19 Dick Porter <dick@ximian.com> + + * UnexceptionalStreamWriter.cs: + * UnexceptionalStreamReader.cs: Wrappers around StreamWriter and + StreamReader that catch IOException. Used by System.Console so + that graphical applications dont get IO errors when their + stdin/out/err vanishes (ie when they spew debug output.) + +2004-09-04 Gonzalo Paniagua Javier <gonzalo@ximian.com> + + * Stream.cs: Close() does not call Flush(). Fixes bug #65340. + +2004-08-26 Ben Maurer <bmaurer@users.sourceforge.net> + + * StreamWriter.cs: avoid String.ToCharArray for perf. + +2004-08-18 Dick Porter <dick@ximian.com> + + * StreamWriter.cs: Flush the buffer if AutoFlush is set to true. + Fixes bug 63063, patch by Laurent Debacker (debackerl@yahoo.com). + +2004-08-13 Dick Porter <dick@ximian.com> + + * StreamWriter.cs: Allow FileShare.Read access to the underlying + FileStream, to be compatible with MS. Fixes bug 62152. + +2004-07-06 Dick Porter <dick@ximian.com> + + * MonoIO.cs: Add ERROR_INVALID_PARAMETER to the exception list. + Don't blow away the SetFileTime() error before the caller gets to + see it. Part of the bug fix to 60970. + +2004-07-05 Dick Porter <dick@ximian.com> + + * CheckPermission.cs: + * File.cs: + * FileInfo.cs: + * MonoIO.cs: + * FileStream.cs: Give the filename when throwing + FileNotFoundException. Fixes bug 61120, based on patch from + Carlos Alberto Cesario <carloscesario@gmail.com>. + +2004-07-05 Dick Porter <dick@ximian.com> + + * File.cs: File.Move() should check that the destination doesn't + already exist. Fixes bug 60915, patch based on one from Carlos + Alberto Cesario <carloscesario@gmail.com>. + 2004-06-24 Gonzalo Paniagua Javier <gonzalo@ximian.com> * Directory.cs: implemented GetLogicalDrives. diff --git a/mcs/class/corlib/System.IO/CheckPermission.cs b/mcs/class/corlib/System.IO/CheckPermission.cs index 2b31cab7e01..232b1350af4 100644 --- a/mcs/class/corlib/System.IO/CheckPermission.cs +++ b/mcs/class/corlib/System.IO/CheckPermission.cs @@ -102,7 +102,7 @@ namespace System.IO } else { - throw new FileNotFoundException(); + throw new FileNotFoundException("File not found", path); } #endif } diff --git a/mcs/class/corlib/System.IO/File.cs b/mcs/class/corlib/System.IO/File.cs index c45dea6aecb..3dcf8213759 100644 --- a/mcs/class/corlib/System.IO/File.cs +++ b/mcs/class/corlib/System.IO/File.cs @@ -70,7 +70,7 @@ namespace System.IO if (dest.Trim () == "" || dest.IndexOfAny (Path.InvalidPathChars) != -1) throw new ArgumentException ("dest"); if (!Exists (src)) - throw new FileNotFoundException (src + " does not exist"); + throw new FileNotFoundException (src + " does not exist", src); if ((GetAttributes(src) & FileAttributes.Directory) == FileAttributes.Directory){ throw new ArgumentException(src + " is a directory"); @@ -261,9 +261,11 @@ namespace System.IO if (dest.Trim () == "" || dest.IndexOfAny (Path.InvalidPathChars) != -1) throw new ArgumentException ("dest"); if (!MonoIO.Exists (src, out error)) - throw new FileNotFoundException (src + " does not exist"); + throw new FileNotFoundException (src + " does not exist", src); if (MonoIO.ExistsDirectory (dest, out error)) throw new IOException (dest + " is a directory"); + if (MonoIO.Exists (dest, out error)) + throw new IOException (dest + " already exists"); string DirName; DirName = Path.GetDirectoryName(src); diff --git a/mcs/class/corlib/System.IO/FileInfo.cs b/mcs/class/corlib/System.IO/FileInfo.cs index c98cf6feaec..3345f61dc79 100644 --- a/mcs/class/corlib/System.IO/FileInfo.cs +++ b/mcs/class/corlib/System.IO/FileInfo.cs @@ -81,7 +81,7 @@ namespace System.IO { public long Length {
get {
if (!Exists)
- throw new FileNotFoundException ("Could not find file \"" + OriginalPath + "\".");
+ throw new FileNotFoundException ("Could not find file \"" + OriginalPath + "\".", OriginalPath);
return stat.Length;
}
diff --git a/mcs/class/corlib/System.IO/FileStream.cs b/mcs/class/corlib/System.IO/FileStream.cs index 3024bf35d04..01b726a0b92 100644 --- a/mcs/class/corlib/System.IO/FileStream.cs +++ b/mcs/class/corlib/System.IO/FileStream.cs @@ -155,7 +155,7 @@ namespace System.IO if (access == FileAccess.Read && mode != FileMode.Create && mode != FileMode.OpenOrCreate && mode != FileMode.CreateNew && !File.Exists (name)) - throw new FileNotFoundException ("Could not find file \"" + name + "\"."); + throw new FileNotFoundException ("Could not find file \"" + name + "\".", name); if (mode == FileMode.CreateNew) { string dname = Path.GetDirectoryName (name); diff --git a/mcs/class/corlib/System.IO/MonoIO.cs b/mcs/class/corlib/System.IO/MonoIO.cs index 47fd104fdc3..a32e6ed5408 100644 --- a/mcs/class/corlib/System.IO/MonoIO.cs +++ b/mcs/class/corlib/System.IO/MonoIO.cs @@ -63,7 +63,8 @@ namespace System.IO // FIXME: add more exception mappings here case MonoIOError.ERROR_FILE_NOT_FOUND: message = String.Format ("Could not find file \"{0}\"", path); - return new FileNotFoundException (message); + return new FileNotFoundException (message, + path); case MonoIOError.ERROR_PATH_NOT_FOUND: message = String.Format ("Could not find a part of the path \"{0}\"", path); @@ -81,6 +82,10 @@ namespace System.IO message = String.Format ("Path is too long. Path: {0}", path); return new PathTooLongException (message); + case MonoIOError.ERROR_INVALID_PARAMETER: + message = String.Format ("Invalid parameter"); + return new IOException (message); + default: message = String.Format ("Win32 IO returned {0}. Path: {1}", error, path); return new IOException (message); @@ -304,7 +309,9 @@ namespace System.IO result = SetFileTime (handle, creation_time, last_access_time, last_write_time, out error); - Close (handle, out error); + + MonoIOError ignore_error; + Close (handle, out ignore_error); return result; } diff --git a/mcs/class/corlib/System.IO/Stream.cs b/mcs/class/corlib/System.IO/Stream.cs index 04884fb5e3d..6623da319a1 100755 --- a/mcs/class/corlib/System.IO/Stream.cs +++ b/mcs/class/corlib/System.IO/Stream.cs @@ -77,7 +77,6 @@ namespace System.IO public virtual void Close () { - Flush (); } void IDisposable.Dispose () diff --git a/mcs/class/corlib/System.IO/StreamWriter.cs b/mcs/class/corlib/System.IO/StreamWriter.cs index 4c51d0269be..1799d74e6e6 100644 --- a/mcs/class/corlib/System.IO/StreamWriter.cs +++ b/mcs/class/corlib/System.IO/StreamWriter.cs @@ -123,7 +123,7 @@ namespace System.IO { else
mode = FileMode.Create;
- internalStream = new FileStream (path, mode, FileAccess.Write);
+ internalStream = new FileStream (path, mode, FileAccess.Write, FileShare.Read);
if (append)
internalStream.Position = internalStream.Length;
@@ -137,12 +137,16 @@ namespace System.IO { get {
return iflush;
}
- set {
- if (DisposedAlready)
- throw new ObjectDisposedException("StreamWriter");
- iflush = value;
- }
- }
+ set { + if (DisposedAlready) + throw new ObjectDisposedException("StreamWriter"); + iflush = value; + + if (iflush) { + Flush (); + } + } + } public virtual Stream BaseStream {
get {
@@ -245,6 +249,28 @@ namespace System.IO { index += todo;
decode_pos += todo;
}
+ } + + void LowLevelWrite (string s) + { + int count = s.Length; + int index = 0; + while (count > 0) { + int todo = decode_buf.Length - decode_pos; + if (todo == 0) { + Decode (); + todo = decode_buf.Length; + } + if (todo > count) + todo = count; + + for (int i = 0; i < todo; i ++) + decode_buf [i + decode_pos] = s [i + index]; + + count -= todo; + index += todo; + decode_pos += todo; + } }
public override void Write (char value)
@@ -278,7 +304,8 @@ namespace System.IO { throw new ObjectDisposedException("StreamWriter");
if (value != null)
- LowLevelWrite (value.ToCharArray (), 0, value.Length);
+ LowLevelWrite (value); +
if (iflush)
Flush ();
}
diff --git a/mcs/class/corlib/System.IO/UnexceptionalStreamReader.cs b/mcs/class/corlib/System.IO/UnexceptionalStreamReader.cs new file mode 100644 index 00000000000..7c527459204 --- /dev/null +++ b/mcs/class/corlib/System.IO/UnexceptionalStreamReader.cs @@ -0,0 +1,149 @@ +// +// System.IO.UnexceptionalStreamReader.cs +// +// Authors: +// Dietmar Maurer (dietmar@ximian.com) +// Miguel de Icaza (miguel@ximian.com) +// Dick Porter (dick@ximian.com) +// +// (C) Ximian, Inc. http://www.ximian.com +// Copyright (C) 2004 Novell (http://www.novell.com) +// + +// +// Copyright (C) 2004 Novell, Inc (http://www.novell.com) +// +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// + + +// This is a wrapper around StreamReader used by System.Console that +// catches IOException so that graphical applications don't suddenly +// get IO errors when their terminal vanishes. See +// UnexceptionalStreamWriter too. + +using System; +using System.Text; +using System.Runtime.InteropServices; + +namespace System.IO { + internal class UnexceptionalStreamReader : StreamReader { + public UnexceptionalStreamReader(Stream stream) + : base (stream) + { + } + + public UnexceptionalStreamReader(Stream stream, bool detect_encoding_from_bytemarks) + : base (stream, detect_encoding_from_bytemarks) + { + } + + public UnexceptionalStreamReader(Stream stream, Encoding encoding) + : base (stream, encoding) + { + } + + public UnexceptionalStreamReader(Stream stream, Encoding encoding, bool detect_encoding_from_bytemarks) + : base (stream, encoding, detect_encoding_from_bytemarks) + { + } + + public UnexceptionalStreamReader(Stream stream, Encoding encoding, bool detect_encoding_from_bytemarks, int buffer_size) + : base (stream, encoding, detect_encoding_from_bytemarks, buffer_size) + { + } + + public UnexceptionalStreamReader(string path) + : base (path) + { + } + + public UnexceptionalStreamReader(string path, bool detect_encoding_from_bytemarks) + : base (path, detect_encoding_from_bytemarks) + { + } + + public UnexceptionalStreamReader(string path, Encoding encoding) + : base (path, encoding) + { + } + + public UnexceptionalStreamReader(string path, Encoding encoding, bool detect_encoding_from_bytemarks) + : base (path, encoding, detect_encoding_from_bytemarks) + { + } + + public UnexceptionalStreamReader(string path, Encoding encoding, bool detect_encoding_from_bytemarks, int buffer_size) + : base (path, encoding, detect_encoding_from_bytemarks, buffer_size) + { + } + + public override int Peek () + { + try { + return(base.Peek ()); + } catch (IOException) { + } + + return(-1); + } + + public override int Read () + { + try { + return(base.Read ()); + } catch (IOException) { + } + + return(-1); + } + + public override int Read ([In, Out] char[] dest_buffer, + int index, int count) + { + try { + return(base.Read (dest_buffer, index, count)); + } catch (IOException) { + } + + return(0); + } + + public override string ReadLine() + { + try { + return(base.ReadLine ()); + } catch (IOException) { + } + + return(null); + } + + public override string ReadToEnd() + { + try { + return(base.ReadToEnd ()); + } catch (IOException) { + } + + return(null); + } + } +} diff --git a/mcs/class/corlib/System.IO/UnexceptionalStreamWriter.cs b/mcs/class/corlib/System.IO/UnexceptionalStreamWriter.cs new file mode 100644 index 00000000000..db9fd5842e7 --- /dev/null +++ b/mcs/class/corlib/System.IO/UnexceptionalStreamWriter.cs @@ -0,0 +1,128 @@ +// +// System.IO.StreamWriter.cs +// +// Authors: +// Dietmar Maurer (dietmar@ximian.com) +// Paolo Molaro (lupus@ximian.com) +// Dick Porter (dick@ximian.com) +// +// (C) Ximian, Inc. http://www.ximian.com +// + +// +// Copyright (C) 2004 Novell, Inc (http://www.novell.com) +// +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// + + +// This is a wrapper around StreamWriter used by System.Console that +// catches IOException so that graphical applications don't suddenly +// get IO errors when their terminal vanishes (ie when they spew debug +// output.) See UnexceptionalStreamReader too. + +using System.Text; +using System; + +namespace System.IO { + internal class UnexceptionalStreamWriter: StreamWriter { + public UnexceptionalStreamWriter (Stream stream) + : base (stream) + { + } + + public UnexceptionalStreamWriter (Stream stream, + Encoding encoding) + : base (stream, encoding) + { + } + + public UnexceptionalStreamWriter (Stream stream, + Encoding encoding, + int bufferSize) + : base (stream, encoding, bufferSize) + { + } + + public UnexceptionalStreamWriter (string path) + : base (path) + { + } + + public UnexceptionalStreamWriter (string path, bool append) + : base (path, append) + { + } + + public UnexceptionalStreamWriter (string path, bool append, + Encoding encoding) + : base (path, append, encoding) + { + } + + public UnexceptionalStreamWriter (string path, bool append, + Encoding encoding, + int bufferSize) + : base (path, append, encoding, bufferSize) + { + } + + public override void Flush () + { + try { + base.Flush (); + } catch (IOException) { + } + } + + public override void Write (char[] buffer, int index, + int count) + { + try { + base.Write (buffer, index, count); + } catch (IOException) { + } + } + + public override void Write (char value) + { + try { + base.Write (value); + } catch (IOException) { + } + } + + public override void Write (char[] value) + { + try { + base.Write (value); + } catch (IOException) { + } + } + + public override void Write (string value) + { + try { + base.Write (value); + } catch (IOException) { + } + } + } +} diff --git a/mcs/class/corlib/System.Reflection.Emit/AssemblyBuilder.cs b/mcs/class/corlib/System.Reflection.Emit/AssemblyBuilder.cs index ebe86410469..344395be1a3 100755 --- a/mcs/class/corlib/System.Reflection.Emit/AssemblyBuilder.cs +++ b/mcs/class/corlib/System.Reflection.Emit/AssemblyBuilder.cs @@ -131,8 +131,16 @@ namespace System.Reflection.Emit { } if (n.KeyPair != null) { + // full keypair is available (for signing) sn = n.KeyPair.StrongName (); } + else { + // public key is available (for delay-signing) + byte[] pk = n.GetPublicKey (); + if ((pk != null) && (pk.Length > 0)) { + sn = new Mono.Security.StrongName (pk); + } + } basic_init (this); } diff --git a/mcs/class/corlib/System.Reflection.Emit/ChangeLog b/mcs/class/corlib/System.Reflection.Emit/ChangeLog index 5aeec6cdae4..0ecc28b55ff 100644 --- a/mcs/class/corlib/System.Reflection.Emit/ChangeLog +++ b/mcs/class/corlib/System.Reflection.Emit/ChangeLog @@ -1,3 +1,33 @@ +2004-10-06 Zoltan Varga <vargaz@freemail.hu> + + * ModuleBuilder.cs (GetTypes): Fix length of returned array. Fixes + #65931. + +2004-10-04 Zoltan Varga <vargaz@freemail.hu> + + * ModuleBuilder.cs (DefineType): Check for duplicate type names. Fixes + #65988. + +2004-09-17 Zoltan Varga <vargaz@freemail.hu> + + * CustomAttributeBuilder.cs: Applied patch from Marcus Urban (mathpup@mylinuxisp.com). Add support for defining custom marshallers by calling SetCustomAttribute. + +2004-09-09 Zoltan Varga <vargaz@freemail.hu> + + * TypeBuilder.cs: Set the table_idx of the global type to 1. + + * ModuleBuilder.cs: Save the main module of the assembly even if it is + transient. + +2004-08-13 Sebastien Pouliot <sebastien@ximian.com> + + * AssemblyBuilder.cs: (Partly) Fix delay-signing issue (#56621) when + MCS is used on the MS runtime (other part of the fix is for MCS). + +2004-07-24 Martin Baulig <martin@ximian.com> + + * TypeBuilder.cs (TypeBuilder.UnspecifiedTypeSize): Set this to 0 + and initialize it to 0 everywhere. Thu Jun 24 15:33:04 CEST 2004 Paolo Molaro <lupus@ximian.com> diff --git a/mcs/class/corlib/System.Reflection.Emit/CustomAttributeBuilder.cs b/mcs/class/corlib/System.Reflection.Emit/CustomAttributeBuilder.cs index e85e67022bc..daadb065ed3 100755 --- a/mcs/class/corlib/System.Reflection.Emit/CustomAttributeBuilder.cs +++ b/mcs/class/corlib/System.Reflection.Emit/CustomAttributeBuilder.cs @@ -198,6 +198,8 @@ namespace System.Reflection.Emit { int sizeConst = 0; int value; int utype; /* the (stupid) ctor takes a short or an enum ... */ + Type marshalTypeRef = null; + string marshalCookie = String.Empty; utype = (int)data [2]; utype |= ((int)data [3]) << 8; @@ -231,7 +233,21 @@ namespace System.Reflection.Emit { value |= ((int)data [pos++]) << 24; sizeConst = value; break; + case "MarshalTypeRef": + case "MarshalType": + len = decode_len (data, pos, out pos); + marshalTypeRef = Type.GetType (string_from_bytes (data, pos, len)); + pos += len; + break; + case "MarshalCookie": + len = decode_len (data, pos, out pos); + marshalCookie = string_from_bytes (data, pos, len); + pos += len; + break; default: + len = decode_len(data, pos, out pos); + string v = string_from_bytes (data, pos, len); + pos += len; break; } } @@ -245,6 +261,8 @@ namespace System.Reflection.Emit { return UnmanagedMarshal.DefineByValArray (sizeConst); case UnmanagedType.ByValTStr: return UnmanagedMarshal.DefineByValTStr (sizeConst); + case UnmanagedType.CustomMarshaler: + return UnmanagedMarshal.DefineCustom ( marshalTypeRef, marshalCookie, marshalTypeRef.ToString (), Guid.Empty); default: return UnmanagedMarshal.DefineUnmanagedMarshal ((UnmanagedType)utype); } diff --git a/mcs/class/corlib/System.Reflection.Emit/ModuleBuilder.cs b/mcs/class/corlib/System.Reflection.Emit/ModuleBuilder.cs index a7d4888d6d7..eabb8f84fb9 100644 --- a/mcs/class/corlib/System.Reflection.Emit/ModuleBuilder.cs +++ b/mcs/class/corlib/System.Reflection.Emit/ModuleBuilder.cs @@ -252,6 +252,8 @@ namespace System.Reflection.Emit { } private TypeBuilder DefineType (string name, TypeAttributes attr, Type parent, Type[] interfaces, PackingSize packsize, int typesize) { + if (name_cache.Contains (name)) + throw new ArgumentException ("Duplicate type name within an assembly."); TypeBuilder res = new TypeBuilder (this, name, attr, parent, interfaces, packsize, typesize, null); if (types != null) { if (types.Length == num_types) { @@ -433,7 +435,7 @@ namespace System.Reflection.Emit { if (types == null) return new TypeBuilder [0]; - int n = types.Length; + int n = num_types; TypeBuilder [] copy = new TypeBuilder [n]; Array.Copy (types, copy, n); @@ -624,9 +626,8 @@ namespace System.Reflection.Emit { internal void Save () { - if (transient) + if (transient && !is_main) return; - if ((global_type != null) && (global_type_created == null)) global_type_created = global_type.CreateType (); diff --git a/mcs/class/corlib/System.Reflection.Emit/TypeBuilder.cs b/mcs/class/corlib/System.Reflection.Emit/TypeBuilder.cs index 1f6884bdc12..edcf429d9cc 100644 --- a/mcs/class/corlib/System.Reflection.Emit/TypeBuilder.cs +++ b/mcs/class/corlib/System.Reflection.Emit/TypeBuilder.cs @@ -95,8 +95,9 @@ namespace System.Reflection.Emit { internal TypeBuilder (ModuleBuilder mb, TypeAttributes attr) { this.parent = null; this.attrs = attr; - this.class_size = -1; + this.class_size = 0; fullname = this.tname = "<Module>"; + this.table_idx = 1; this.nspace = ""; pmodule = mb; setup_internal_class (this); @@ -987,7 +988,7 @@ namespace System.Reflection.Emit { public override Type[] GetNestedTypes (BindingFlags bindingAttr) { bool match; ArrayList result = new ArrayList (); - + if (subtypes == null) return Type.EmptyTypes; foreach (TypeBuilder t in subtypes) { diff --git a/mcs/class/corlib/System.Reflection/ChangeLog b/mcs/class/corlib/System.Reflection/ChangeLog index 8a7945e688e..2ceab253beb 100644 --- a/mcs/class/corlib/System.Reflection/ChangeLog +++ b/mcs/class/corlib/System.Reflection/ChangeLog @@ -1,3 +1,12 @@ + +Sat Jul 10 15:48:34 CEST 2004 Paolo Molaro <lupus@ximian.com> + + * Modulec.s: return just name in ToString (bug #61287). + +2004-07-03 Zoltan Varga <vargaz@freemail.hu> + + * Module.cs: Initialize FilterTypeName[IgnoreCase]. Fixes #61048. + 2004-06-17 Gert Driesen <drieseng@users.sourceforge.net> * Pointer.cs: remove serializable attribute to match MS.NET diff --git a/mcs/class/corlib/System.Reflection/Module.cs b/mcs/class/corlib/System.Reflection/Module.cs index 01dc55f9be6..876967a50c0 100644 --- a/mcs/class/corlib/System.Reflection/Module.cs +++ b/mcs/class/corlib/System.Reflection/Module.cs @@ -55,6 +55,11 @@ namespace System.Reflection { const BindingFlags defaultBindingFlags = BindingFlags.Public | BindingFlags.Static | BindingFlags.Instance; + static Module () { + FilterTypeName = new TypeFilter (filter_by_type_name); + FilterTypeNameIgnoreCase = new TypeFilter (filter_by_type_name_ignore_case); + } + internal Module () { } ~Module () { @@ -206,7 +211,7 @@ namespace System.Reflection { public override string ToString () { - return "Reflection.Module: " + name; + return name; } // Mono Extension: returns the GUID of this module @@ -215,6 +220,22 @@ namespace System.Reflection { return new Guid (GetGuidInternal ()); } + private static bool filter_by_type_name (Type m, object filterCriteria) { + string s = (string)filterCriteria; + if (s.EndsWith ("*")) + return m.Name.StartsWith (s.Substring (0, s.Length - 1)); + else + return m.Name == s; + } + + private static bool filter_by_type_name_ignore_case (Type m, object filterCriteria) { + string s = (string)filterCriteria; + if (s.EndsWith ("*")) + return m.Name.ToLower ().StartsWith (s.Substring (0, s.Length - 1).ToLower ()); + else + return String.Compare (m.Name, s, true) == 0; + } + [MethodImplAttribute (MethodImplOptions.InternalCall)] private extern string GetGuidInternal (); diff --git a/mcs/class/corlib/System.Reflection/common.src b/mcs/class/corlib/System.Reflection/common.src deleted file mode 100644 index 022b6768fcc..00000000000 --- a/mcs/class/corlib/System.Reflection/common.src +++ /dev/null @@ -1,25 +0,0 @@ -Assembly.cs -AssemblyNameFlags.cs -BindingFlags.cs -CallingConventions.cs -ConstructorInfo.cs -DefaultMemberAttribute.cs -EventAttributes.cs -EventInfo.cs -FieldAttributes.cs -FieldInfo.cs -ICustomAttributeProvider.cs -MemberFilter.cs -MemberInfo.cs -MemberTypes.cs -MethodAttributes.cs -MethodBase.cs -MethodImplAttributes.cs -MethodInfo.cs -Module.cs -ParameterAttributes.cs -PropertyAttributes.cs -PropertyInfo.cs -ResourceAttributes.cs -ResourceLocation.cs -TypeAttributes.cs diff --git a/mcs/class/corlib/System.Runtime.InteropServices/ChangeLog b/mcs/class/corlib/System.Runtime.InteropServices/ChangeLog index 3eab4fba987..b74738d5faf 100644 --- a/mcs/class/corlib/System.Runtime.InteropServices/ChangeLog +++ b/mcs/class/corlib/System.Runtime.InteropServices/ChangeLog @@ -1,3 +1,9 @@ +2004-09-10 Raja R Harinath <rharinath@novell.com> + + Fix bootstrap with mcs 1.1.x. + * UnmanagedType.cs (UnmanagedType.__mono_bootstrap_NativeTypeMax): + Mark as non-compliant to CLS. + 2004-06-22 Raja R Harinath <rharinath@novell.com> Fix bootstrap with mcs 0.31. diff --git a/mcs/class/corlib/System.Runtime.InteropServices/UnmanagedType.cs b/mcs/class/corlib/System.Runtime.InteropServices/UnmanagedType.cs index 6502e1f90f6..1b5f3363c24 100755 --- a/mcs/class/corlib/System.Runtime.InteropServices/UnmanagedType.cs +++ b/mcs/class/corlib/System.Runtime.InteropServices/UnmanagedType.cs @@ -188,6 +188,7 @@ namespace System.Runtime.InteropServices { #if BOOTSTRAP_WITH_OLDLIB /// <summary> /// </summary> + [CLSCompliant(false)] __mono_bootstrap_NativeTypeMax = 80, #endif } // UnmanagedType diff --git a/mcs/class/corlib/System.Runtime.Remoting.Channels/ChangeLog b/mcs/class/corlib/System.Runtime.Remoting.Channels/ChangeLog index aafa83f9899..35352b211ea 100644 --- a/mcs/class/corlib/System.Runtime.Remoting.Channels/ChangeLog +++ b/mcs/class/corlib/System.Runtime.Remoting.Channels/ChangeLog @@ -1,3 +1,8 @@ +2004-07-02 Lluis Sanchez Gual <lluis@novell.com> + + * ChannelServices.cs: In RegisterChannel, ignore name colisions if the + channel name is "". This fixes bug #61592. + 2004-06-15 Gert Driesen <drieseng@users.sourceforge.net> * TransportHeaders.cs: added TODO for serialization diff --git a/mcs/class/corlib/System.Runtime.Remoting.Channels/ChannelServices.cs b/mcs/class/corlib/System.Runtime.Remoting.Channels/ChannelServices.cs index 98629c496f4..f2f21baf53e 100644 --- a/mcs/class/corlib/System.Runtime.Remoting.Channels/ChannelServices.cs +++ b/mcs/class/corlib/System.Runtime.Remoting.Channels/ChannelServices.cs @@ -254,7 +254,7 @@ namespace System.Runtime.Remoting.Channels { IChannel regc = (IChannel) registeredChannels[n]; - if (regc.ChannelName == chnl.ChannelName) + if (regc.ChannelName == chnl.ChannelName && chnl.ChannelName != "") throw new RemotingException ("Channel " + regc.ChannelName + " already registered"); if (regc.ChannelPriority < chnl.ChannelPriority && pos==-1) diff --git a/mcs/class/corlib/System.Runtime.Remoting.Messaging/ChangeLog b/mcs/class/corlib/System.Runtime.Remoting.Messaging/ChangeLog index 87e4e0902e6..31b0acd440c 100644 --- a/mcs/class/corlib/System.Runtime.Remoting.Messaging/ChangeLog +++ b/mcs/class/corlib/System.Runtime.Remoting.Messaging/ChangeLog @@ -1,3 +1,8 @@ +2004-07-22 Lluis Sanchez Gual <lluis@novell.com> + + * MethodCall.cs: Use RemotingServices.GetMethodBaseFromName to get the + MethodBase from the method name. This fixes bug #61774. + 2004-06-18 Sebastien Pouliot <sebastien@ximian.com> * ReturnMessage.cs: Added IMessage interface to class definition. diff --git a/mcs/class/corlib/System.Runtime.Remoting.Messaging/MethodCall.cs b/mcs/class/corlib/System.Runtime.Remoting.Messaging/MethodCall.cs index 9313d3aa0cb..47dbb9d0beb 100644 --- a/mcs/class/corlib/System.Runtime.Remoting.Messaging/MethodCall.cs +++ b/mcs/class/corlib/System.Runtime.Remoting.Messaging/MethodCall.cs @@ -288,11 +288,8 @@ namespace System.Runtime.Remoting.Messaging { Type type = RemotingServices.GetServerTypeForUri (_uri); if (type == null) throw new RemotingException ("Requested service not found. No receiver for uri " + _uri); - if (CanCastTo (_typeName, type)) - { - BindingFlags bflags = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic; - if (_methodSignature == null) _methodBase = type.GetMethod (_methodName, bflags); - else _methodBase = type.GetMethod (_methodName, bflags, null, _methodSignature, null); + if (CanCastTo (_typeName, type)) { + _methodBase = RemotingServices.GetMethodBaseFromName (type, _methodName, _methodSignature); return; } else diff --git a/mcs/class/corlib/System.Runtime.Remoting/ChangeLog b/mcs/class/corlib/System.Runtime.Remoting/ChangeLog index 1fc62be042d..14aa52173f9 100755 --- a/mcs/class/corlib/System.Runtime.Remoting/ChangeLog +++ b/mcs/class/corlib/System.Runtime.Remoting/ChangeLog @@ -1,3 +1,21 @@ +2004-07-22 Lluis Sanchez Gual <lluis@novell.com> + + * ObjRef.cs: Fixed type check in in ObjRef constructor. The requested class + must be the object class or a base class. This fixes bug #61249. + +2004-07-22 Lluis Sanchez Gual <lluis@novell.com> + + * RemotingServices.cs: Changed GetMethodBaseFromMethodMessage so its code + can be reused internally. Also fixed bug when gettting a method from an + interface. + +2004-07-02 Lluis Sanchez Gual <lluis@ximian.com> + + * RemotingConfiguration.cs: Avoid adding "id" and "type" as custom + properties of providers. This fixes bug #60934. + * ServerIdentity.cs, RemotingServices.cs: When disposing an identity, detach + the identity from the object, so it can be safely marshalled again. + 2004-06-15 Gert Driesen <drieseng@users.sourceforge.net> * RemotingTimeoutException.cs: added missing serialization ctor diff --git a/mcs/class/corlib/System.Runtime.Remoting/ObjRef.cs b/mcs/class/corlib/System.Runtime.Remoting/ObjRef.cs index 90db146c267..30234367827 100644 --- a/mcs/class/corlib/System.Runtime.Remoting/ObjRef.cs +++ b/mcs/class/corlib/System.Runtime.Remoting/ObjRef.cs @@ -92,7 +92,7 @@ namespace System.Runtime.Remoting { uri = RemotingServices.GetObjectUri(mbr); typeInfo = new TypeInfo(type); - if (!typeInfo.CanCastTo(mbr.GetType(), mbr)) + if (!type.IsAssignableFrom (mbr.GetType())) throw new RemotingException ("The server object type cannot be cast to the requested type " + type.FullName + "."); UpdateChannelInfo(); diff --git a/mcs/class/corlib/System.Runtime.Remoting/RemotingConfiguration.cs b/mcs/class/corlib/System.Runtime.Remoting/RemotingConfiguration.cs index 204bc6b4368..2cbe62dff51 100644 --- a/mcs/class/corlib/System.Runtime.Remoting/RemotingConfiguration.cs +++ b/mcs/class/corlib/System.Runtime.Remoting/RemotingConfiguration.cs @@ -721,9 +721,9 @@ namespace System.Runtime.Remoting if (at == "id" && isTemplate) prov.Id = val; - if (at == "type") + else if (at == "type") prov.Type = val; - if (at == "ref" && !isTemplate) + else if (at == "ref" && !isTemplate) prov.Ref = val; else prov.CustomProperties.Add (at, val); diff --git a/mcs/class/corlib/System.Runtime.Remoting/RemotingServices.cs b/mcs/class/corlib/System.Runtime.Remoting/RemotingServices.cs index aa694cbb3b6..6d4b810ed13 100644 --- a/mcs/class/corlib/System.Runtime.Remoting/RemotingServices.cs +++ b/mcs/class/corlib/System.Runtime.Remoting/RemotingServices.cs @@ -57,6 +57,7 @@ namespace System.Runtime.Remoting internal static string app_id; static int next_id = 1; + static readonly BindingFlags methodBindings = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic; static RemotingServices () { @@ -159,8 +160,10 @@ namespace System.Runtime.Remoting else throw new ArgumentException ("The obj parameter is a proxy."); } - else + else { identity = obj.ObjectIdentity; + obj.ObjectIdentity = null; + } if (identity == null || !identity.IsConnected) return false; @@ -288,22 +291,49 @@ namespace System.Runtime.Remoting Type type = Type.GetType (msg.TypeName); if (type == null) throw new RemotingException ("Type '" + msg.TypeName + "' not found."); - - BindingFlags bflags = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic; + + return GetMethodBaseFromName (type, msg.MethodName, (Type[]) msg.MethodSignature); + } + + internal static MethodBase GetMethodBaseFromName (Type type, string methodName, Type[] signature) + { + if (type.IsInterface) { + return FindInterfaceMethod (type, methodName, signature); + } + else { + MethodBase method = null; + if (signature == null) + method = type.GetMethod (methodName, methodBindings); + else + method = type.GetMethod (methodName, methodBindings, null, (Type[]) signature, null); + + if (method != null) + return method; + + if (signature == null) + return type.GetConstructor (methodBindings, null, Type.EmptyTypes, null); + else + return type.GetConstructor (methodBindings, null, signature, null); + } + } + + static MethodBase FindInterfaceMethod (Type type, string methodName, Type[] signature) + { + MethodBase method = null; - MethodBase method; - if (msg.MethodSignature == null) - method = type.GetMethod (msg.MethodName, bflags); + if (signature == null) + method = type.GetMethod (methodName, methodBindings); else - method = type.GetMethod (msg.MethodName, bflags, null, (Type[]) msg.MethodSignature, null); + method = type.GetMethod (methodName, methodBindings, null, signature, null); + + if (method != null) return method; - if (method != null) - return method; + foreach (Type t in type.GetInterfaces ()) { + method = FindInterfaceMethod (t, methodName, signature); + if (method != null) return method; + } - if (msg.MethodSignature == null) - return type.GetConstructor (bflags, null, Type.EmptyTypes, null); - else - return type.GetConstructor (bflags, null, (Type[]) msg.MethodSignature, null); + return null; } public static void GetObjectData(object obj, SerializationInfo info, StreamingContext context) diff --git a/mcs/class/corlib/System.Runtime.Remoting/ServerIdentity.cs b/mcs/class/corlib/System.Runtime.Remoting/ServerIdentity.cs index f5ed96a066b..72c025121d0 100644 --- a/mcs/class/corlib/System.Runtime.Remoting/ServerIdentity.cs +++ b/mcs/class/corlib/System.Runtime.Remoting/ServerIdentity.cs @@ -136,7 +136,13 @@ namespace System.Runtime.Remoting protected void DisposeServerObject() { - _serverObject = null; + // Detach identity from server object to avoid problems if the + // object is marshalled again. + + if (_serverObject != null) { + _serverObject.ObjectIdentity = null; + _serverObject = null; + } } } diff --git a/mcs/class/corlib/System.Security.Cryptography.X509Certificates/ChangeLog b/mcs/class/corlib/System.Security.Cryptography.X509Certificates/ChangeLog index b5a036af423..86be09eef0a 100644 --- a/mcs/class/corlib/System.Security.Cryptography.X509Certificates/ChangeLog +++ b/mcs/class/corlib/System.Security.Cryptography.X509Certificates/ChangeLog @@ -1,3 +1,7 @@ +2004-09-07 Sebastien Pouliot <sebastien@ximian.com> + + * X509Certificate.cs: Merge changes from HEAD. + 2003-12-15 Sebastien Pouliot <spouliot@videotron.ca> * X509Certificate.cs: Removed old (commented) Authenticode stuff. diff --git a/mcs/class/corlib/System.Security.Cryptography.X509Certificates/X509Certificate.cs b/mcs/class/corlib/System.Security.Cryptography.X509Certificates/X509Certificate.cs index af5722f601d..5d3f9dd8177 100644 --- a/mcs/class/corlib/System.Security.Cryptography.X509Certificates/X509Certificate.cs +++ b/mcs/class/corlib/System.Security.Cryptography.X509Certificates/X509Certificate.cs @@ -116,15 +116,26 @@ namespace System.Security.Cryptography.X509Certificates { [MonoTODO ("Incomplete - minimal validation in this version")] public static X509Certificate CreateFromSignedFile (string filename) { - AuthenticodeDeformatter a = new AuthenticodeDeformatter (filename); - if (a.SigningCertificate != null) { - return new X509Certificate (a.SigningCertificate.RawData); - } - else { + try { + AuthenticodeDeformatter a = new AuthenticodeDeformatter (filename); + if (a.SigningCertificate != null) { + if (a.Reason != 0) { + string msg = String.Format (Locale.GetText ( + "Invalid digital signature on {0}, reason #{1}."), + filename, a.Reason); + throw new COMException (msg); + } + return new X509Certificate (a.SigningCertificate.RawData); + } + // if no signature is present return an empty certificate byte[] cert = null; // must not confuse compiler about null ;) return new X509Certificate (cert); } + catch (Exception e) { + string msg = String.Format (Locale.GetText ("Couldn't extract digital signature from {0}."), filename); + throw new COMException (msg, e); + } } // constructors @@ -410,4 +421,4 @@ namespace System.Security.Cryptography.X509Certificates { } #endif } -}
\ No newline at end of file +} diff --git a/mcs/class/corlib/System.Security.Cryptography/ChangeLog b/mcs/class/corlib/System.Security.Cryptography/ChangeLog index 59642bc66bc..f087b452504 100644 --- a/mcs/class/corlib/System.Security.Cryptography/ChangeLog +++ b/mcs/class/corlib/System.Security.Cryptography/ChangeLog @@ -1,3 +1,9 @@ +2004-07-15 Sebastien Pouliot <sebastien@ximian.com> + + * DES.cs: Fixed FeedbackSizeValue to 8. + * RC2.cs: Fixed FeedbackSizeValue to 8. + * TripleDES.cs: Fixed FeedbackSizeValue to 8. + 2004-06-23 Sebastien Pouliot <sebastien@ximian.com> * CryptoStream.cs: Removed the block reduction. This seems to be done diff --git a/mcs/class/corlib/System.Security.Cryptography/DES.cs b/mcs/class/corlib/System.Security.Cryptography/DES.cs index a775477b436..cb678113d6c 100644 --- a/mcs/class/corlib/System.Security.Cryptography/DES.cs +++ b/mcs/class/corlib/System.Security.Cryptography/DES.cs @@ -6,10 +6,6 @@ // Sebastien Pouliot <sebastien@ximian.com> // // Portions (C) 2002 Motus Technologies Inc. (http://www.motus.com) -// (C) 2004 Novell (http://www.novell.com) -// - -// // Copyright (C) 2004 Novell, Inc (http://www.novell.com) // // Permission is hereby granted, free of charge, to any person obtaining @@ -50,7 +46,7 @@ public abstract class DES : SymmetricAlgorithm { { KeySizeValue = 64; BlockSizeValue = 64; - FeedbackSizeValue = 64; + FeedbackSizeValue = 8; LegalKeySizesValue = new KeySizes[1]; LegalKeySizesValue[0] = new KeySizes(64, 64, 0); diff --git a/mcs/class/corlib/System.Security.Cryptography/RC2.cs b/mcs/class/corlib/System.Security.Cryptography/RC2.cs index 58566078d5f..70119078722 100644 --- a/mcs/class/corlib/System.Security.Cryptography/RC2.cs +++ b/mcs/class/corlib/System.Security.Cryptography/RC2.cs @@ -5,10 +5,6 @@ // Andrew Birkett (andy@nobugs.org) // Sebastien Pouliot (sebastien@ximian.com) // -// (C) 2004 Novell (http://www.novell.com) -// - -// // Copyright (C) 2004 Novell, Inc (http://www.novell.com) // // Permission is hereby granted, free of charge, to any person obtaining @@ -77,7 +73,7 @@ namespace System.Security.Cryptography { { KeySizeValue = 128; BlockSizeValue = 64; - FeedbackSizeValue = 64; + FeedbackSizeValue = 8; // The RFC allows keys of 1 to 128 bytes, but MS impl only supports // 40 to 128 bits, sigh. diff --git a/mcs/class/corlib/System.Security.Cryptography/TripleDES.cs b/mcs/class/corlib/System.Security.Cryptography/TripleDES.cs index 54969879d16..add883b6ce8 100644 --- a/mcs/class/corlib/System.Security.Cryptography/TripleDES.cs +++ b/mcs/class/corlib/System.Security.Cryptography/TripleDES.cs @@ -5,10 +5,6 @@ // Sebastien Pouliot <sebastien@ximian.com> // // (C) 2002, 2003 Motus Technologies Inc. (http://www.motus.com) -// (C) 2004 Novell (http://www.novell.com) -// - -// // Copyright (C) 2004 Novell, Inc (http://www.novell.com) // // Permission is hereby granted, free of charge, to any person obtaining @@ -51,7 +47,7 @@ public abstract class TripleDES : SymmetricAlgorithm { // from SymmetricAlgorithm KeySizeValue = 192; BlockSizeValue = 64; - FeedbackSizeValue = 64; + FeedbackSizeValue = 8; LegalKeySizesValue = new KeySizes [1]; LegalKeySizesValue [0] = new KeySizes (128, 192, 64); diff --git a/mcs/class/corlib/System.Security.Permissions/ChangeLog b/mcs/class/corlib/System.Security.Permissions/ChangeLog index 219a8c199ea..63e95738285 100644 --- a/mcs/class/corlib/System.Security.Permissions/ChangeLog +++ b/mcs/class/corlib/System.Security.Permissions/ChangeLog @@ -1,3 +1,9 @@ +2004-10-05 Sebastien Pouliot <sebastien@ximian.com> + + * PrincipalPermission.cs: Fixed bug where a change to a permission + (e.g. Copy, Union) could affect multiple instances. Fixed FromXml + to clear existing entries. + 2004-06-10 Gert Driesen <drieseng@users.sourceforge.net> * StrongNameIdentityPermission.cs: removed extra useless finalizer diff --git a/mcs/class/corlib/System.Security.Permissions/PrincipalPermission.cs b/mcs/class/corlib/System.Security.Permissions/PrincipalPermission.cs index d1f23c091a5..17235490015 100644 --- a/mcs/class/corlib/System.Security.Permissions/PrincipalPermission.cs +++ b/mcs/class/corlib/System.Security.Permissions/PrincipalPermission.cs @@ -98,7 +98,7 @@ namespace System.Security.Permissions { internal PrincipalPermission (ArrayList principals) { - this.principals = principals; + this.principals = (ArrayList) principals.Clone (); } // Properties @@ -147,6 +147,7 @@ namespace System.Security.Permissions { if ((esd.Attributes ["version"] as string) != "1") throw new ArgumentException ("wrong version"); + principals.Clear (); // Children is null, not empty, when no child is present if (esd.Children != null) { foreach (SecurityElement se in esd.Children) { @@ -273,7 +274,7 @@ namespace System.Security.Permissions { PrincipalPermission union = new PrincipalPermission (principals); foreach (PrincipalInfo pi in o.principals) - principals.Add (pi); + union.principals.Add (pi); return union; } @@ -284,4 +285,4 @@ namespace System.Security.Permissions { return 8; } } -}
\ No newline at end of file +} diff --git a/mcs/class/corlib/System.Threading/ChangeLog b/mcs/class/corlib/System.Threading/ChangeLog index ba1a9664f98..d441965fb9b 100644 --- a/mcs/class/corlib/System.Threading/ChangeLog +++ b/mcs/class/corlib/System.Threading/ChangeLog @@ -1,3 +1,20 @@ +2004-09-16 Gonzalo Paniagua Javier <gonzalo@ximian.com> + + * Timer.cs: don't invoke the callback twice when the timer changes. + Fixes bug #66116. + +2004-08-04 Gonzalo Paniagua Javier <gonzalo@ximian.com> + + * Timer.cs: don't invoke the callback if the period changes before the + due time. Fixes bug #62421. + +2004-07-15 Dick Porter <dick@ximian.com> + + * Thread.cs: Hold a lock in GetNamedDataSlot. Fixes bug 61582, + based on patch by Sébastien Robitaille + (sebastien.robitaille@croesus.com). Also fix instances of + lock(typeof(Thread)) to lock a private object instead. + 2004-06-24 Dick Porter <dick@ximian.com> * Mutex.cs: Implement the createdNew parameter diff --git a/mcs/class/corlib/System.Threading/Thread.cs b/mcs/class/corlib/System.Threading/Thread.cs index 66826e12d40..911fb1dbe12 100755 --- a/mcs/class/corlib/System.Threading/Thread.cs +++ b/mcs/class/corlib/System.Threading/Thread.cs @@ -157,9 +157,10 @@ namespace System.Threading // Stores a hash keyed by strings of LocalDataStoreSlot objects static Hashtable datastorehash; - + private static object datastore_lock = new object (); + private static void InitDataStoreHash () { - lock (typeof (Thread)) { + lock (datastore_lock) { if (datastorehash == null) { datastorehash = Hashtable.Synchronized(new Hashtable()); } @@ -167,7 +168,7 @@ namespace System.Threading } public static LocalDataStoreSlot AllocateNamedDataSlot(string name) { - lock (typeof (Thread)) { + lock (datastore_lock) { if (datastorehash == null) InitDataStoreHash (); LocalDataStoreSlot slot = (LocalDataStoreSlot)datastorehash[name]; @@ -186,7 +187,7 @@ namespace System.Threading } public static void FreeNamedDataSlot(string name) { - lock (typeof (Thread)) { + lock (datastore_lock) { if (datastorehash == null) InitDataStoreHash (); LocalDataStoreSlot slot=(LocalDataStoreSlot)datastorehash[name]; @@ -210,15 +211,17 @@ namespace System.Threading public extern static int GetDomainID(); public static LocalDataStoreSlot GetNamedDataSlot(string name) { - if (datastorehash == null) - InitDataStoreHash (); - LocalDataStoreSlot slot=(LocalDataStoreSlot)datastorehash[name]; + lock (datastore_lock) { + if (datastorehash == null) + InitDataStoreHash (); + LocalDataStoreSlot slot=(LocalDataStoreSlot)datastorehash[name]; - if(slot==null) { - slot=AllocateNamedDataSlot(name); - } + if(slot==null) { + slot=AllocateNamedDataSlot(name); + } - return(slot); + return(slot); + } } [MethodImplAttribute(MethodImplOptions.InternalCall)] diff --git a/mcs/class/corlib/System.Threading/Timer.cs b/mcs/class/corlib/System.Threading/Timer.cs index 164c60ef2ca..1bba6fa581e 100755 --- a/mcs/class/corlib/System.Threading/Timer.cs +++ b/mcs/class/corlib/System.Threading/Timer.cs @@ -128,6 +128,9 @@ namespace System.Threading wait.Reset (); signaled = wait.WaitOne (period, false); + if (aborted) + break; + if (!signaled) { callback (state); } else if (!WaitForDueTime ()) { @@ -195,10 +198,11 @@ namespace System.Threading if (runner == null) return false; - + + start_event.Reset (); + runner.Abort (); runner.DueTime = dueTime; runner.Period = period; - runner.Abort (); start_event.Set (); return true; } diff --git a/mcs/class/corlib/System/Activator.cs b/mcs/class/corlib/System/Activator.cs index 4727251d9e6..6cb4c24b262 100644 --- a/mcs/class/corlib/System/Activator.cs +++ b/mcs/class/corlib/System/Activator.cs @@ -168,9 +168,10 @@ namespace System length = args.Length; Type [] atypes = new Type [length]; - for (int i = 0; i < length; ++i) { - atypes [i] = args [i].GetType (); - } + for (int i = 0; i < length; ++i) + if (args [i] != null) + atypes [i] = args [i].GetType (); + ConstructorInfo ctor = type.GetConstructor (atypes); if (ctor == null) { if (type.IsValueType && atypes.Length == 0) @@ -213,9 +214,10 @@ namespace System length = args.Length; Type[] atypes = new Type [length]; - for (int i = 0; i < length; ++i) { - atypes [i] = args [i].GetType (); - } + for (int i = 0; i < length; ++i) + if (args [i] != null) + atypes [i] = args [i].GetType (); + ConstructorInfo ctor = type.GetConstructor (bindingAttr, binder, atypes, null); if (ctor == null) { // Not sure about this diff --git a/mcs/class/corlib/System/AppDomain.cs b/mcs/class/corlib/System/AppDomain.cs index 06ab7351c93..e987f1a7b4f 100755 --- a/mcs/class/corlib/System/AppDomain.cs +++ b/mcs/class/corlib/System/AppDomain.cs @@ -63,10 +63,10 @@ namespace System static string _process_guid; [ThreadStatic] - Hashtable type_resolve_in_progress; + static Hashtable type_resolve_in_progress; [ThreadStatic] - Hashtable assembly_resolve_in_progress; + static Hashtable assembly_resolve_in_progress; // Evidence evidence; diff --git a/mcs/class/corlib/System/ChangeLog b/mcs/class/corlib/System/ChangeLog index b345b93f069..f9b59c29d4f 100644 --- a/mcs/class/corlib/System/ChangeLog +++ b/mcs/class/corlib/System/ChangeLog @@ -1,3 +1,68 @@ +2004-10-08 Zoltan Varga <vargaz@freemail.hu> + + * Convert.cs (ToType): Throw an exception when converting null to a + valuetype. Fixes #67780. + +2004-10-08 Atsushi Enomoto <atsushi@ximian.com> + + * DateTime.cs : Removed incorrectly injected HEAD fix. + +2004-10-08 Atsushi Enomoto <atsushi@ximian.com> + + * DateTime.cs : When it it not exact parse, 'Z' is allowed as a suffix + of m/s/t/z. This fixes bug 66723. + +2004-10-04 Zoltan Varga <vargaz@freemail.hu> + + * AppDomain.cs: Make ThreadStatic variables static. Fixes #56614. + +2004-09-30 Geoff Norton <gnorton@customerdna.com> + + * Convert.cs: ConvertToBase* was not endian aware. Implemented EndianSwap + and swapping of all values before going into the BitConverter so that values + are returned with proper endianess. + +2004-09-23 Martin Garton <martin@wrasse.demon.co.uk> + + * Convert.cs: ToType was returning unconverted object when it should + fail with an ArgumentException. + +2004-09-19 Dick Porter <dick@ximian.com> + + * Console.cs: Use the internal wrappers for StreamReader and + StreamWriter that catch IOException. + +2004-08-29 Ben Maurer <bmaurer@users.sourceforge.net> + + * Activator.cs (CreateInstance): If an argument is null, + do not call GetType () on it. #63852 + +2004-09-05 Gonzalo Paniagua Javier <gonzalo@ximian.com> + + * Environment.cs: (ExpandEnvironmentVariables) don't nullify the case + insensitive environment variables hashtable once we create it. + +2004-08-19 Atsushi Enomoto <atsushi@ximian.com> + + * DateTime.cs : When hour format is "hh", MS.NET (maybe incorrectly) + allows 12, that should not be accepted (13 is rejected) and + interpreted as 0. This fixes bug 63376. + +2004-08-17 Sebastien Pouliot <sebastien@ximian.com> + + * Version.cs: Fixed Clone so we can use it on versions with only + major/minor or major/minor/build. + +2004-07-07 Geoff Norton <gnorton@customerdna.com> + + * Monotype.cs: Patch for bug #58844. Dont throw exceptions right away; + pass through all the possibly BindingInfo's and keep a bool value as to the type + of exception we might need to throw; + +2004-07-07 Geoff Norton <gnorton@customerdna.com> + + * Patch to fix bug #58973 + 2004-06-25 Ben Maurer <bmaurer@ximian.com> * Environment.cs: GetFolderPath has new behavior. r=miguel diff --git a/mcs/class/corlib/System/Console.cs b/mcs/class/corlib/System/Console.cs index 8a0830a7328..f71b4069c43 100644 --- a/mcs/class/corlib/System/Console.cs +++ b/mcs/class/corlib/System/Console.cs @@ -63,15 +63,15 @@ namespace System encoding = Encoding.Default; } - stderr = new StreamWriter (OpenStandardError (0), encoding); + stderr = new UnexceptionalStreamWriter (OpenStandardError (0), encoding); ((StreamWriter)stderr).AutoFlush = true; stderr = TextWriter.Synchronized (stderr, true); - stdout = new StreamWriter (OpenStandardOutput (0), encoding); + stdout = new UnexceptionalStreamWriter (OpenStandardOutput (0), encoding); ((StreamWriter)stdout).AutoFlush = true; stdout = TextWriter.Synchronized (stdout, true); - stdin = new StreamReader (OpenStandardInput (0), encoding); + stdin = new UnexceptionalStreamReader (OpenStandardInput (0), encoding); stdin = TextReader.Synchronized (stdin); } diff --git a/mcs/class/corlib/System/Convert.cs b/mcs/class/corlib/System/Convert.cs index f63481831c5..5e15d578704 100644 --- a/mcs/class/corlib/System/Convert.cs +++ b/mcs/class/corlib/System/Convert.cs @@ -2559,8 +2559,18 @@ namespace System { return (long) result;
}
+ private static void EndianSwap (ref byte[] value) + { + byte[] buf = new byte[value.Length]; + for (int i = 0; i < value.Length; i++) + buf[i] = value[value.Length-1-i]; + value = buf; + } + private static string ConvertToBase2 (byte[] value) { + if (!BitConverter.IsLittleEndian) + EndianSwap (ref value); StringBuilder sb = new StringBuilder (); for (int i = value.Length - 1; i >= 0; i--) { byte b = value [i]; @@ -2580,6 +2590,8 @@ namespace System { private static string ConvertToBase8 (byte[] value)
{ + if (!BitConverter.IsLittleEndian) + EndianSwap (ref value); ulong l = 0; switch (value.Length) { case 1: @@ -2612,6 +2624,8 @@ namespace System { private static string ConvertToBase16 (byte[] value) { + if (!BitConverter.IsLittleEndian) + EndianSwap (ref value); StringBuilder sb = new StringBuilder (); for (int i = value.Length - 1; i >= 0; i--) { char high = (char)((value[i] >> 4) & 0x0f); @@ -2672,8 +2686,12 @@ namespace System { internal static object ToType (object value, Type conversionType,
IFormatProvider provider)
{
- if (value == null)
- return null;
+ if (value == null) { + if ((conversionType != null) && conversionType.IsValueType) + throw new InvalidCastException ("Null object can not be converted to a value type."); + else + return null; + } if (conversionType == null)
throw new InvalidCastException ("Cannot cast to destination type.");
@@ -2739,12 +2757,7 @@ namespace System { else if (conversionType == conversionTable[18]) // 18 TypeCode.String
return (object) convertValue.ToString (provider);
else {
- try {
- return (object) convertValue;
- }
- catch {
- throw new ArgumentException (Locale.GetText ("Unknown target conversion type"));
- }
+ throw new ArgumentException (Locale.GetText ("Unknown target conversion type"));
}
} else
// Not in the conversion table
diff --git a/mcs/class/corlib/System/DateTime.cs b/mcs/class/corlib/System/DateTime.cs index cb90d719a98..188d0d27bd4 100644 --- a/mcs/class/corlib/System/DateTime.cs +++ b/mcs/class/corlib/System/DateTime.cs @@ -1007,8 +1007,10 @@ namespace System num = 1; } - if (hour >= 12) + if (hour > 12) return false; + if (hour == 12) + hour = 0; break; case 'H': @@ -1188,6 +1190,22 @@ namespace System s = s.Substring (num_parsed); + if (!exact) { + switch (chars [pos]) { + case 'm': + case 's': + case 'f': + case 'z': + if (s.Length > 0 && s [0] == 'Z' + && (pos + 1 == chars.Length + || chars [pos + 1] != 'Z')) { + useutc = true; + s = s.Substring (1); + } + break; + } + } + pos = pos + num + 1; num = 0; } diff --git a/mcs/class/corlib/System/Double.cs b/mcs/class/corlib/System/Double.cs index a52c482792a..47f0d406531 100644 --- a/mcs/class/corlib/System/Double.cs +++ b/mcs/class/corlib/System/Double.cs @@ -207,6 +207,10 @@ namespace System { for (; sidx < len; sidx++){ c = s [sidx]; + if (c == '\0') { + sidx = len; + continue; + } switch (state){ case State_AllowSign: if ((style & NumberStyles.AllowLeadingSign) != 0){ diff --git a/mcs/class/corlib/System/Environment.cs b/mcs/class/corlib/System/Environment.cs index bf213ff4cb7..c21030f8b35 100644 --- a/mcs/class/corlib/System/Environment.cs +++ b/mcs/class/corlib/System/Environment.cs @@ -290,8 +290,8 @@ namespace System PlatformID platform = Platform; StringBuilder result = new StringBuilder (); result.Append (name, 0, off1); + Hashtable tbl = null; do { - Hashtable tbl = null; string var = name.Substring (off1 + 1, off2 - off1 - 1); string value = GetEnvironmentVariable (var); if (value == null && (int) platform != 128) { diff --git a/mcs/class/corlib/System/MonoType.cs b/mcs/class/corlib/System/MonoType.cs index a04eeb93877..395332cf459 100644 --- a/mcs/class/corlib/System/MonoType.cs +++ b/mcs/class/corlib/System/MonoType.cs @@ -340,22 +340,26 @@ namespace System name = attr.MemberName; } bool ignoreCase = (invokeAttr & BindingFlags.IgnoreCase) != 0; + bool throwMissingMethodException = false; + bool throwMissingFieldException = false; if ((invokeAttr & BindingFlags.InvokeMethod) != 0) { MethodInfo[] methods = GetMethodsByName (name, invokeAttr, ignoreCase, this); object state = null; MethodBase m = binder.BindToMethod (invokeAttr, methods, ref args, modifiers, culture, namedParameters, out state); - if (m == null) - throw new MissingMethodException (); - object result = m.Invoke (target, invokeAttr, binder, args, culture); - binder.ReorderArgumentArray (ref args, state); - return result; + if (m == null) { + throwMissingMethodException = true; + } else { + object result = m.Invoke (target, invokeAttr, binder, args, culture); + binder.ReorderArgumentArray (ref args, state); + return result; + } } if ((invokeAttr & BindingFlags.GetField) != 0) { FieldInfo f = GetField (name, invokeAttr); if (f != null) { return f.GetValue (target); } else if ((invokeAttr & BindingFlags.GetProperty) == 0) { - throw new MissingFieldException (); + throwMissingFieldException = true; } /* try GetProperty */ } else if ((invokeAttr & BindingFlags.SetField) != 0) { @@ -364,7 +368,7 @@ namespace System f.SetValue (target, args [0]); return null; } else if ((invokeAttr & BindingFlags.SetProperty) == 0) { - throw new MissingFieldException (); + throwMissingFieldException = true; } /* try SetProperty */ } @@ -384,11 +388,13 @@ namespace System smethods [count++] = mb; } MethodBase m = binder.BindToMethod (invokeAttr, smethods, ref args, modifiers, culture, namedParameters, out state); - if (m == null) - throw new MissingFieldException (); - object result = m.Invoke (target, invokeAttr, binder, args, culture); - binder.ReorderArgumentArray (ref args, state); - return result; + if (m == null) { + throwMissingFieldException = true; + } else { + object result = m.Invoke (target, invokeAttr, binder, args, culture); + binder.ReorderArgumentArray (ref args, state); + return result; + } } else if ((invokeAttr & BindingFlags.SetProperty) != 0) { PropertyInfo[] properties = GetPropertiesByName (name, invokeAttr, ignoreCase, this); object state = null; @@ -405,12 +411,19 @@ namespace System smethods [count++] = mb; } MethodBase m = binder.BindToMethod (invokeAttr, smethods, ref args, modifiers, culture, namedParameters, out state); - if (m == null) - throw new MissingFieldException (); - object result = m.Invoke (target, invokeAttr, binder, args, culture); - binder.ReorderArgumentArray (ref args, state); - return result; + if (m == null) { + throwMissingFieldException = true; + } else { + object result = m.Invoke (target, invokeAttr, binder, args, culture); + binder.ReorderArgumentArray (ref args, state); + return result; + } } + if (throwMissingMethodException) + throw new MissingMethodException(); + if (throwMissingFieldException) + throw new MissingFieldException(); + return null; } diff --git a/mcs/class/corlib/System/Random.cs b/mcs/class/corlib/System/Random.cs index 3bc3e23498b..e730865d76e 100644 --- a/mcs/class/corlib/System/Random.cs +++ b/mcs/class/corlib/System/Random.cs @@ -74,7 +74,7 @@ namespace System } } inext = 0; - inextp = 21; + inextp = 31; } protected virtual double Sample () diff --git a/mcs/class/corlib/System/Version.cs b/mcs/class/corlib/System/Version.cs index ea64cde7080..adc86fa5568 100644 --- a/mcs/class/corlib/System/Version.cs +++ b/mcs/class/corlib/System/Version.cs @@ -152,7 +152,12 @@ namespace System public object Clone () { - return new Version (_Major, _Minor, _Build, _Revision); + if (_Build == -1) + return new Version (_Major, _Minor); + else if (_Revision == -1) + return new Version (_Major, _Minor, _Build); + else + return new Version (_Major, _Minor, _Build, _Revision); } public int CompareTo (object version) diff --git a/mcs/class/corlib/Test/System.Collections/ChangeLog b/mcs/class/corlib/Test/System.Collections/ChangeLog index 5e7760f0fad..885360ab080 100644 --- a/mcs/class/corlib/Test/System.Collections/ChangeLog +++ b/mcs/class/corlib/Test/System.Collections/ChangeLog @@ -1,3 +1,7 @@ +2004-07-28 Dick Porter <dick@ximian.com> + + * ComparerTest.cs: Test for invariant compares (bug 61458.) + 2004-06-14 Sebastien Pouliot <sebastien@ximian.com> * HashtableTest.cs: Added new case to CopyTo(Array,int) an empty diff --git a/mcs/class/corlib/Test/System.Collections/ComparerTest.cs b/mcs/class/corlib/Test/System.Collections/ComparerTest.cs index c6353f4ec6a..c1591fc3402 100644 --- a/mcs/class/corlib/Test/System.Collections/ComparerTest.cs +++ b/mcs/class/corlib/Test/System.Collections/ComparerTest.cs @@ -42,7 +42,16 @@ namespace MonoTests.System.Collections { Assert(c.Compare (3, 2) > 0);
}
-
+ + [Test] + public void Invariant () + { + Comparer c = Comparer.DefaultInvariant; + + Assert (c.Compare ("a", "A") > 0); + } + + }
}
diff --git a/mcs/class/corlib/Test/System.Reflection/ChangeLog b/mcs/class/corlib/Test/System.Reflection/ChangeLog index 2c5110a6ee3..fd367c75537 100644 --- a/mcs/class/corlib/Test/System.Reflection/ChangeLog +++ b/mcs/class/corlib/Test/System.Reflection/ChangeLog @@ -1,3 +1,7 @@ +2004-07-03 Zoltan Varga <vargaz@freemail.hu> + + * ModuleTest.cs: New tests for FindTypes. + 2004-06-10 Lluis Sanchez <lluis@ximian.com> * AssemblyNameTest.cs: AssertEqualsByteArrays(): don't crash if arrays are diff --git a/mcs/class/corlib/Test/System/ChangeLog b/mcs/class/corlib/Test/System/ChangeLog index b271ba154f9..6d419bfee33 100644 --- a/mcs/class/corlib/Test/System/ChangeLog +++ b/mcs/class/corlib/Test/System/ChangeLog @@ -1,3 +1,13 @@ +2004-09-23 Martin Garton <martin@wrasse.demon.co.uk> + + * ConvertTest.cs: Ensure ToType() fails with an ArgumentException in + a case where is cannot convert. + +2004-08-17 Sebastien Pouliot <sebastien@ximian.com> + + * VersionTest.cs: Added tests when cloning a version with no build and + no revision numbers (-1). + 2004-06-23 Sebastien Pouliot <sebastien@ximian.com> * DoubleFormatterTest.cs: Added a new test for a negative roundtrip diff --git a/mcs/class/corlib/Test/System/ConvertTest.cs b/mcs/class/corlib/Test/System/ConvertTest.cs index bafdffdb566..44e5f547567 100755 --- a/mcs/class/corlib/Test/System/ConvertTest.cs +++ b/mcs/class/corlib/Test/System/ConvertTest.cs @@ -189,7 +189,17 @@ namespace MonoTests.System { } catch (Exception e) { AssertEquals("#A33", typeof(ArgumentNullException), e.GetType()); - } + } + + try { + /* should fail to convert string to any enumeration type. */ + Convert.ChangeType("random string", typeof(DayOfWeek)); + Fail(); + } + catch (Exception e) { + AssertEquals("#A34", typeof(ArgumentException), e.GetType()); + } + } public void TestGetTypeCode() { diff --git a/mcs/class/corlib/Test/System/VersionTest.cs b/mcs/class/corlib/Test/System/VersionTest.cs index 635a485cadc..2467d963a48 100644 --- a/mcs/class/corlib/Test/System/VersionTest.cs +++ b/mcs/class/corlib/Test/System/VersionTest.cs @@ -135,6 +135,12 @@ public class VersionTest : TestCase Assert ("A1", v1.Equals (v2)); Assert ("A2", !ReferenceEquals (v1, v2)); + + Version v3 = new Version (); // 0.0 + v2 = (Version) v3.Clone (); + + Assert ("A3", v3.Equals (v2)); + Assert ("A4", !ReferenceEquals (v3, v2)); } public void TestCompareTo () diff --git a/mcs/class/corlib/corlib.dll.sources b/mcs/class/corlib/corlib.dll.sources index 4a49234f3f2..c1a958a1308 100755 --- a/mcs/class/corlib/corlib.dll.sources +++ b/mcs/class/corlib/corlib.dll.sources @@ -307,6 +307,8 @@ System.IO/StringReader.cs System.IO/StringWriter.cs System.IO/TextReader.cs System.IO/TextWriter.cs +System.IO/UnexceptionalStreamReader.cs +System.IO/UnexceptionalStreamWriter.cs System.IO.IsolatedStorage/INormalizeForIsolatedStorage.cs System.IO.IsolatedStorage/IsolatedStorage.cs System.IO.IsolatedStorage/IsolatedStorageException.cs |