Re: [Mono-dev] [PATCH] unbreak postbacks (fix for r70294)

2007-01-09 Thread Ben Timby

And you would be 100% correct.

Christian Birkl wrote:

The typeof operator exists since version 1 of javascript/ecmascript and
every object which implements [Call] returns 'function'. So it is pretty
backwards and browser compatible (I'm going as far as to bet one beer
that Netscape 3.x supports this statement ;-))

Christian


	
	
		test
	
___
Mono-devel-list mailing list
Mono-devel-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-devel-list


[Mono-dev] BaseCompareValidatorTest - fix

2007-01-09 Thread Ilya Kharmatsky


After a long-long delay, hi all!

Please review the attached patch, which fixes the 
BaseCompareValidatorTest (see www.mono-project.com/ASPTests). The 
changes are related to the both versions of ASP.Net 1.1 and 2.0. I've 
run the test suit with both configurations (1.1 and 2.0) and no 
regression was found.


Thanks,
Ilya.



Index: System.Web/System.Web.UI.WebControls/BaseCompareValidator.cs
===
--- System.Web/System.Web.UI.WebControls/BaseCompareValidator.cs
(revision 70722)
+++ System.Web/System.Web.UI.WebControls/BaseCompareValidator.cs
(working copy)
@@ -79,33 +79,7 @@
   ValidationDataType type,
   out object value)
{
-   try {
-   switch (type) {
-   case ValidationDataType.String:
-   value = text;
-   return value != null;
-   case ValidationDataType.Integer:
-   value = Int32.Parse (text);
-   return true;
-   case ValidationDataType.Double:
-   value = Double.Parse(text);
-   return true;
-   case ValidationDataType.Date:
-   value = DateTime.Parse(text);
-   return true;
-   case ValidationDataType.Currency:
-   value = Decimal.Parse(text, 
NumberStyles.Currency);
-   return true;
-   default:
-   value = null;
-   return false;
-   }
-   }
-   catch {
-   value = null;
-   return false;
-   }
-
+return BaseCompareValidator.Convert(text, type, false, out value);
}
 
protected static bool Compare (string left,
@@ -113,40 +87,7 @@
   ValidationCompareOperator op,
   ValidationDataType type)
{
-   object lo, ro;
-
-   if (!Convert (left, type, out lo))
-   return false;
-
-   /* DataTypeCheck is a unary operator that only
-* depends on the lhs */
-   if (op == ValidationCompareOperator.DataTypeCheck)
-   return true;
-
-   /* pretty crackladen, but if we're unable to
-* convert the rhs to @type, the comparison
-* succeeds */
-   if (!Convert (right, type, out ro))
-   return true;
-
-   int comp = ((IComparable)lo).CompareTo 
((IComparable)ro);
-
-   switch (op) {
-   case ValidationCompareOperator.Equal:
-   return comp == 0;
-   case ValidationCompareOperator.NotEqual:
-   return comp != 0;
-   case ValidationCompareOperator.LessThan:
-   return comp < 0;
-   case ValidationCompareOperator.LessThanEqual:
-   return comp <= 0;
-   case ValidationCompareOperator.GreaterThan:
-   return comp > 0;
-   case ValidationCompareOperator.GreaterThanEqual:
-   return comp >= 0;
-   default:
-   return false;
-   }
+return BaseCompareValidator.Compare(left, false, right, false, op, 
type);  
}
 
protected override bool DetermineRenderUplevel ()
@@ -220,18 +161,24 @@
 #if NET_2_0
