Browse Source

2006-09-02 Zoltan Varga <[email protected]>

	* ParameterInfo.cs MethodInfo.cs MonoMethod.cs: Applied patch from 
	Peter Dettman ([email protected]). Implement ReturnParameter
	property.

svn path=/trunk/mcs/; revision=64762
Zoltan Varga 19 years ago
parent
commit
a01e55c26d

+ 4 - 0
mcs/class/corlib/System.Reflection/ChangeLog

@@ -1,5 +1,9 @@
 2006-09-02  Zoltan Varga  <[email protected]>
 
+	* ParameterInfo.cs MethodInfo.cs MonoMethod.cs: Applied patch from 
+	Peter Dettman ([email protected]). Implement ReturnParameter
+	property.
+
 	* Binder.cs (ReorderParameters): Really fix this.
 	
 	* Binder.cs (ReorderParameters): Fix this method. Fixes #79120.

+ 1 - 1
mcs/class/corlib/System.Reflection/MethodInfo.cs

@@ -101,7 +101,7 @@ namespace System.Reflection {
 
 		public virtual ParameterInfo ReturnParameter {
 			get {
-				throw new NotSupportedException ();				
+				throw new NotSupportedException ();
 			}
 		}
 #endif

+ 8 - 0
mcs/class/corlib/System.Reflection/MonoMethod.cs

@@ -81,6 +81,14 @@ namespace System.Reflection {
 			return get_base_definition (this);
 		}
 
+#if NET_2_0 || BOOTSTRAP_NET_2_0
+		public override ParameterInfo ReturnParameter {
+			get {
+				return new ParameterInfo (ReturnType, this, MonoMethodInfo.get_retval_marshal (mhandle));
+			}
+		}
+#endif
+
 		public override Type ReturnType {
 			get {
 				MonoMethodInfo info;

+ 19 - 1
mcs/class/corlib/System.Reflection/ParameterInfo.cs

@@ -73,7 +73,25 @@ namespace System.Reflection
 			this.AttrsImpl = ParameterAttributes.Retval;
 			this.marshalAs = marshalAs;
 		}
-		
+
+		public override string ToString() {
+			Type elementType = ClassImpl;
+			while (elementType.HasElementType) {
+					elementType = elementType.GetElementType();
+			}
+			bool useShort = elementType.IsPrimitive || ClassImpl == typeof(void)
+				|| ClassImpl.Namespace == MemberImpl.DeclaringType.Namespace;
+			string result = useShort
+				? ClassImpl.Name
+				: ClassImpl.FullName;
+			// MS.NET seems to skip this check and produce an extra space for return types
+			if (!IsRetval) {
+				result += ' ';
+				result += NameImpl;
+			}
+			return result;
+		}
+
 		public virtual Type ParameterType {
 			get {return ClassImpl;}
 		}