Răsfoiți Sursa

2009-06-10 Marek Safar <[email protected]>

	* Predicate.cs, Action.cs, Funcs.cs, Comparison.cs, IComparable.cs,
	Converter.cs, EventHandler.cs: Add type variance.
	
	* InvalidTimeZoneException.cs,
	TimeZoneNotFoundException.cs: New file.


svn path=/trunk/mcs/; revision=135847
Marek Safar 16 ani în urmă
părinte
comite
2fec4e4d1e

+ 27 - 3
mcs/class/corlib/System/Action.cs

@@ -3,6 +3,7 @@
 //
 // Authors:
 //  Ben Maurer ([email protected])
+//  Marek Safar ([email protected])
 //
 // Copyright (C) 2004 Novell
 //
@@ -25,8 +26,31 @@
 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 //
-#if NET_2_0
-namespace System {
+
+using System.Runtime.CompilerServices;
+
+namespace System
+{
+#if NET_4_0
+	[TypeForwardedFrom (Consts.AssemblySystemCore_3_5)]
+	public delegate void Action ();
+	
+	public delegate void Action <in T> (T obj);
+	
+	[TypeForwardedFrom (Consts.AssemblySystemCore_3_5)]
+	public delegate void Action <in T1, in T2> (T1 arg1, T2 arg2);
+	
+	[TypeForwardedFrom (Consts.AssemblySystemCore_3_5)]
+	public delegate void Action <in T1, in T2, in T3> (T1 arg1, T2 arg2, T3 arg3);
+	
+	[TypeForwardedFrom (Consts.AssemblySystemCore_3_5)]
+	public delegate void Action <in T1, in T2, in T3, in T4> (T1 arg1, T2 arg2, T3 arg3, T4 arg4);
+	
+	public delegate void Action <in T1, in T2, in T3, in T4, in T5> (T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5);
+	public delegate void Action <in T1, in T2, in T3, in T4, in T5, in T6> (T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6);
+	public delegate void Action <in T1, in T2, in T3, in T4, in T5, in T6, in T7> (T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7);
+	public delegate void Action <in T1, in T2, in T3, in T4, in T5, in T6, in T7, in T8> (T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7, T8 arg8);
+#elif NET_2_0
 	public delegate void Action <T> (T obj);
+#endif	
 }
-#endif

+ 8 - 0
mcs/class/corlib/System/ChangeLog

@@ -1,3 +1,11 @@
+2009-06-10  Marek Safar  <[email protected]>
+
+	* Predicate.cs, Action.cs, Funcs.cs, Comparison.cs, IComparable.cs,
+	Converter.cs, EventHandler.cs: Add type variance.
+	
+	* InvalidTimeZoneException.cs,
+	TimeZoneNotFoundException.cs: New file.
+
 2009-05-27  Zoltan Varga  <[email protected]>
 
 	* AppDomain.cs (DoAssemblyResolve): Fix recursion detection. Fixes #507003.

+ 9 - 3
mcs/class/corlib/System/Comparison.cs

@@ -3,6 +3,7 @@
 //
 // Authors:
 //  Ben Maurer ([email protected])
+//  Marek Safar ([email protected])
 //
 // Copyright (C) 2004 Novell
 //
@@ -25,8 +26,13 @@
 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 //
-#if NET_2_0
-namespace System {
+
+namespace System
+{
+#if NET_4_0
+	public delegate int Comparison <in T> (T x, T y);
+#elif NET_2_0
 	public delegate int Comparison <T> (T x, T y);
+#endif	
 }
-#endif
+

+ 8 - 3
mcs/class/corlib/System/Converter.cs

@@ -3,6 +3,7 @@
 //
 // Authors:
 //  Ben Maurer ([email protected])
+//  Marek Safar ([email protected])
 //
 // Copyright (C) 2004 Novell
 //
@@ -25,8 +26,12 @@
 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 //
-#if NET_2_0
-namespace System {
+
+namespace System
+{
+#if NET_4_0
+	public delegate TOutput Converter <in TInput, out TOutput> (TInput input);
+#elif NET_2_0
 	public delegate TOutput Converter <TInput, TOutput> (TInput input);
-}
 #endif
+}

+ 6 - 0
mcs/class/corlib/System/EventHandler.cs

@@ -3,6 +3,7 @@
 //
 // Author:
 //   Miguel de Icaza ([email protected])
+//   Marek Safar ([email protected])
 //
 // (C) Ximian, Inc.  http://www.ximian.com
 //
@@ -33,8 +34,13 @@
 namespace System {
 
 #if NET_2_0
+
 	[Serializable]
+#if NET_4_0
+	public delegate void EventHandler <in TEventArgs> (object sender, TEventArgs e) where TEventArgs : EventArgs;
+#else	
 	public delegate void EventHandler <TEventArgs> (object sender, TEventArgs e) where TEventArgs : EventArgs;
+#endif	
 
 	[Serializable]
 	[System.Runtime.InteropServices.ComVisible (true)]

+ 24 - 7
mcs/class/corlib/System/Funcs.cs

@@ -27,12 +27,29 @@
 
 #if NET_4_0
 
-namespace System {
-	public delegate TResult Func<TResult> ();
-	public delegate TResult Func<T, TResult> (T arg1);
-	public delegate TResult Func<T1, T2, TResult> (T1 arg1, T2 arg2);
-	public delegate TResult Func<T1, T2, T3, TResult> (T1 arg1, T2 arg2, T3 arg3);
-	public delegate TResult Func<T1, T2, T3, T4, TResult> (T1 arg1, T2 arg2, T3 arg3, T4 arg4);
+using System.Runtime.CompilerServices;
+
+namespace System
+{
+	[TypeForwardedFrom (Consts.AssemblySystemCore_3_5)]	
+	public delegate TResult Func<out TResult> ();
+	
+	[TypeForwardedFrom (Consts.AssemblySystemCore_3_5)]
+	public delegate TResult Func<in T, out TResult> (T arg1);
+	
+	[TypeForwardedFrom (Consts.AssemblySystemCore_3_5)]
+	public delegate TResult Func<in T1, in T2, out TResult> (T1 arg1, T2 arg2);
+	
+	[TypeForwardedFrom (Consts.AssemblySystemCore_3_5)]
+	public delegate TResult Func<in T1, in T2, in T3, out TResult> (T1 arg1, T2 arg2, T3 arg3);
+	
+	[TypeForwardedFrom (Consts.AssemblySystemCore_3_5)]
+	public delegate TResult Func<in T1, in T2, in T3, in T4, out TResult> (T1 arg1, T2 arg2, T3 arg3, T4 arg4);
+	
+	public delegate TResult Func<in T1, in T2, in T3, in T4, in T5, out TResult> (T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5);
+	public delegate TResult Func<in T1, in T2, in T3, in T4, in T5, in T6, out TResult> (T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6);
+	public delegate TResult Func<in T1, in T2, in T3, in T4, in T5, in T6, in T7, out TResult> (T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7);
+	public delegate TResult Func<in T1, in T2, in T3, in T4, in T5, in T6, in T7, in T8, out TResult> (T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7, T8 arg8);
 }
 
-#endif
+#endif

+ 6 - 1
mcs/class/corlib/System/IComparable.cs

@@ -3,6 +3,7 @@
 //
 // Author:
 //   Miguel de Icaza ([email protected])
+//   Marek Safar ([email protected])
 //
 // (C) Ximian, Inc.  http://www.ximian.com
 //
@@ -40,7 +41,11 @@ namespace System {
 		int CompareTo (object obj);
 	}
 	
-#if NET_2_0
+#if NET_4_0
+	public interface IComparable <in T> {
+		int CompareTo (T other);
+	}
+#elif NET_2_0
 	public interface IComparable <T> {
 		int CompareTo (T other);
 	}

+ 51 - 0
mcs/class/corlib/System/InvalidTimeZoneException.cs

@@ -0,0 +1,51 @@
+/*
+ * System.InvalidimeZoneException
+ *
+ * Author(s)
+ * 	Stephane Delcroix <[email protected]>
+ *
+ * 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.
+ */
+
+#if NET_4_0
+
+using System.Runtime.CompilerServices;
+
+namespace System
+{
+	[Serializable]
+	[TypeForwardedFrom (Consts.AssemblySystemCore_3_5)]	
+	public class InvalidTimeZoneException : Exception
+	{
+		public InvalidTimeZoneException () : base ()
+		{}
+
+		public InvalidTimeZoneException (string message) : base (message)
+		{}
+
+		public InvalidTimeZoneException (string message, Exception e) : base (message, e)
+		{}
+
+		protected InvalidTimeZoneException (Runtime.Serialization.SerializationInfo info, Runtime.Serialization.StreamingContext sc) : base (info, sc)
+		{}
+	}
+}
+
+#endif

+ 9 - 3
mcs/class/corlib/System/Predicate.cs

@@ -3,6 +3,7 @@
 //
 // Authors:
 //  Ben Maurer ([email protected])
+//  Marek Safar ([email protected])
 //
 // Copyright (C) 2004 Novell
 //
@@ -25,8 +26,13 @@
 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 //
-#if NET_2_0
-namespace System {
+
+namespace System
+{
+#if NET_4_0
+	public delegate bool Predicate <in T> (T obj);
+#elif NET_2_0
 	public delegate bool Predicate <T> (T obj);
+#endif	
 }
-#endif
+

+ 51 - 0
mcs/class/corlib/System/TimeZoneNotFoundException.cs

@@ -0,0 +1,51 @@
+/*
+ * System.TimeZoneNotFoundException
+ *
+ * Author(s)
+ * 	Stephane Delcroix <[email protected]>
+ *
+ * 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.
+ */
+
+#if NET_4_0
+
+using System.Runtime.CompilerServices;
+
+namespace System
+{
+	[Serializable]
+	[TypeForwardedFrom (Consts.AssemblySystemCore_3_5)]	
+	public class TimeZoneNotFoundException : Exception
+	{
+		public TimeZoneNotFoundException () : base ()
+		{}
+
+		public TimeZoneNotFoundException (string message) : base (message)
+		{}
+
+		public TimeZoneNotFoundException (string message, Exception e) : base (message, e)
+		{}
+
+		protected TimeZoneNotFoundException (Runtime.Serialization.SerializationInfo info, Runtime.Serialization.StreamingContext sc) : base (info, sc)
+		{}
+	}
+}
+
+#endif