[DefaultValue (false)]
[Themeable (false)]
-   public bool CultureInvariantValues {
+   public
+#else 
+   internal
+#endif
+bool CultureInvariantValues {
get { return ViewState.GetBool 
("CultureInvariantValues", false); }
set { ViewState ["CultureInvariantValues"] = value; }
}
-#endif
 
-   protected static int CutoffYear {
+
+   
+   protected static int CutoffYear {
get {
return 
CultureInf

[Mono-dev] Please approve commit change to System.Web.Hosting/ApplicationHost.cs

2007-01-09 Thread Adar Wesley
Hi All,

 

I would like to commit a change to ApplicationHost.  The suggested diff
follows:

 

svn diff System.Web.Hosting/ApplicationHost.cs

Index: System.Web.Hosting/ApplicationHost.cs

===

--- System.Web.Hosting/ApplicationHost.cs   (revision 70723)

+++ System.Web.Hosting/ApplicationHost.cs   (working copy)

@@ -81,12 +81,9 @@

if (physicalDir == null)

throw new NullReferenceException ();

 

-#if NET_2_0

+   // Make sure physicalDir has file system
semantics

+   // and not uri semantics ( '\' and not '/' ).

physicalDir = Path.GetFullPath (physicalDir);

-#endif

-   // This might throw

-   Uri u = new Uri (physicalDir);

-   physicalDir = HttpUtility.UrlDecode
(u.AbsolutePath);

 

 

The reasoning is that physicalDir should have file system semantics and

not URI semantics.  The Path.GetFullPath() API fixes all the slashes to
be

correct for the OS.

 

This is true both for version 1.1 and 2.0.

 

Thanks,

 

Adar Wesley

 

___
Mono-devel-list mailing list
Mono-devel-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-devel-list


[Mono-dev] [Patch] TreeView, TreeNode, TreeNodeCollection

2007-01-09 Thread Alan McGovern

Hi,

This is my first patch, so i want to make sure that everything is alright
before i go committing. I will provide NUnit tests for the new functionality
(i'll post the tests here) if everything looks good with the patch.

I just implemented some of the .NET 2.0 methods which are missing which i
would like to have. They're nothing major. Also, how would i go about
implementing the ContextMenu stuff. Is there an example of how i can do
this? I'm not 100% sure how to do it :p
Index: C:/programming/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TreeNode.cs
===
--- C:/programming/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TreeNode.cs	(revision 69123)
+++ C:/programming/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TreeNode.cs	(working copy)
@@ -54,6 +54,9 @@
 
 		internal IntPtr handle;
 		
+#if NET_2_0
+		private string name = string.Empty;
+#endif
 		#endregion	// Fields
 
 		#region Internal Constructors		
@@ -352,6 +355,18 @@
 			}
 		}
 
+#if NET_2_0
+		public string Name
+		{
+			get { return this.name; }
+			set
+			{
+// Value should never be null as per spec
+this.name = (value == null) ? string.Empty : value;
+			}
+		}
+#endif
+
 		public TreeNode NextNode {
 			get {
 if (parent == null)
Index: C:/programming/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TreeNodeCollection.cs
===
--- C:/programming/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TreeNodeCollection.cs	(revision 69123)
+++ C:/programming/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TreeNodeCollection.cs	(working copy)
@@ -95,6 +95,20 @@
 			}
 		}
 
+		#if NET_2_0
+		public virtual TreeNode this[string key]
+		{
+			get
+			{
+if(string.IsNullOrEmpty(key))
+		return null;
+
+int index = IndexOfKey(key);
+return (index == -1) ? null : this[index];
+			}
+		}
+		#endif
+
 		public virtual TreeNode Add (string text)
 		{
 			TreeNode res = new TreeNode (text);
@@ -442,6 +456,43 @@
 return (res == 0 ? l.Index - r.Index : res);
 			}
 		}
+
+#if NET_2_0
+		public virtual int IndexOfKey(string key)
+		{
+			if (string.IsNullOrEmpty(key))
+return -1;
+
+// We do a case insensitive comparison to find the key
+			for (int i = 0; i < nodes.Count; i++)
+if (string.Equals(nodes.Name, name, StringComparison.CurrentCultureIgnoreCase))
+	return i;
+
+			return -1;
+}
+
+		public virtual bool ContainsKey(string name)
+		{
+			return (IndexOfKey(name) != -1);
+		}
+
+
+		public virtual void RemoveByKey(string key)
+		{
+			int index = -1;
+			for (int i = 0; i < nodes.Count; i++)
+			{
+if (!string.Equals(nodes[i].Name,key, StringComparison.CurrentCultureIgnoreCase))
+	continue;
+
+index = i;
+break;
+			}
+
+			if (index != -1)
+RemoveAt(index);
+		}
+#endif
 	}
 }
 
Index: C:/programming/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TreeView.cs
===
--- C:/programming/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TreeView.cs	(revision 69123)
+++ C:/programming/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TreeView.cs	(working copy)
@@ -549,6 +549,15 @@
 			return root_node.GetNodeCount (include_subtrees);
 		}
 
