[Mono-bugs] [Bug 59623][Nor] New - Regex.Matches method does not return correct results.

bugzilla-daemon@bugzilla.ximian.com bugzilla-daemon@bugzilla.ximian.com
Fri, 4 Jun 2004 22:50:24 -0400 (EDT)


Please do not reply to this email- if you want to comment on the bug, go to the
URL shown below and enter your comments there.

Changed by claytonharbour@sporadicism.com.

http://bugzilla.ximian.com/show_bug.cgi?id=59623

--- shadow/59623	2004-06-04 22:50:24.000000000 -0400
+++ shadow/59623.tmp.3993	2004-06-04 22:50:24.000000000 -0400
@@ -0,0 +1,91 @@
+Bug#: 59623
+Product: Mono: Class Libraries
+Version: unspecified
+OS: Red Hat 9.0
+OS Details: Fedora Core 1
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Normal
+Component: System
+AssignedTo: mono-bugs@ximian.com                            
+ReportedBy: claytonharbour@sporadicism.com               
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: Regex.Matches method does not return correct results.
+
+Please fill in this template when reporting a bug, unless you know what you
+are doing.
+Description of Problem:
+
+
+Steps to reproduce the problem:
+1. Use following test case:
+
+using System;
+using System.IO;
+using System.Text.RegularExpressions;
+using NUnit.Framework;
+
+namespace MyNamespace {
+    [TestFixture]
+    public class MatchesTest {
+    
+	public static void Main (String[] args) {
+		MatchesTest matchesTest = new MatchesTest ();
+		matchesTest.ParseProject();
+	}
+
+        [Test]    
+        public void ParseProject () {
+            string pattern =
+@"Project\(\""(?<package>\{.*?\})\"".*?\""(?<name>.*?)\"".*?\""(?<project>.*?)\"".*?\""(?<guid>.*?)\""(?<all>[\s\S]*?)EndProject";
+
+            Regex reProjects = new Regex(pattern);
+            string fileContents = this.ReadFileContents(new
+FileInfo("Gentle.NET.sln"));
+            MatchCollection projectMatches = reProjects.Matches(fileContents);
+
+            Console.WriteLine(String.Format("Found {0} projects.",
+projectMatches.Count));
+            Assertion.Assert(String.Format("Found {0} projects.",
+projectMatches.Count), projectMatches.Count > 0);
+        }
+        
+        public string ReadFileContents (FileInfo file) {
+            string fileContents;
+
+            using (StreamReader sr = new StreamReader(file.FullName)) {
+                fileContents = sr.ReadToEnd();
+            }
+            return fileContents;
+        }
+
+    }
+    
+}
+
+2. I used the Gentle.Net.sln file
+(http://www.mertner.com/viewcvs/*checkout*/projects/gentle/Source/Gentle.NET.sln?rev=403&content-type=text/plain)
+but any .sln file could be used here.
+3. Expect the MatchCollection to be populated but it is not.
+
+Actual Results:
+
+Running against Gentle.Net.sln () the Count is 14.
+
+
+Expected Results:
+
+Running against Gentle.Net.sln () the Count is 0.
+
+How often does this happen? 
+
+Always when using the Matches method.  Parsing the regular expression using
+the Match() method does seem to work.
+
+Additional Information:
+
+Tested on Mono Beta 2, this works under ms .net sdk 1.1.