diff options
author | Jb Evain <jb@evain.net> | 2015-05-28 20:33:19 +0300 |
---|---|---|
committer | Jb Evain <jb@evain.net> | 2015-05-28 20:33:19 +0300 |
commit | 283b47606318a5f3e2d5f88c81212bea105025ef (patch) | |
tree | cb5910b2f489f2dd7b91a34d90771111a1f257e6 | |
parent | ff1110260564d91c9d3e977c345fcbc055bc04dd (diff) |
Simplify ifdefing out of CryptoService
-rw-r--r-- | Mono.Cecil/AssemblyWriter.cs | 8 | ||||
-rw-r--r-- | Mono.Security.Cryptography/CryptoService.cs | 21 |
2 files changed, 13 insertions, 16 deletions
diff --git a/Mono.Cecil/AssemblyWriter.cs b/Mono.Cecil/AssemblyWriter.cs index 2ba1c5a..b96d42d 100644 --- a/Mono.Cecil/AssemblyWriter.cs +++ b/Mono.Cecil/AssemblyWriter.cs @@ -993,10 +993,12 @@ namespace Mono.Cecil { uint AddLinkedResource (LinkedResource resource) { var table = GetTable<FileTable> (Table.File); + var hash = resource.Hash; - var hash = resource.Hash.IsNullOrEmpty () - ? CryptoService.ComputeHash (resource.File) - : resource.Hash; +#if !PCL + if (hash.IsNullOrEmpty ()) + hash = CryptoService.ComputeHash (resource.File); +#endif return (uint) table.AddRow (new FileRow ( FileAttributes.ContainsNoMetaData, diff --git a/Mono.Security.Cryptography/CryptoService.cs b/Mono.Security.Cryptography/CryptoService.cs index cc3afc3..8d76ad7 100644 --- a/Mono.Security.Cryptography/CryptoService.cs +++ b/Mono.Security.Cryptography/CryptoService.cs @@ -8,17 +8,17 @@ // Licensed under the MIT/X11 license. // +#if !READ_ONLY + +#if !PCL + using System; using System.IO; using System.Reflection; using System.Security.Cryptography; - -#if !READ_ONLY - -#if !PCL using System.Runtime.Serialization; + using Mono.Security.Cryptography; -#endif using Mono.Cecil.PE; @@ -30,7 +30,6 @@ namespace Mono.Cecil { static class CryptoService { -#if !PCL public static void StrongName (Stream stream, ImageWriter writer, StrongNameKeyPair key_pair) { int strong_name_pointer; @@ -92,7 +91,7 @@ namespace Mono.Cecil { return sha1.Hash; } -#endif + static void CopyStreamChunk (Stream stream, Stream dest_stream, byte [] buffer, int length) { while (length > 0) { @@ -104,7 +103,6 @@ namespace Mono.Cecil { public static byte [] ComputeHash (string file) { -#if !PCL if (!File.Exists (file)) return Empty<byte>.Array; @@ -121,13 +119,9 @@ namespace Mono.Cecil { } return sha1.Hash; -#else - return Empty<byte>.Array; -#endif } } -#if !PCL static partial class Mixin { public static RSA CreateRSA (this StrongNameKeyPair key_pair) @@ -157,7 +151,8 @@ namespace Mono.Cecil { return key_container != null; } } -#endif } #endif + +#endif |