+		#if NET_2_0
+		public void Sort()
+		{
+			// Just call the pre-existing methods to sort the treeview.
+			// I assume it'll sort correctly.
+			this.Sorted = true;
+		}
+#endif
+
 		public override string ToString () {
 			int count = Nodes.Count;
 			if (count <= 0)
Index: C:/programming/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
===
--- C:/programming/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog	(revision 69123)
+++ C:/programming/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog	(working copy)
@@ -1,3 +1,9 @@
+2007-1-09 Alan McGovern <[EMAIL PROTECTED]>
+	* TreeNode.cs
+	* TreeView.cs
+	* TreeNodeCollection.cs
+	- Added some new .NET 2.0 methods
+
 2006-12-06  Jackson Harper  <[EMAIL PROTECTED]>
 
 	* TextControl.cs: Make this operation undoable.
___
Mono-devel-list mailing list
Mono-devel-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-devel-list


Re: [Mono-dev] [Patch] TreeView, TreeNode, TreeNodeCollection

2007-01-09 Thread Robert Jordan
Hi Alan,

Alan McGovern wrote:
> This is my first patch, so i want to make sure that everything is alright
> before i go committing. I will provide NUnit tests for the new 
> functionality
> (i'll post the tests here) if everything looks good with the patch.

You should write and test the unit tests on MS.NET even before
starting to code, because MS.NET's docs are often incomplete.

> +#if NET_2_0
> + public virtual int IndexOfKey(string key)
> + {
> + if (string.IsNullOrEmpty(key))
> + return -1;
> +
> + // We do a case insensitive comparison to find 
> the key
> + for (int i = 0; i < nodes.Count; i++)
> + if (string.Equals(nodes.Name, name, 
> StringComparison.CurrentCultureIgnoreCase))

Does MS.NET really perform a culture-variant comparison?

Also, that's a linear scan. How does MS.NET perform? You may want to
write a test that creates 100 nodes and that removes them by
name. If it's an almost instant operation on MS.NET, they are probably
optimizing the lookup using a non-linear (hash table, sorted
list) data type.

> + public virtual void RemoveByKey(string key)
> + {
> + int index = -1;
> + for (int i = 0; i < nodes.Count; i++)
> + {
> + if (!string.Equals(nodes[i].Name,key, 
> StringComparison.CurrentCultureIgnoreCase))
> + continue;
> +
> + index = i;
> + break;
> + }

Ditto. Additionally, what happens on MS.NET if you remove the
String.Empty key? What happens if the collection has duplicate keys?
Will be the keys deleted all together or just the first/last/random
occurrence?

Robert

___
Mono-devel-list mailing list
Mono-devel-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-devel-list


Re: [Mono-dev] [Patch] TreeView, TreeNode, TreeNodeCollection

2007-01-09 Thread Carlos Alberto Cortez

> 
> > +   public virtual void RemoveByKey(string key)
> > +   {
> > +   int index = -1;
> > +   for (int i = 0; i < nodes.Count; i++)
> > +   {
> > +   if (!string.Equals(nodes[i].Name,key, 
> > StringComparison.CurrentCultureIgnoreCase))
> > +   continue;
> > +
> > +   index = i;
> > +   break;
> > +   }
> 
> Ditto. Additionally, what happens on MS.NET if you remove the
> String.Empty key? What happens if the collection has duplicate keys?
> Will be the keys deleted all together or just the first/last/random
> occurrence?

As far as I can tell, RemoveByKey behaves just like the other
Key-related methods, so when passing a null or empty string it should do
nothing.

Also, when having duplicate keys, the method should remove the first
occurrence (at least that happens with ListView related collections, for
example).

Anyway, the best thing do do, as Robert said, is to write tests.

Carlos.




___
Mono-devel-list mailing list
Mono-devel-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-devel-list


[Mono-dev] Cross-platform fsync()

2007-01-09 Thread Patrick Earl
Greetings all.  I've recently run into the need for a cross platform
fsync() call.  As far as I know, all of the flavors of unix that mono
supports provide the fsync call themselves.  On windows, there is a
_commit() function that does the same thing.  It seems like the
underlying platform support is there, but I'm not sure how to bring
that back up into the .net world so we can, for example, perform some
sort of flush to disk operation on a FileStream.  Suggestions?  Ideas?

Patrick
___
Mono-devel-list mailing list
Mono-devel-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-devel-list


Re: [Mono-dev] Cross-platform fsync()

2007-01-09 Thread Robert Jordan
Patrick Earl wrote:
> Greetings all.  I've recently run into the need for a cross platform
> fsync() call.  As far as I know, all of the flavors of unix that mono
> supports provide the fsync call themselves.  On windows, there is a
> _commit() function that does the same thing.  It seems like the
> underlying platform support is there, but I'm not sure how to bring
> that back up into the .net world so we can, for example, perform some
> sort of flush to disk operation on a FileStream.  Suggestions?  Ideas?

On MS.NET and Mono for Windows, the proper function is WIN32's
FlushFileBuffers()that can be called via p/invoke from kernel32.dll
either on FileStream.Handle, or (.NET 2.0) on FileStream.SafeFileHandle.

On Linux, FlushFileBuffers() is provided by Mono's WAPI layer
that calls fsync(2) internally, but I don't know how it can be
called from managed code. Maybe like this (untested):

[DllImport("__Internal")]
public static bool FlushFileBuffers (IntPtr handle);

For .NET 2.0:
[DllImport("__Internal")]
public static bool FlushFileBuffers (SafeFileHandle handle);

The meaning of "__Internal" is documented here:

http://mono-project.com/Interop_with_Native_Libraries

Robert

___
Mono-devel-list mailing list
Mono-devel-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-devel-list


Re: [Mono-dev] Cross-platform fsync()

2007-01-09 Thread Alan McGovern

(sorry, just realised last message didn't go to mailing list)
Hi,

Have you tried FileStream.Flush()? ;)

Alan.

On 1/9/07, Patrick Earl <[EMAIL PROTECTED]> wrote:


Greetings all.  I've recently run into the need for a cross platform
fsync() call.  As far as I know, all of the flavors of unix that mono
supports provide the fsync call themselves.  On windows, there is a
_commit() function that does the same thing.  It seems like the
underlying platform support is there, but I'm not sure how to bring
that back up into the .net world so we can, for example, perform some
sort of flush to disk operation on a FileStream.  Suggestions?  Ideas?

Patrick
___
Mono-devel-list mailing list
Mono-devel-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-devel-list

___
Mono-devel-list mailing list
Mono-devel-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-devel-list