[Mono-devel-list] Re: [Mono-patches] r45553 - trunk/mcs/class/corlib/System.Reflection

Martin Baulig martin at ximian.com
Mon Jun 6 23:37:51 EDT 2005


Hi,

please do not commit such patches to corlib without first testing them.

There is an open bug report (#75136) about this issue, but we can't just
keep the build broken until that's fixed.

Thanks,
Martin

On Mon, 2005-06-06 at 20:14 -0400, Carlos Alberto Cortes  wrote:
> Author: calberto
> Date: 2005-06-06 20:14:13 -0400 (Mon, 06 Jun 2005)
> New Revision: 45553
> 
> Modified:
>    trunk/mcs/class/corlib/System.Reflection/ChangeLog
>    trunk/mcs/class/corlib/System.Reflection/CustomAttributeData.cs
>    trunk/mcs/class/corlib/System.Reflection/CustomAttributeNamedArgument.cs
>    trunk/mcs/class/corlib/System.Reflection/CustomAttributeTypedArgument.cs
> Log:
> 2005-06-07  Carlos Alberto Cortez <calberto.cortez at gmail.com>
> 
> 	* CustomAttributeData.cs: Implemented.
> 
> 	* CustomAttributeDataNamedArgument.cs: Implemented.
> 
> 	* CustomAttrbuteDataTypedArgument.cs: Implemented.
> 	
> 
> 
> Modified: trunk/mcs/class/corlib/System.Reflection/ChangeLog
> ===================================================================
> --- trunk/mcs/class/corlib/System.Reflection/ChangeLog	2005-06-07 00:12:21 UTC (rev 45552)
> +++ trunk/mcs/class/corlib/System.Reflection/ChangeLog	2005-06-07 00:14:13 UTC (rev 45553)
> @@ -1,3 +1,11 @@
> +2005-06-07  Carlos Alberto Cortez <calberto.cortez at gmail.com>
> +
> +	* CustomAttributeData.cs: Implemented.
> +
> +	* CustomAttributeDataNamedArgument.cs: Implemented.
> +
> +	* CustomAttrbuteDataTypedArgument.cs: Implemented.
> +	
>  2005-06-06  Zoltan Varga  <vargaz at freemail.hu>
>  
>  	* Assembly.cs ExceptionHandlingClause.cs: Fix build.
> 
> Modified: trunk/mcs/class/corlib/System.Reflection/CustomAttributeData.cs
> ===================================================================
> --- trunk/mcs/class/corlib/System.Reflection/CustomAttributeData.cs	2005-06-07 00:12:21 UTC (rev 45552)
> +++ trunk/mcs/class/corlib/System.Reflection/CustomAttributeData.cs	2005-06-07 00:14:13 UTC (rev 45553)
> @@ -3,6 +3,7 @@
>  //
>  // Author:
>  //   Zoltan Varga (vargaz at gmail.com)
> +//   Carlos Alberto Cortez (calberto.cortez at gmail.com)
>  //
>  // Copyright (C) 2004 Novell, Inc (http://www.novell.com)
>  //
> @@ -32,6 +33,7 @@
>  using System.Collections.Generic;
>  using System.Runtime.CompilerServices;
>  using System.Runtime.InteropServices;
> +using System.Text;
>  
>  namespace System.Reflection {
>  
> @@ -39,47 +41,87 @@
>  	[ComVisible (true)]
>  #endif
>  	public sealed class CustomAttributeData {
> +		ConstructorInfo ctorInfo;
> +		IList<CustomAttributeTypedArgument> ctorArgs;
> +		IList<CustomAttributeNamedArgument> namedArgs;
>  
> -		[MonoTODO]
> +		internal CustomAttributeData (ConstructorInfo ctorInfo, object [] ctorArgs, object [] namedArgs)
> +		{
> +			this.ctorInfo = ctorInfo;
> +			
> +			this.ctorArgs = Array.AsReadOnly<CustomAttributeTypedArgument> 
> +				(ctorArgs != null ? UnboxValues<CustomAttributeTypedArgument> (ctorArgs) : new CustomAttributeTypedArgument [0]);
> +			
> +			this.namedArgs = Array.AsReadOnly<CustomAttributeNamedArgument> 
> +				(namedArgs != null ? UnboxValues<CustomAttributeNamedArgument> (namedArgs) : new CustomAttributeNamedArgument [0]);
> +		}
> +
>  		public ConstructorInfo Constructor {
>  			get {
> -				throw new NotImplementedException ();
> +				return ctorInfo;
>  			}
>  		}
>  
> -		[MonoTODO]
>  		public IList<CustomAttributeTypedArgument> ConstructorArguments {
>  			get {
> -				throw new NotImplementedException ();
> +				return ctorArgs;
>  			}
>  		}
>  
> -		[MonoTODO]
>  		public IList<CustomAttributeNamedArgument> NamedArguments {
>  			get {
> -				throw new NotImplementedException ();
> +				return namedArgs;
>  			}
>  		}
>  
> -		[MonoTODO]
> -		public static IList<CustomAttributeData> GetCustomAttributes (Assembly yarget) {
> -			throw new NotImplementedException ();
> +		public static IList<CustomAttributeData> GetCustomAttributes (Assembly target) {
> +			return MonoCustomAttrs.GetCustomAttributesData (target);
>  		}
>  
> -		[MonoTODO]
>  		public static IList<CustomAttributeData> GetCustomAttributes (MemberInfo target) {
> -			throw new NotImplementedException ();
> +			return MonoCustomAttrs.GetCustomAttributesData (target);
>  		}
>  
> -		[MonoTODO]
>  		public static IList<CustomAttributeData> GetCustomAttributes (Module target) {
> -			throw new NotImplementedException ();
> +			return MonoCustomAttrs.GetCustomAttributesData (target);
>  		}
>  
> -		[MonoTODO]
>  		public static IList<CustomAttributeData> GetCustomAttributes (ParameterInfo target) {
> -			throw new NotImplementedException ();
> +			return MonoCustomAttrs.GetCustomAttributesData (target);
>  		}
> +
> +		public override string ToString ()
> +		{
> +			StringBuilder sb = new StringBuilder ();
> +
> +			sb.Append ("[" + ctorInfo.DeclaringType.Name + " (");
> +			for (int i = 0; i < ctorArgs.Count; i++) {
> +				sb.Append (ctorArgs [i].ToString ());
> +				if (i + 1 < ctorArgs.Count)
> +					sb.Append (", ");
> +			}
> +
> +			if (namedArgs.Count > 0)
> +				sb.Append (", ");
> +			
> +			for (int j = 0; j < namedArgs.Count; j++) {
> +				sb.Append (namedArgs [j].ToString ());
> +				if (j + 1 < namedArgs.Count)
> +					sb.Append (", ");
> +			}
> +			sb.AppendFormat (")]");
> +
> +			return sb.ToString ();
> +		}
> +
> +		static T [] UnboxValues<T> (object [] values)
> +		{
> +			T [] retval = new T [values.Length];
> +			for (int i = 0; i < values.Length; i++)
> +				retval [i] = (T) values [i];
> +
> +			return retval;
> +		}
>  	}
>  
>  }
> 
> Modified: trunk/mcs/class/corlib/System.Reflection/CustomAttributeNamedArgument.cs
> ===================================================================
> --- trunk/mcs/class/corlib/System.Reflection/CustomAttributeNamedArgument.cs	2005-06-07 00:12:21 UTC (rev 45552)
> +++ trunk/mcs/class/corlib/System.Reflection/CustomAttributeNamedArgument.cs	2005-06-07 00:14:13 UTC (rev 45553)
> @@ -3,6 +3,7 @@
>  //
>  // Author:
>  //   Zoltan Varga (vargaz at gmail.com)
> +//   Carlos Alberto Cortez (calberto.cortez at gmail.com)
>  //
>  // Copyright (C) 2004 Novell, Inc (http://www.novell.com)
>  //
> @@ -37,20 +38,31 @@
>  	[ComVisible (true)]
>  #endif
>  	public struct CustomAttributeNamedArgument {
> +		CustomAttributeTypedArgument typedArgument;
> +		MemberInfo memberInfo;
>  
> -		[MonoTODO]
> +		internal CustomAttributeNamedArgument (MemberInfo memberInfo, object typedArgument)
> +		{
> +			this.memberInfo = memberInfo;
> +			this.typedArgument = (CustomAttributeTypedArgument) typedArgument;
> +		}
> +
>  		public MemberInfo MemberInfo {
>  			get {
> -				throw new NotImplementedException ();
> +				return memberInfo;
>  			}
>  		}
>  
> -		[MonoTODO]
>  		public CustomAttributeTypedArgument TypedValue {
>  			get {
> -				throw new NotImplementedException ();
> +				return typedArgument;
>  			}
>  		}
> +
> +		public override string ToString ()
> +		{
> +			return memberInfo.Name + " = " + typedArgument.ToString ();
> +		}
>  	}
>  
>  }
> 
> Modified: trunk/mcs/class/corlib/System.Reflection/CustomAttributeTypedArgument.cs
> ===================================================================
> --- trunk/mcs/class/corlib/System.Reflection/CustomAttributeTypedArgument.cs	2005-06-07 00:12:21 UTC (rev 45552)
> +++ trunk/mcs/class/corlib/System.Reflection/CustomAttributeTypedArgument.cs	2005-06-07 00:14:13 UTC (rev 45553)
> @@ -3,6 +3,7 @@
>  //
>  // Author:
>  //   Zoltan Varga (vargaz at gmail.com)
> +//   Carlos Alberto Cortez (calberto.cortez at gmail.com)
>  //
>  // Copyright (C) 2004 Novell, Inc (http://www.novell.com)
>  //
> @@ -37,20 +38,37 @@
>  	[ComVisible (true)]
>  #endif
>  	public struct CustomAttributeTypedArgument {
> +		Type argumentType;
> +		object value;
>  
> -		[MonoTODO]
> +		internal CustomAttributeTypedArgument (Type argumentType, object value)
> +		{
> +			this.argumentType = argumentType;
> +			this.value = value;
> +		}
> +
>  		public Type ArgumentType {
>  			get {
> -				throw new NotImplementedException ();
> +				return argumentType;
>  			}
>  		}
>  
> -		[MonoTODO]
>  		public object Value {
>  			get {
> -				throw new NotImplementedException ();
> +				return value;
>  			}
>  		}
> +
> +		public override string ToString ()
> +		{
> +			string val = value.ToString ();
> +			if (argumentType == typeof (string))
> +				return "\"" + val + "\"";
> +			if (argumentType == typeof (Type)) 
> +				return "typeof (" + val + ")";
> +
> +			return val;
> +		}
>  	}
>  
>  }
> 
> _______________________________________________
> Mono-patches maillist  -  Mono-patches at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-patches
> 




More information about the Mono-devel-list mailing list