[Mono-list] BUG in mcs

Erik Bagfors erik@bagfors.nu
25 Jul 2002 22:03:03 +0200


--=-0Wr5z+GY3uQ0x223Yp4G
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

On Thu, 2002-07-25 at 16:02, Paolo Molaro wrote:
> On 07/25/02 Erik Bagfors wrote:
> > For some reason I can't get bugzilla to mail me my password. It says it
> > does but I never get it.  So I can't put this in bugzilla.
> [...]
> I filed it in bugzilla for you.
>=20
> > BTW, I saw that the attribute "Name" is missing in System.IO.FileStream
> > as well.  That's real easy to fix.  Will someone or should I send in a
> > patch?
>=20
> A patch + test case is always the best thing:-)
>=20

Ok, here you go. I don't have NUnit or whatever you are using for
testing.  I guess I should install that for the future.  So the test is
a separate application but I'm sure it's like 30 seconds of work for
someone who knows the testing-framework.

Warning I haven't tried this code since I was unable to recompile
corelib.  But it's so easy it should just work :)

/Erik - who just got mono to use 100% CPU without wanting to die on kill
-9 :)

--=20
Erik B=E5gfors               | erik@bagfors.nu
Supporter of free software | GSM +46 733 279 273
fingerprint: 6666 A85B 95D3 D26B 296B 6C60 4F32 2C0B 693D 6E32

--=-0Wr5z+GY3uQ0x223Yp4G
Content-Disposition: attachment; filename=FileStream.patch
Content-Transfer-Encoding: quoted-printable
Content-Type: text/x-diff; name=FileStream.patch; charset=ISO-8859-1

Index: FileStream.cs
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: /mono/mcs/class/corlib/System.IO/FileStream.cs,v
retrieving revision 1.17
diff -u -r1.17 FileStream.cs
--- FileStream.cs	12 Jul 2002 15:58:59 -0000	1.17
+++ FileStream.cs	25 Jul 2002 19:56:58 -0000
@@ -60,6 +60,8 @@
 			if (name =3D=3D "" || name.IndexOfAny (Path.InvalidPathChars) !=3D -1)=0D
 				throw new ArgumentException ();=0D
=20=0D
+			this.name =3D name;=0D
+=0D
 			// TODO: demand permissions=0D
=20=0D
 			this.handle =3D MonoIO.Open (name, mode, access, share);=0D
@@ -95,6 +97,12 @@
                         }=0D
                 }=0D
=20=0D
+		public string Name {=0D
+			get {=0D
+				return name;=20=0D
+			}=0D
+		}=0D
+=0D
 		public override long Length {=0D
 			get { return MonoIO.GetLength (handle); }=0D
 		}=0D
@@ -333,6 +341,7 @@
 		private int buf_offset;			// position of next byte=0D
 		private bool buf_dirty;			// true if buffer has been written to=0D
 		private long buf_start;			// location of buffer in file=0D
+		private string name =3D "[Unknown]";	// name of file.=0D
=20=0D
 		IntPtr handle;				// handle to underlying file=0D
 	}=0D

--=-0Wr5z+GY3uQ0x223Yp4G
Content-Disposition: attachment; filename=FileStream-name-test.cs
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain; name=FileStream-name-test.cs; charset=ISO-8859-1

using System;=0D
using System.IO;=0D
=0D
class MainClass=0D
{=0D
	public static void Main(string[] args)=0D
	{=0D
		Console.WriteLine("Hello World!");=0D
		FileStream fs =3D new FileStream("/etc/passwd", FileMode.Open);=0D
		Console.WriteLine(fs.Name); // Should write the name of the file=0D
		IntPtr ip =3D fs.Handle;=0D
		FileStream fs2 =3D new FileStream (ip,FileAccess.Read);=0D
		Console.WriteLine(fs2.Name); // Should write [Unknown] (Like the MS-versi=
on does)=0D
	}=0D
}=0D
=0D

--=-0Wr5z+GY3uQ0x223Yp4G--