Author: gert
Date: 2006-10-19 16:32:06 -0400 (Thu, 19 Oct 2006)
New Revision: 66822

Modified:
   trunk/mcs/class/corlib/System.Reflection/AssemblyName.cs
   trunk/mcs/class/corlib/System.Reflection/ChangeLog
   trunk/mcs/class/corlib/Test/System.Reflection/AssemblyNameTest.cs
   trunk/mcs/class/corlib/Test/System.Reflection/ChangeLog
Log:
* AssemblyName.cs: Revert change where filename was not converted to
absolute path before passing it to Assembly.InternalGetAssemblyName
as the CodeBase is not set in that case.
* AssemblyNameTest.cs: Added test for CodeBase of AssemblyName
filled by AssemblyName.GetAssemblyName. Added tests for bug #79661.


Modified: trunk/mcs/class/corlib/System.Reflection/AssemblyName.cs
===================================================================
--- trunk/mcs/class/corlib/System.Reflection/AssemblyName.cs    2006-10-19 
17:03:43 UTC (rev 66821)
+++ trunk/mcs/class/corlib/System.Reflection/AssemblyName.cs    2006-10-19 
20:32:06 UTC (rev 66822)
@@ -317,7 +317,7 @@
                                throw new ArgumentNullException 
("assemblyFile");
 
                        AssemblyName aname = new AssemblyName ();
-                       Assembly.InternalGetAssemblyName (assemblyFile, aname);
+                       Assembly.InternalGetAssemblyName (Path.GetFullPath 
(assemblyFile), aname);
                        return aname;
                }
 

Modified: trunk/mcs/class/corlib/System.Reflection/ChangeLog
===================================================================
--- trunk/mcs/class/corlib/System.Reflection/ChangeLog  2006-10-19 17:03:43 UTC 
(rev 66821)
+++ trunk/mcs/class/corlib/System.Reflection/ChangeLog  2006-10-19 20:32:06 UTC 
(rev 66822)
@@ -1,3 +1,9 @@
+2006-10-19  Gert Driesen  <[EMAIL PROTECTED]>
+
+       * AssemblyName.cs: Revert change where filename was not converted to
+       absolute path before passing it to Assembly.InternalGetAssemblyName
+       as the CodeBase is not set in that case.
+
 2006-10-17  Kornél Pál  <[EMAIL PROTECTED]>
 
        * FieldInfo.cs: Added GetRawConstantValue (). Note that throwing a

Modified: trunk/mcs/class/corlib/Test/System.Reflection/AssemblyNameTest.cs
===================================================================
--- trunk/mcs/class/corlib/Test/System.Reflection/AssemblyNameTest.cs   
2006-10-19 17:03:43 UTC (rev 66821)
+++ trunk/mcs/class/corlib/Test/System.Reflection/AssemblyNameTest.cs   
2006-10-19 20:32:06 UTC (rev 66822)
@@ -474,7 +474,7 @@
        public void GetObjectData_Null ()
        {
                AssemblyName an = new AssemblyName ();
-               an.GetObjectData (null, new StreamingContext 
(StreamingContextStates.All));
+               an.GetObjectData (null, new StreamingContext 
(StreamingContextStates.All));
        }
 
        [Test]
@@ -501,7 +501,7 @@
                Assert.IsNull (clone.Version, "Version");
                Assert.AreEqual (AssemblyVersionCompatibility.SameMachine, 
                        clone.VersionCompatibility, "VersionCompatibility");
-       }
+       }
 
        [Test]
        public void Clone_Self ()
@@ -519,8 +519,55 @@
                Assert.AreEqual (an.Name, clone.Name, "Name");
                Assert.AreEqual (an.Version, clone.Version, "Version");
                Assert.AreEqual (an.VersionCompatibility, 
clone.VersionCompatibility, "VersionCompatibility");
-       }
+       }
 
+       [Test]
+       [ExpectedException (typeof (FileNotFoundException))]
+       public void GetAssemblyName_AssemblyFile_DoesNotExist ()
+       {
+               AssemblyName.GetAssemblyName (Path.Combine (tempDir, 
"doesnotexist.dll"));
+       }
+
+       [Test]
+       [Category ("NotWorking")]
+       public void GetAssemblyName_AssemblyFile_LoadFailure ()
+       {
+               string file = Path.Combine (tempDir, "loadfailure.dll");
+               using (FileStream fs = File.Open (file, FileMode.OpenOrCreate, 
FileAccess.Read, FileShare.None)) {
+                       try {
+                               AssemblyName.GetAssemblyName (file);
+                               Assert.Fail ("#1");
+                       } catch (FileLoadException ex) {
+                       }
+               }
+               File.Delete (file);
+       }
+
+       [Test]
+       public void GetAssemblyName_AssemblyFile_BadImage ()
+       {
+               string file = Path.Combine (tempDir, "badimage.dll");
+               using (StreamWriter sw = File.CreateText (file)) {
+                       sw.WriteLine ("somegarbage");
+               }
+               try {
+                       AssemblyName.GetAssemblyName (file);
+                       Assert.Fail ("#1");
+               } catch (BadImageFormatException ex) {
+               }
+               File.Delete (file);
+       }
+
+       [Test]
+       public void GetAssemblyName_CodeBase ()
+       {
+               Assembly execAssembly = Assembly.GetExecutingAssembly ();
+
+               AssemblyName aname = AssemblyName.GetAssemblyName 
(execAssembly.Location);
+               Assert.IsNotNull (aname.CodeBase, "#1");
+               Assert.AreEqual (execAssembly.CodeBase, aname.CodeBase, "#2");
+       }
+
        // helpers
 
        private string GetTokenString (byte[] value)


Property changes on: 
trunk/mcs/class/corlib/Test/System.Reflection/AssemblyNameTest.cs
___________________________________________________________________
Name: svn:eol-style
   + native

Modified: trunk/mcs/class/corlib/Test/System.Reflection/ChangeLog
===================================================================
--- trunk/mcs/class/corlib/Test/System.Reflection/ChangeLog     2006-10-19 
17:03:43 UTC (rev 66821)
+++ trunk/mcs/class/corlib/Test/System.Reflection/ChangeLog     2006-10-19 
20:32:06 UTC (rev 66822)
@@ -1,3 +1,8 @@
+2006-10-19  Gert Driesen  <[EMAIL PROTECTED]>
+
+       * AssemblyNameTest.cs: Added test for CodeBase of AssemblyName
+       filled by AssemblyName.GetAssemblyName. Added tests for bug #79661.
+
 2006-09-29  Jb Evain  <[EMAIL PROTECTED]>
 
        * FieldInfoTest.cs: Test for FieldInfo.SetValue on a literal field.

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to