2004-01-27 Zoltan Varga <vargaz@freemail.hu>
authorZoltan Varga <vargaz@gmail.com>
Tue, 27 Jan 2004 14:49:55 +0000 (14:49 -0000)
committerZoltan Varga <vargaz@gmail.com>
Tue, 27 Jan 2004 14:49:55 +0000 (14:49 -0000)
* AssemblyBuilder.cs (SetCustomAttribute): Move the reading of the
keyfile to the Save () method.

svn path=/trunk/mcs/; revision=22540

mcs/class/corlib/System.Reflection.Emit/AssemblyBuilder.cs
mcs/class/corlib/System.Reflection.Emit/ChangeLog

index cb25d5a229cfee7c2e6ce3e1dc5c2ea6767f7e63..6ef9e7e6b44ed335978d6fd3ab86f845f87061cb 100755 (executable)
@@ -85,6 +85,7 @@ namespace System.Reflection.Emit {
                Win32VersionResource version_res;
                bool created;
                bool is_module_only;
+               string keyfile_name;
                private Mono.Security.StrongName sn;
 
                [MethodImplAttribute(MethodImplOptions.InternalCall)]
@@ -566,6 +567,19 @@ namespace System.Reflection.Emit {
 
                        if (version_res != null)
                                DefineVersionInfoResourceImpl (assemblyFileName);
+
+                       if ((keyfile_name != null) && (keyfile_name != String.Empty)) {
+                               using (FileStream fs = new FileStream (keyfile_name, FileMode.Open)) {
+                                       byte[] snkeypair = new byte [fs.Length];
+                                       fs.Read (snkeypair, 0, snkeypair.Length);
+
+                                       // this will import public or private/public keys
+                                       RSA rsa = CryptoConvert.FromCapiKeyBlob (snkeypair);
+                                       // and export only the public part
+                                       sn = new Mono.Security.StrongName (rsa);
+                                       public_key = sn.PublicKey;
+                               }
+                       }
                        
                        foreach (ModuleBuilder module in modules)
                                if (module != mainModule)
@@ -612,19 +626,7 @@ namespace System.Reflection.Emit {
                                version = create_assembly_version (customBuilder.string_arg ());
                                return;
                        } else if (attrname == "System.Reflection.AssemblyKeyFileAttribute") {
-                               string keyfile_name = customBuilder.string_arg ();
-                               if (keyfile_name == String.Empty)
-                                       return;
-                               using (FileStream fs = new FileStream (keyfile_name, FileMode.Open)) {
-                                       byte[] snkeypair = new byte [fs.Length];
-                                       fs.Read (snkeypair, 0, snkeypair.Length);
-
-                                       // this will import public or private/public keys
-                                       RSA rsa = CryptoConvert.FromCapiKeyBlob (snkeypair);
-                                       // and export only the public part
-                                       sn = new Mono.Security.StrongName (rsa);
-                                       public_key = sn.PublicKey;
-                               }
+                               keyfile_name = customBuilder.string_arg ();
                                return;
                        } else if (attrname == "System.Reflection.AssemblyKeyNameAttribute") {
                                string key_name = customBuilder.string_arg ();
index 8bc531aacaf6b35af5da6bb44683b28d4769186a..fe84550bbb4239c41b5176b0e6334670c21c46d7 100644 (file)
@@ -1,3 +1,8 @@
+2004-01-27  Zoltan Varga  <vargaz@freemail.hu>
+
+       * AssemblyBuilder.cs (SetCustomAttribute): Move the reading of the
+       keyfile to the Save () method.
+
 2004-01-26  Sebastien Pouliot  <spouliot@videotron.ca>
 
        * AssemblyBuilder.cs: Save will now strongname the assembly is (a) a