[Mono-dev] System.Type.GetTypeCode null arg failure

Zoltan Varga vargaz at gmail.com
Thu Oct 13 17:46:56 EDT 2005


            Hi,

  Applied. Thanks.

         Zoltan

On 10/12/05, Mike Welham <mwelham at gmail.com> wrote:
> I tried repeatedly to file this in bugzilla, but she was having none of it.
>
> Description of Problem:
> -----------------------
>
> System.Type.GetTypeCode(Type) throws a NullRef exception when its arg is
> null. Microsoft's implementation returns TypeCode.Empty
>
> Steps to reproduce the problem:
> -------------------------------
>
> using System;
> public class TestHost {
>         static void Main() {
>                 if(Type.GetTypeCode(null) != TypeCode.Empty)
>                         throw new Exception();
>         }
> }
>
> Actual Results:
> ---------------
>
> NullReferenceException thrown
>
> Expected Results:
> -----------------
>
> TypeCode.Empty returned
>
> How often does this happen?
> ---------------------------
>
> Always
>
> Additional Information:
> -----------------------
>
> -- patch --
>
> Index: class/corlib/System/Type.cs
> ===================================================================
> --- class/corlib/System/Type.cs (revision 51657)
> +++ class/corlib/System/Type.cs (working copy)
> @@ -468,6 +468,9 @@
>                  internal extern static TypeCode GetTypeCodeInternal
> (Type type);
>
>                  public static TypeCode GetTypeCode (Type type) {
> +                       if(type == null)
> +                               return TypeCode.Empty;
> +
>                          type = type.UnderlyingSystemType;
>
>                          if (!type.IsSystemType)
>
> -- end patch --
>
>
> Mike
> _______________________________________________
> Mono-devel-list mailing list
> Mono-devel-list at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-devel-list
>



More information about the Mono-devel-list mailing list