Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fix writing of delay-signed assemblies

  • Loading branch information...
commit 7d9999c60bd538a19a84f1211064ef104f07ee82 1 parent fb8dcba
@jbevain authored
View
1  Mono.Cecil.PE/Image.cs
@@ -52,6 +52,7 @@ sealed class Image {
public DataDirectory Debug;
public DataDirectory Resources;
+ public DataDirectory StrongName;
public StringHeap StringHeap;
public BlobHeap BlobHeap;
View
1  Mono.Cecil.PE/ImageReader.cs
@@ -322,6 +322,7 @@ void ReadCLIHeader ()
// Resources 8
image.Resources = ReadDataDirectory ();
// StrongNameSignature 8
+ image.StrongName = ReadDataDirectory ();
// CodeManagerTable 8
// VTableFixups 8
// ExportAddressTableJumps 8
View
5 Mono.Cecil.PE/ImageWriter.cs
@@ -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;
View
8 Mono.Cecil/AssemblyWriter.cs
@@ -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);
View
8 Test/Mono.Cecil.Tests/ImageReadTests.cs
@@ -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);
+ }
}
}
View
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.