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 [EMAIL PROTECTED] http://bugzilla.ximian.com/show_bug.cgi?id=77098 --- shadow/77098 2005-12-27 05:26:44.000000000 -0500 +++ shadow/77098.tmp.5501 2005-12-27 05:26:44.000000000 -0500 @@ -0,0 +1,96 @@ +Bug#: 77098 +Product: Mono: Class Libraries +Version: 1.0 +OS: +OS Details: Windows XP SP2 +Status: NEW +Resolution: +Severity: +Priority: Blocker +Component: CORLIB +AssignedTo: [EMAIL PROTECTED] +ReportedBy: [EMAIL PROTECTED] +QAContact: [EMAIL PROTECTED] +TargetMilestone: --- +URL: +Cc: +Summary: FileStream's position gets changed by implicit and explicit flushing + +Description of Problem: +I'm not sure if that is really a bug, but at least the MS .NET Framework's +FileStream behaves exactly the way would I expect. That means flushing of +FileStream, either explicit (i.e. by calling Flush() method) or implicit +(i.e. by calling get_Length) doesn't change the file pointer. + +Steps to reproduce the problem: +1. Creating a FileStream (new file) with buffering +2. Write data to the FileStream which is smaller than the buffer +3. Set position of the FileStream to 0 +4. Do something which explicitely or implicitely causes flushing of the +buffer (like query file size (get_Length) or calling Flush() method) + +Actual Results: +FileStream's position is at the end of the file + +Expected Results: +FileStream's position should be 0 + +How often does this happen? +Always + +Additional Information: +Here are 2 tests that demonstrates the problem. + +[Test] +public void TestPositionAfterImplicitFlushProblem() +{ + using (FileStreamEx fs = new FileStreamEx(Path.Combine(TempFolder, +"TestSetPositionImplicitFlushProblem.dat"), + FileMode.Create, + FileAccess.ReadWrite, + FileShare.None, + 8192)) + { + byte[] buffer1 = new byte[100]; + byte[] buffer2 = new byte[buffer1.Length]; + + for (int index = 0; (index < buffer1.Length); index++) + buffer1[index] = (byte)(index & 0xff); + + fs.Write(buffer1, 0, buffer1.Length); + fs.Position = 0; + + Assert.AreEqual(fs.Length, 100); // Implicit flushing + + Assert.AreEqual(fs.Position, 0); + Assert.AreEqual(fs.Read(buffer2, 0, buffer2.Length), buffer2.Length); + Assert.AreEqual(buffer1, buffer2); + } +} + +[Test] +public void TestPositionAfterExplicitFlushProblem() +{ + using (FileStreamEx fs = new FileStreamEx(Path.Combine(TempFolder, +"TestPositionAfterExplicitFlushProblem.dat"), + FileMode.Create, + FileAccess.ReadWrite, + FileShare.None, + 8192)) + { + byte[] buffer1 = new byte[100]; + byte[] buffer2 = new byte[buffer1.Length]; + + for (int index = 0; (index < buffer1.Length); index++) + buffer1[index] = (byte)(index & 0xff); + + fs.Write(buffer1, 0, buffer1.Length); + fs.Position = 0; + + fs.Flush(); // Explicit flushing + + Assert.AreEqual(fs.Position, 0); + Assert.AreEqual(fs.Read(buffer2, 0, buffer2.Length), buffer2.Length); + Assert.AreEqual(buffer1, buffer2); + } +} _______________________________________________ mono-bugs maillist - [email protected] http://lists.ximian.com/mailman/listinfo/mono-bugs
