Hey Ivan,

Thanks for the patch!

Do you have an assembly that shows your issue, so we can integrate it
in the unit tests suite?

On 9/18/07, Ivan <[EMAIL PROTECTED]> wrote:
>
> Using monomerge.exe I found occasions when Cecil would attempt to set
> MethodReturnType's MetadataToken, Constant & MarshalSpec values where
> the background ParameterDefinition storage object didn't exist. These
> setters would dereference a null and throw an exception.
>
> There is code in MethodReturnType to create this empty
> ParameterDefinition, but relied on CustomAttributes getter being
> called.
>
> Without having too much background in Cecil, I found it made sense to
> move this into the Parameter property and reference its getter.
> This appeared to fix my problem (at least in initial testing).
>
> diff -u3 -r org\Mono.Cecil/Mono.Cecil/MethodReturnType.cs Mono.Cecil/
> Mono.Cecil/MethodReturnType.cs
> --- org\Mono.Cecil/Mono.Cecil/MethodReturnType.cs       2007-07-13
> 08:28:50.000000000 +1000
> +++ Mono.Cecil/Mono.Cecil/MethodReturnType.cs   2007-09-18
> 15:48:14.154426600 +1000
> @@ -50,25 +50,25 @@
>                 }
>
>                 internal ParameterDefinition Parameter {
> -                       get { return m_param; }
> +                       get {
> +                               if (m_param == null)
> +                               {
> +                                       m_param = new ParameterDefinition(
> +                                               string.Empty, 0, 
> (ParameterAttributes)0, m_returnType);
> +                                       m_param.Method = m_method;
> +                               }
> +                               return m_param;
> +                       }
>                         set { m_param = value; }
>                 }
>
>                 public MetadataToken MetadataToken {
>                         get { return m_param.MetadataToken; }
> -                       set { m_param.MetadataToken = value; }
> +                       set { Parameter.MetadataToken = value; }
>                 }
>
>                 public CustomAttributeCollection CustomAttributes {
> -                       get {
> -                               if (m_param == null) {
> -                                       m_param = new ParameterDefinition (
> -                                               string.Empty, 0, 
> (ParameterAttributes) 0, m_returnType);
> -                                       m_param.Method = m_method;
> -                               }
> -
> -                               return m_param.CustomAttributes;
> -                       }
> +                       get { return Parameter.CustomAttributes; }
>                 }
>
>                 public bool HasConstant {
> @@ -87,9 +87,7 @@
>
>                                 return m_param.Constant;
>                         }
> -                       set {
> -                               m_param.Constant = value;
> -                       }
> +                       set { Parameter.Constant = value; }
>                 }
>
>                 public MarshalSpec MarshalSpec {
> @@ -99,7 +97,7 @@
>
>                                 return m_param.MarshalSpec;
>                         }
> -                       set { m_param.MarshalSpec = value; }
> +                       set { Parameter.MarshalSpec = value; }
>                 }
>
>                 public MethodReturnType (TypeReference retType)
>
>
> >
>


-- 
Jb Evain  <[EMAIL PROTECTED]>

--~--~---------~--~----~------------~-------~--~----~
--
mono-cecil
-~----------~----~----~----~------~----~------~--~---

Reply via email to