[Mono-list] Regex Exception - Discrepancy between .NET and Mono

Matt Lee thatismatt at gmail.com
Mon Feb 16 05:30:16 EST 2009


Dear All,
The simple class below throws an exception, but under .NET
an ArgumentNullException is thrown, whereas under Mono
a NullReferenceException is thrown.

using System.Text.RegularExpressions;

public class Program
{
    public static void Main(string[] args)
    {
        var r = new Regex("");
        r.Match(null);
    }
}

I spotted this because the stack trace contained line references that
weren't on my machine:

Unhandled Exception: System.NullReferenceException: Object reference not set
to an instance of an object
  at System.Text.RegularExpressions.Regex.Match (System.String input, Int32
startat) [0x00000]
    in
C:\cygwin\tmp\monobuild\build\BUILD\mono-2.2\mcs\build\common\Consts.cs:1
  at System.Text.RegularExpressions.Regex.Match (System.String input)
[0x00000]
    in
C:\cygwin\tmp\monobuild\build\BUILD\mono-2.2\mcs\class\System\System.Text.RegularExpressions\Regex.cs:337
  at Program.Main (System.String[] args) [0x00000]

For reference the .NET stack trace is below:

Unhandled Exception: System.ArgumentNullException: Value cannot be null.
Parameter name: input
   at System.Text.RegularExpressions.Regex.Match(String input)
   at Program.Main(String[] args)

Should I file a bug about this? Or do we not really!

Thanks,
Matt
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ximian.com/pipermail/mono-list/attachments/20090216/0ea9ca37/attachment.html 


More information about the Mono-list mailing list