Skip to content
This repository
Browse code

Fix writing of delay-signed assemblies

  • Loading branch information...
commit 7d9999c60bd538a19a84f1211064ef104f07ee82 1 parent fb8dcba
Jb Evain authored
1  Mono.Cecil.PE/Image.cs
@@ -52,6 +52,7 @@ sealed class Image {
52 52
53 53 public DataDirectory Debug;
54 54 public DataDirectory Resources;
  55 + public DataDirectory StrongName;
55 56
56 57 public StringHeap StringHeap;
57 58 public BlobHeap BlobHeap;
1  Mono.Cecil.PE/ImageReader.cs
@@ -322,6 +322,7 @@ void ReadCLIHeader ()
322 322 // Resources 8
323 323 image.Resources = ReadDataDirectory ();
324 324 // StrongNameSignature 8
  325 + image.StrongName = ReadDataDirectory ();
325 326 // CodeManagerTable 8
326 327 // VTableFixups 8
327 328 // ExportAddressTableJumps 8
5 Mono.Cecil.PE/ImageWriter.cs
@@ -750,11 +750,8 @@ int GetMetadataHeaderLength ()
750 750
751 751 int GetStrongNameLength ()
752 752 {
753   - if ((module.Attributes & ModuleAttributes.StrongNameSigned) == 0)
754   - return 0;
755   -
756 753 if (module.Assembly == null)
757   - throw new InvalidOperationException ();
  754 + return 0;
758 755
759 756 var public_key = module.Assembly.Name.PublicKey;
760 757
8 Mono.Cecil/AssemblyWriter.cs
@@ -97,13 +97,11 @@ public static void WriteModuleTo (ModuleDefinition module, Stream stream, Writer
97 97 var symbol_writer = GetSymbolWriter (module, fq_name, symbol_writer_provider);
98 98
99 99 #if !SILVERLIGHT && !CF
100   - if (parameters.StrongNameKeyPair != null && name != null)
  100 + if (parameters.StrongNameKeyPair != null && name != null) {
101 101 name.PublicKey = parameters.StrongNameKeyPair.PublicKey;
102   -#endif
103   -
104   - if (name != null && name.HasPublicKey)
105 102 module.Attributes |= ModuleAttributes.StrongNameSigned;
106   -
  103 + }
  104 +#endif
107 105 var metadata = new MetadataBuilder (module, fq_name,
108 106 symbol_writer_provider, symbol_writer);
109 107
8 Test/Mono.Cecil.Tests/ImageReadTests.cs
@@ -115,5 +115,13 @@ public void AnyCpuModule (ModuleDefinition module)
115 115 Assert.AreEqual (TargetArchitecture.I386, module.Image.Architecture);
116 116 Assert.AreEqual (ModuleAttributes.ILOnly, module.Image.Attributes);
117 117 }
  118 +
  119 + [TestModule ("delay-signed.dll")]
  120 + public void DelaySignedAssembly (ModuleDefinition module)
  121 + {
  122 + Assert.AreNotEqual (ModuleAttributes.StrongNameSigned, module.Attributes & ModuleAttributes.StrongNameSigned);
  123 + Assert.AreNotEqual (0, module.Image.StrongName.VirtualAddress);
  124 + Assert.AreNotEqual (0, module.Image.StrongName.Size);
  125 + }
118 126 }
119 127 }
BIN  Test/Resources/assemblies/delay-signed.dll
Binary file not shown

0 comments on commit 7d9999c

Please sign in to comment.
Something went wrong with that request. Please try again.