Author: krasnov
Date: 2007-12-25 05:17:47 -0500 (Tue, 25 Dec 2007)
New Revision: 91873
Modified:
trunk/mcs/class/System/System.ComponentModel/ChangeLog
trunk/mcs/class/System/System.ComponentModel/PropertyDescriptorCollection.cs
trunk/mcs/class/System/Test/System.ComponentModel/ChangeLog
trunk/mcs/class/System/Test/System.ComponentModel/PropertyDescriptorCollectionTests.cs
Log:
* PropertyDescriptorCollection.cs: optimized Find method, removed culture
sensitive string comparison
* PropertyDescriptorCollectionTests.cs: added test for Find method
Modified: trunk/mcs/class/System/System.ComponentModel/ChangeLog
===================================================================
--- trunk/mcs/class/System/System.ComponentModel/ChangeLog 2007-12-25
10:09:22 UTC (rev 91872)
+++ trunk/mcs/class/System/System.ComponentModel/ChangeLog 2007-12-25
10:17:47 UTC (rev 91873)
@@ -1,3 +1,8 @@
+2007-12-25 Vladimir Krasnov <[EMAIL PROTECTED]>
+
+ * PropertyDescriptorCollection.cs: optimized Find method, removed
+ culture sensitive string comparison
+
2007-12-19 Dick Porter <[EMAIL PROTECTED]>
* Win32Exception.cs: Add text for error 5, Access denied.
Modified:
trunk/mcs/class/System/System.ComponentModel/PropertyDescriptorCollection.cs
===================================================================
---
trunk/mcs/class/System/System.ComponentModel/PropertyDescriptorCollection.cs
2007-12-25 10:09:22 UTC (rev 91872)
+++
trunk/mcs/class/System/System.ComponentModel/PropertyDescriptorCollection.cs
2007-12-25 10:17:47 UTC (rev 91873)
@@ -144,8 +144,26 @@
}
foreach (PropertyDescriptor p in properties) {
- if (0 == String.Compare (name, p.Name,
ignoreCase, System.Globalization.CultureInfo.InvariantCulture))
- return p;
+#if NET_2_0
+ if (ignoreCase) {
+ if (0 == String.Compare (name, p.Name,
StringComparison.OrdinalIgnoreCase))
+ return p;
+ }
+ else {
+ if (0 == String.Compare (name, p.Name,
StringComparison.Ordinal))
+ return p;
+ }
+#else
+ if (ignoreCase) {
+ if (0 == String.CompareOrdinal
(name.ToLower (System.Globalization.CultureInfo.InvariantCulture),
+ p.Name.ToLower
(System.Globalization.CultureInfo.InvariantCulture)))
+ return p;
+ }
+ else {
+ if (0 == String.CompareOrdinal (name,
p.Name))
+ return p;
+ }
+#endif
}
return null;
}
Modified: trunk/mcs/class/System/Test/System.ComponentModel/ChangeLog
===================================================================
--- trunk/mcs/class/System/Test/System.ComponentModel/ChangeLog 2007-12-25
10:09:22 UTC (rev 91872)
+++ trunk/mcs/class/System/Test/System.ComponentModel/ChangeLog 2007-12-25
10:17:47 UTC (rev 91873)
@@ -1,3 +1,7 @@
+2007-12-25 Vladimir Krasnov <[EMAIL PROTECTED]>
+
+ * PropertyDescriptorCollectionTests.cs: added test for Find method
+
2007-12-04 Gert Driesen <[EMAIL PROTECTED]>
* Win32ExceptionTest.cs: Added ctor tests.
Modified:
trunk/mcs/class/System/Test/System.ComponentModel/PropertyDescriptorCollectionTests.cs
===================================================================
---
trunk/mcs/class/System/Test/System.ComponentModel/PropertyDescriptorCollectionTests.cs
2007-12-25 10:09:22 UTC (rev 91872)
+++
trunk/mcs/class/System/Test/System.ComponentModel/PropertyDescriptorCollectionTests.cs
2007-12-25 10:17:47 UTC (rev 91873)
@@ -118,6 +118,21 @@
dictionary.Add ("whatever", 5);
}
+ [Test]
+ public void CultureInsensitiveFindTest ()
+ {
+ Assert.AreEqual(0, string.Compare ("\u0061\u030a",
"\u00e5", true), "#1");
+
+ PropertyDescriptorCollection col =
+ new PropertyDescriptorCollection (
+ new PropertyDescriptor [] {
+ new MockPropertyDescriptor
("hehe_\u0061\u030a", null),
+ new MockPropertyDescriptor
("heh_\u00e5", null) });
+
+ Assert.IsNull (col.Find ("heh_\u0061\u030a", false),
"#2");
+ Assert.IsNull (col.Find ("hehe_\u00e5", false), "#3");
+
+ }
#if NET_2_0
public void ReadOnly ()
{
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches