Permalink
Browse files

Fix writing of delay-signed assemblies

  • Loading branch information...
1 parent fb8dcba commit 7d9999c60bd538a19a84f1211064ef104f07ee82 @jbevain committed Mar 28, 2012
View
@@ -52,6 +52,7 @@ sealed class Image {
public DataDirectory Debug;
public DataDirectory Resources;
+ public DataDirectory StrongName;
public StringHeap StringHeap;
public BlobHeap BlobHeap;
@@ -322,6 +322,7 @@ void ReadCLIHeader ()
// Resources 8
image.Resources = ReadDataDirectory ();
// StrongNameSignature 8
+ image.StrongName = ReadDataDirectory ();
// CodeManagerTable 8
// VTableFixups 8
// ExportAddressTableJumps 8
@@ -750,11 +750,8 @@ int GetMetadataHeaderLength ()
int GetStrongNameLength ()
{
- if ((module.Attributes & ModuleAttributes.StrongNameSigned) == 0)
- return 0;
-
if (module.Assembly == null)
- throw new InvalidOperationException ();
+ return 0;
var public_key = module.Assembly.Name.PublicKey;
@@ -97,13 +97,11 @@ public static void WriteModuleTo (ModuleDefinition module, Stream stream, Writer
var symbol_writer = GetSymbolWriter (module, fq_name, symbol_writer_provider);
#if !SILVERLIGHT && !CF
- if (parameters.StrongNameKeyPair != null && name != null)
+ if (parameters.StrongNameKeyPair != null && name != null) {
name.PublicKey = parameters.StrongNameKeyPair.PublicKey;
-#endif
-
- if (name != null && name.HasPublicKey)
module.Attributes |= ModuleAttributes.StrongNameSigned;
-
+ }
+#endif
var metadata = new MetadataBuilder (module, fq_name,
symbol_writer_provider, symbol_writer);
@@ -115,5 +115,13 @@ public void AnyCpuModule (ModuleDefinition module)
Assert.AreEqual (TargetArchitecture.I386, module.Image.Architecture);
Assert.AreEqual (ModuleAttributes.ILOnly, module.Image.Attributes);
}
+
+ [TestModule ("delay-signed.dll")]
+ public void DelaySignedAssembly (ModuleDefinition module)
+ {
+ Assert.AreNotEqual (ModuleAttributes.StrongNameSigned, module.Attributes & ModuleAttributes.StrongNameSigned);
+ Assert.AreNotEqual (0, module.Image.StrongName.VirtualAddress);
+ Assert.AreNotEqual (0, module.Image.StrongName.Size);
+ }
}
}
Binary file not shown.

0 comments on commit 7d9999c

Please sign in to comment.