Skip to content
This repository has been archived by the owner on Mar 19, 2021. It is now read-only.

Commit

Permalink
Assume that if the construction of a strong-name key pair fails when …
Browse files Browse the repository at this point in the history
…the assembly is delaysigned it is because the assembly's KeyBlob represents just the public key and not the pair.
  • Loading branch information
mike-barnett committed Nov 20, 2018
1 parent 2c25832 commit 31bba1d
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions System.Compiler/Writer.cs
Expand Up @@ -5366,7 +5366,7 @@ internal static void WritePE(System.CodeDom.Compiler.CompilerParameters/*!*/ com
}
try
{
assem.PublicKeyOrToken = Writer.GetPublicKey(assem);
assem.PublicKeyOrToken = Writer.GetPublicKey(assem, delaySign);
}
catch (ArgumentException ex)
{
Expand All @@ -5393,10 +5393,21 @@ internal static void WritePE(System.CodeDom.Compiler.CompilerParameters/*!*/ com
}
}
}
private static byte[] GetPublicKey(AssemblyNode/*!*/ assem) {
private static byte[] GetPublicKey(AssemblyNode/*!*/ assem, bool delaySign) {
Debug.Assert(assem != null);
if (assem.KeyContainerName != null) return new Reflection.StrongNameKeyPair(assem.KeyContainerName).PublicKey;
if (assem.KeyBlob != null) return new Reflection.StrongNameKeyPair(assem.KeyBlob).PublicKey;
if (assem.KeyContainerName != null) {
return new Reflection.StrongNameKeyPair(assem.KeyContainerName).PublicKey;
}
if (assem.KeyBlob != null) {
try {
return new Reflection.StrongNameKeyPair(assem.KeyBlob).PublicKey;
} catch {
if (delaySign)
return assem.KeyBlob;
else
throw;
}
}
return assem.PublicKeyOrToken;
}

Expand Down

0 comments on commit 31bba1d

Please sign in to comment.