[Mono-devel-list] Re: mcs/class/corlib/System.Collections CaseInsensitiveHashCodeProvider.cs,1.11,1.12 ChangeLog,1.114,1.115
Lluis Sanchez
lluis at ximian.com
Mon Apr 26 05:17:45 EDT 2004
Hi
This change will make CaseInsensitiveHashCodeProvider to always use the
culture of the thread that created the instance, not the current culture
of the calling thread. I wonder if this is the intended behavior.
Lluis.
On dg, 2004-04-25 at 13:42, Andreas Nahr wrote:
> Update of /cvs/public/mcs/class/corlib/System.Collections
> In directory mono-cvs.ximian.com:/tmp/cvs-serv12155
>
> Modified Files:
> CaseInsensitiveHashCodeProvider.cs ChangeLog
> Log Message:
> 2004-04-25 Andreas Nahr <ClassDevelopment at A-SoftTech.com>
>
> * CaseInsensitiveHashCodeProvider.cs: Fix the default constructor (needs to
> set CurrentCulture, Add null check to other constructor, Call correct function
> for invariant case, ensure culture is set to null for invariant case, removed
> static constructor, made invariant version available as internal in .Net 1.0
>
>
> Index: CaseInsensitiveHashCodeProvider.cs
> ===================================================================
> RCS file: /cvs/public/mcs/class/corlib/System.Collections/CaseInsensitiveHashCodeProvider.cs,v
> retrieving revision 1.11
> retrieving revision 1.12
> diff -u -d -r1.11 -r1.12
> --- CaseInsensitiveHashCodeProvider.cs 21 Apr 2004 21:29:28 -0000 1.11
> +++ CaseInsensitiveHashCodeProvider.cs 25 Apr 2004 11:42:52 -0000 1.12
> @@ -16,31 +16,31 @@
> [Serializable]
> public class CaseInsensitiveHashCodeProvider : IHashCodeProvider {
>
> - private static CaseInsensitiveHashCodeProvider singleton;
> - private static CaseInsensitiveHashCodeProvider singletonInvariant;
> + private static CaseInsensitiveHashCodeProvider singleton = new CaseInsensitiveHashCodeProvider ();
> + private static CaseInsensitiveHashCodeProvider singletonInvariant = new CaseInsensitiveHashCodeProvider (true);
>
> CultureInfo culture;
>
> -
> - // Class constructor
> -
> - static CaseInsensitiveHashCodeProvider ()
> - {
> - singleton = new CaseInsensitiveHashCodeProvider ();
> - singletonInvariant = new CaseInsensitiveHashCodeProvider (CultureInfo.InvariantCulture);
> - }
> -
> -
> -
> // Public instance constructor
>
> public CaseInsensitiveHashCodeProvider ()
> - {
> + {
> + culture = CultureInfo.CurrentCulture;
> + }
> +
> + public CaseInsensitiveHashCodeProvider (bool invariant)
> + {
> + // leave culture == null
> }
>
> public CaseInsensitiveHashCodeProvider (CultureInfo culture)
> - {
> - this.culture = culture;
> + {
> + if (culture == null)
> + throw new ArgumentNullException ("culture");
> +
> + if (culture.LCID != CultureInfo.InvariantCulture.LCID)
> + this.culture = culture;
> + // else leave culture == null
> }
>
>
> @@ -55,13 +55,15 @@
> }
>
> #if NET_1_1
> - public static CaseInsensitiveHashCodeProvider DefaultInvariant {
> + public
> +#else
> + internal
> +#endif
> + static CaseInsensitiveHashCodeProvider DefaultInvariant {
> get {
> return singletonInvariant;
> }
> }
> -#endif
> -
>
> //
> // Instance methods
> @@ -73,9 +75,8 @@
>
> public int GetHashCode (object obj)
> {
> - if (obj == null) {
> - throw new ArgumentNullException ("obj is null");
> - }
> + if (obj == null)
> + throw new ArgumentNullException ("obj");
>
> string str = obj as string;
>
> @@ -94,7 +95,7 @@
> }
> else {
> for (int i = 0;i<length;i++) {
> - c = Char.ToLower (str [i]);
> + c = Char.ToLowerInvariant (str [i]);
> h = h * 31 + c;
> }
> }
>
> Index: ChangeLog
> ===================================================================
> RCS file: /cvs/public/mcs/class/corlib/System.Collections/ChangeLog,v
> retrieving revision 1.114
> retrieving revision 1.115
> diff -u -d -r1.114 -r1.115
> --- ChangeLog 21 Apr 2004 21:29:28 -0000 1.114
> +++ ChangeLog 25 Apr 2004 11:42:52 -0000 1.115
> @@ -1,3 +1,10 @@
> +2004-04-25 Andreas Nahr <ClassDevelopment at A-SoftTech.com>
> +
> + * CaseInsensitiveHashCodeProvider.cs: Fix the default constructor (needs to
> + set CurrentCulture, Add null check to other constructor, Call correct function
> + for invariant case, ensure culture is set to null for invariant case, removed
> + static constructor, made invariant version available as internal in .Net 1.0
> +
> 2004-04-21 Lluis Sanchez Gual <lluis at ximian.com>
>
> * CaseInsensitiveHashCodeProvider.cs: If the culture is null, don't use
>
> _______________________________________________
> Mono-patches maillist - Mono-patches at ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-patches
More information about the Mono-devel-list
mailing list