From 8177a546ba10c34f40d35c78f4930ea506a83541 Mon Sep 17 00:00:00 2001 From: Jb Evain Date: Thu, 13 Nov 2014 16:28:52 +0100 Subject: On-going work for PCL support --- Mono.Cecil.csproj | 2 +- Mono.Cecil.settings | 26 ++++++++++++--- Mono.Cecil.sln | 30 ++++++++++++++++- Mono.Cecil/AssemblyInfo.cs | 2 ++ Mono.Cecil/ModuleDefinition.cs | 48 +++++++++++++++++----------- Mono.Security.Cryptography/CryptoConvert.cs | 4 +-- ProjectInfo.cs | 2 ++ rocks/Mono.Cecil.Rocks.csproj | 2 +- rocks/Test/Mono.Cecil.Rocks.Tests.csproj | 2 +- symbols/mdb/Mono.Cecil.Mdb.csproj | 2 +- symbols/mdb/Test/Mono.Cecil.Mdb.Tests.csproj | 2 +- symbols/pdb/Mono.Cecil.Pdb.csproj | 2 +- symbols/pdb/Test/Mono.Cecil.Pdb.Tests.csproj | 2 +- 13 files changed, 92 insertions(+), 34 deletions(-) diff --git a/Mono.Cecil.csproj b/Mono.Cecil.csproj index 0a5ea38..662f15b 100644 --- a/Mono.Cecil.csproj +++ b/Mono.Cecil.csproj @@ -139,5 +139,5 @@ - + \ No newline at end of file diff --git a/Mono.Cecil.settings b/Mono.Cecil.settings index c1ca9d3..924b14c 100644 --- a/Mono.Cecil.settings +++ b/Mono.Cecil.settings @@ -11,6 +11,8 @@ $(MSBuildThisFileDirectory)\mono.snk Library $(BuildDirectory)\bin\$(Configuration)\ + False + $(MSBuildToolsPath)\Microsoft.CSharp.targets true @@ -54,11 +56,22 @@ v4.0 $(DefineConstants);NET_3_5;NET_4_0;SILVERLIGHT;CF + + WindowsPhone + Silverlight + v4.0 + $(DefineConstants);NET_3_5;NET_4_0;SILVERLIGHT;CF + + + {786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + Profile158 + v4.0 + $(DefineConstants);NET_3_5;NET_4_0;SILVERLIGHT;PCL + $(MSBuildExtensionsPath32)\Microsoft\Portable\$(TargetFrameworkVersion)\Microsoft.Portable.CSharp.targets + - - - - + + @@ -74,6 +87,8 @@ + + @@ -86,7 +101,8 @@ - + + diff --git a/Mono.Cecil.sln b/Mono.Cecil.sln index bdc8c87..58014e9 100644 --- a/Mono.Cecil.sln +++ b/Mono.Cecil.sln @@ -1,6 +1,6 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 2013 -VisualStudioVersion = 12.0.30723.0 +VisualStudioVersion = 12.0.30501.0 MinimumVisualStudioVersion = 10.0.40219.1 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tests", "Tests", "{74E5ECE0-06B4-401C-AEBA-E8DD53E17943}" EndProject @@ -107,7 +107,6 @@ Global {8559DD7F-A16F-46D0-A05A-9139FAEBA8FD}.net_4_5_Release|Any CPU.ActiveCfg = net_4_5_Release|Any CPU {8559DD7F-A16F-46D0-A05A-9139FAEBA8FD}.net_4_5_Release|Any CPU.Build.0 = net_4_5_Release|Any CPU {8559DD7F-A16F-46D0-A05A-9139FAEBA8FD}.pcl_Debug|Any CPU.ActiveCfg = pcl_Debug|Any CPU - {8559DD7F-A16F-46D0-A05A-9139FAEBA8FD}.pcl_Debug|Any CPU.Build.0 = pcl_Debug|Any CPU {8559DD7F-A16F-46D0-A05A-9139FAEBA8FD}.pcl_Release|Any CPU.ActiveCfg = net_4_0_Release|Any CPU {8559DD7F-A16F-46D0-A05A-9139FAEBA8FD}.pcl_Release|Any CPU.Build.0 = net_4_0_Release|Any CPU {8559DD7F-A16F-46D0-A05A-9139FAEBA8FD}.silverlight_Debug|Any CPU.ActiveCfg = net_4_0_Release|Any CPU @@ -153,7 +152,6 @@ Global {63E6915C-7EA4-4D76-AB28-0D7191EEA626}.net_4_5_Release|Any CPU.ActiveCfg = net_4_5_Release|Any CPU {63E6915C-7EA4-4D76-AB28-0D7191EEA626}.net_4_5_Release|Any CPU.Build.0 = net_4_5_Release|Any CPU {63E6915C-7EA4-4D76-AB28-0D7191EEA626}.pcl_Debug|Any CPU.ActiveCfg = pcl_Debug|Any CPU - {63E6915C-7EA4-4D76-AB28-0D7191EEA626}.pcl_Debug|Any CPU.Build.0 = pcl_Debug|Any CPU {63E6915C-7EA4-4D76-AB28-0D7191EEA626}.pcl_Release|Any CPU.ActiveCfg = net_4_0_Release|Any CPU {63E6915C-7EA4-4D76-AB28-0D7191EEA626}.pcl_Release|Any CPU.Build.0 = net_4_0_Release|Any CPU {63E6915C-7EA4-4D76-AB28-0D7191EEA626}.silverlight_Debug|Any CPU.ActiveCfg = net_4_0_Release|Any CPU @@ -217,7 +215,6 @@ Global {FBC6DD59-D09D-499C-B03C-99C1C78FF2AC}.net_4_5_Release|Any CPU.ActiveCfg = net_4_5_Release|Any CPU {FBC6DD59-D09D-499C-B03C-99C1C78FF2AC}.net_4_5_Release|Any CPU.Build.0 = net_4_5_Release|Any CPU {FBC6DD59-D09D-499C-B03C-99C1C78FF2AC}.pcl_Debug|Any CPU.ActiveCfg = pcl_Debug|Any CPU - {FBC6DD59-D09D-499C-B03C-99C1C78FF2AC}.pcl_Debug|Any CPU.Build.0 = pcl_Debug|Any CPU {FBC6DD59-D09D-499C-B03C-99C1C78FF2AC}.pcl_Release|Any CPU.ActiveCfg = pcl_Release|Any CPU {FBC6DD59-D09D-499C-B03C-99C1C78FF2AC}.pcl_Release|Any CPU.Build.0 = pcl_Release|Any CPU {FBC6DD59-D09D-499C-B03C-99C1C78FF2AC}.silverlight_Debug|Any CPU.ActiveCfg = silverlight_Debug|Any CPU diff --git a/Mono.Cecil/AssemblyDefinition.cs b/Mono.Cecil/AssemblyDefinition.cs index de6ed17..b472d81 100644 --- a/Mono.Cecil/AssemblyDefinition.cs +++ b/Mono.Cecil/AssemblyDefinition.cs @@ -112,6 +112,7 @@ namespace Mono.Cecil { } #endif +#if !PCL public static AssemblyDefinition ReadAssembly (string fileName) { return ReadAssembly (ModuleDefinition.ReadModule (fileName)); @@ -121,6 +122,7 @@ namespace Mono.Cecil { { return ReadAssembly (ModuleDefinition.ReadModule (fileName, parameters)); } +#endif public static AssemblyDefinition ReadAssembly (Stream stream) { diff --git a/Mono.Cecil/AssemblyNameReference.cs b/Mono.Cecil/AssemblyNameReference.cs index 9cacef1..52bcbb4 100644 --- a/Mono.Cecil/AssemblyNameReference.cs +++ b/Mono.Cecil/AssemblyNameReference.cs @@ -109,6 +109,7 @@ namespace Mono.Cecil { byte [] HashPublicKey () { +#if !PCL HashAlgorithm algorithm; switch (hash_algorithm) { @@ -132,6 +133,9 @@ namespace Mono.Cecil { using (algorithm) return algorithm.ComputeHash (public_key); +#else + return new SHA1Managed ().ComputeHash (public_key); +#endif } public virtual MetadataScopeType MetadataScopeType { diff --git a/Mono.Cecil/AssemblyReader.cs b/Mono.Cecil/AssemblyReader.cs index ee667cb..cf7d768 100644 --- a/Mono.Cecil/AssemblyReader.cs +++ b/Mono.Cecil/AssemblyReader.cs @@ -89,8 +89,10 @@ namespace Mono.Cecil { { var symbol_reader_provider = parameters.SymbolReaderProvider; +#if !PCL if (symbol_reader_provider == null && parameters.ReadSymbols) symbol_reader_provider = SymbolProvider.GetPlatformReaderProvider (); +#endif if (symbol_reader_provider != null) { module.SymbolReaderProvider = symbol_reader_provider; @@ -551,6 +553,7 @@ namespace Mono.Cecil { if (attributes != FileAttributes.ContainsMetaData) continue; +#if !PCL var parameters = new ReaderParameters { ReadingMode = module.ReadingMode, SymbolReaderProvider = module.SymbolReaderProvider, @@ -559,11 +562,15 @@ namespace Mono.Cecil { modules.Add (ModuleDefinition.ReadModule ( GetModuleFileName (name), parameters)); +#else + throw new NotSupportedException (); +#endif } return modules; } +#if !PCL string GetModuleFileName (string name) { if (module.FullyQualifiedName == null) @@ -572,6 +579,7 @@ namespace Mono.Cecil { var path = Path.GetDirectoryName (module.FullyQualifiedName); return Path.Combine (path, name); } +#endif void InitializeModuleReferences () { diff --git a/Mono.Cecil/BaseAssemblyResolver.cs b/Mono.Cecil/BaseAssemblyResolver.cs index 76f5da1..691c28b 100644 --- a/Mono.Cecil/BaseAssemblyResolver.cs +++ b/Mono.Cecil/BaseAssemblyResolver.cs @@ -8,6 +8,8 @@ // Licensed under the MIT/X11 license. // +#if !PCL + using System; using System.Collections.Generic; using System.IO; @@ -350,3 +352,5 @@ namespace Mono.Cecil { #endif } } + +#endif diff --git a/Mono.Cecil/DefaultAssemblyResolver.cs b/Mono.Cecil/DefaultAssemblyResolver.cs index a21405b..aa4e278 100644 --- a/Mono.Cecil/DefaultAssemblyResolver.cs +++ b/Mono.Cecil/DefaultAssemblyResolver.cs @@ -8,6 +8,8 @@ // Licensed under the MIT/X11 license. // +#if !PCL + using System; using System.Collections.Generic; @@ -50,3 +52,5 @@ namespace Mono.Cecil { } } } + +#endif diff --git a/Mono.Cecil/Import.cs b/Mono.Cecil/Import.cs index 8a3345a..2e2f230 100644 --- a/Mono.Cecil/Import.cs +++ b/Mono.Cecil/Import.cs @@ -8,6 +8,8 @@ // Licensed under the MIT/X11 license. // +#if !READ_ONLY + using System; using System.Collections.Generic; using Mono.Collections.Generic; @@ -773,3 +775,5 @@ namespace Mono.Cecil { #endif } + +#endif diff --git a/Mono.Cecil/ModuleDefinition.cs b/Mono.Cecil/ModuleDefinition.cs index 134dd99..fac634e 100644 --- a/Mono.Cecil/ModuleDefinition.cs +++ b/Mono.Cecil/ModuleDefinition.cs @@ -343,8 +343,10 @@ namespace Mono.Cecil { public IAssemblyResolver AssemblyResolver { get { +#if !PCL if (assembly_resolver == null) Interlocked.CompareExchange (ref assembly_resolver, new DefaultAssemblyResolver (), null); +#endif return assembly_resolver; } @@ -649,16 +651,28 @@ namespace Mono.Cecil { internal FieldDefinition Resolve (FieldReference field) { +#if PCL + if (MetadataResolver == null) + throw new NotSupportedException (); +#endif return MetadataResolver.Resolve (field); } internal MethodDefinition Resolve (MethodReference method) { +#if PCL + if (MetadataResolver == null) + throw new NotSupportedException (); +#endif return MetadataResolver.Resolve (method); } internal TypeDefinition Resolve (TypeReference type) { +#if PCL + if (MetadataResolver == null) + throw new NotSupportedException (); +#endif return MetadataResolver.Resolve (type); } @@ -972,6 +986,7 @@ namespace Mono.Cecil { #endif +#if !PCL public void ReadSymbols () { if (string.IsNullOrEmpty (fq_name)) @@ -983,6 +998,7 @@ namespace Mono.Cecil { ReadSymbols (provider.GetSymbolReader (this, fq_name)); } +#endif public void ReadSymbols (ISymbolReader reader) { diff --git a/Mono.Security.Cryptography/CryptoService.cs b/Mono.Security.Cryptography/CryptoService.cs index 6f28623..5cb7e0e 100644 --- a/Mono.Security.Cryptography/CryptoService.cs +++ b/Mono.Security.Cryptography/CryptoService.cs @@ -104,6 +104,7 @@ namespace Mono.Cecil { public static byte [] ComputeHash (string file) { +#if !PCL if (!File.Exists (file)) return Empty.Array; @@ -120,6 +121,9 @@ namespace Mono.Cecil { } return sha1.Hash; +#else + return Empty.Array; +#endif } } diff --git a/System.Security.Cryptography/SHA1Managed.cs b/System.Security.Cryptography/SHA1Managed.cs new file mode 100644 index 0000000..a162278 --- /dev/null +++ b/System.Security.Cryptography/SHA1Managed.cs @@ -0,0 +1,373 @@ +// +// System.Security.Cryptography.SHA1CryptoServiceProvider.cs +// +// Authors: +// Matthew S. Ford (Matthew.S.Ford@Rose-Hulman.Edu) +// Sebastien Pouliot (sebastien@ximian.com) +// +// Copyright 2001 by Matthew S. Ford. +// Copyright (C) 2004, 2005, 2008 Novell, Inc (http://www.novell.com) +// +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// + +// Note: +// The MS Framework includes two (almost) identical class for SHA1. +// SHA1Managed is a 100% managed implementation. +// SHA1CryptoServiceProvider (this file) is a wrapper on CryptoAPI. +// Mono must provide those two class for binary compatibility. +// In our case both class are wrappers around a managed internal class SHA1Internal. + +#if PCL + +namespace System.Security.Cryptography { + + internal class SHA1Internal { + + private const int BLOCK_SIZE_BYTES = 64; + private uint[] _H; // these are my chaining variables + private ulong count; + private byte[] _ProcessingBuffer; // Used to start data when passed less than a block worth. + private int _ProcessingBufferCount; // Counts how much data we have stored that still needs processed. + private uint[] buff; + + public SHA1Internal () + { + _H = new uint[5]; + _ProcessingBuffer = new byte[BLOCK_SIZE_BYTES]; + buff = new uint[80]; + + Initialize(); + } + + public void HashCore (byte[] rgb, int ibStart, int cbSize) + { + int i; + + if (_ProcessingBufferCount != 0) { + if (cbSize < (BLOCK_SIZE_BYTES - _ProcessingBufferCount)) { + System.Buffer.BlockCopy (rgb, ibStart, _ProcessingBuffer, _ProcessingBufferCount, cbSize); + _ProcessingBufferCount += cbSize; + return; + } + else { + i = (BLOCK_SIZE_BYTES - _ProcessingBufferCount); + System.Buffer.BlockCopy (rgb, ibStart, _ProcessingBuffer, _ProcessingBufferCount, i); + ProcessBlock (_ProcessingBuffer, 0); + _ProcessingBufferCount = 0; + ibStart += i; + cbSize -= i; + } + } + + for (i = 0; i < cbSize - cbSize % BLOCK_SIZE_BYTES; i += BLOCK_SIZE_BYTES) { + ProcessBlock (rgb, (uint)(ibStart + i)); + } + + if (cbSize % BLOCK_SIZE_BYTES != 0) { + System.Buffer.BlockCopy (rgb, cbSize - cbSize % BLOCK_SIZE_BYTES + ibStart, _ProcessingBuffer, 0, cbSize % BLOCK_SIZE_BYTES); + _ProcessingBufferCount = cbSize % BLOCK_SIZE_BYTES; + } + } + + public byte[] HashFinal () + { + byte[] hash = new byte[20]; + + ProcessFinalBlock (_ProcessingBuffer, 0, _ProcessingBufferCount); + + for (int i=0; i<5; i++) { + for (int j=0; j<4; j++) { + hash [i*4+j] = (byte)(_H[i] >> (8*(3-j))); + } + } + + return hash; + } + + public void Initialize () + { + count = 0; + _ProcessingBufferCount = 0; + + _H[0] = 0x67452301; + _H[1] = 0xefcdab89; + _H[2] = 0x98badcfe; + _H[3] = 0x10325476; + _H[4] = 0xC3D2E1F0; + } + + private void ProcessBlock(byte[] inputBuffer, uint inputOffset) + { + uint a, b, c, d, e; + + count += BLOCK_SIZE_BYTES; + + // abc removal would not work on the fields + uint[] _H = this._H; + uint[] buff = this.buff; + InitialiseBuff(buff, inputBuffer, inputOffset); + FillBuff(buff); + + a = _H[0]; + b = _H[1]; + c = _H[2]; + d = _H[3]; + e = _H[4]; + + // This function was unrolled because it seems to be doubling our performance with current compiler/VM. + // Possibly roll up if this changes. + + // ---- Round 1 -------- + int i=0; + while (i < 20) + { + e += ((a << 5) | (a >> 27)) + (((c ^ d) & b) ^ d) + 0x5A827999 + buff[i]; + b = (b << 30) | (b >> 2); + + d += ((e << 5) | (e >> 27)) + (((b ^ c) & a) ^ c) + 0x5A827999 + buff[i+1]; + a = (a << 30) | (a >> 2); + + c += ((d << 5) | (d >> 27)) + (((a ^ b) & e) ^ b) + 0x5A827999 + buff[i+2]; + e = (e << 30) | (e >> 2); + + b += ((c << 5) | (c >> 27)) + (((e ^ a) & d) ^ a) + 0x5A827999 + buff[i+3]; + d = (d << 30) | (d >> 2); + + a += ((b << 5) | (b >> 27)) + (((d ^ e) & c) ^ e) + 0x5A827999 + buff[i+4]; + c = (c << 30) | (c >> 2); + i += 5; + } + + // ---- Round 2 -------- + while (i < 40) + { + e += ((a << 5) | (a >> 27)) + (b ^ c ^ d) + 0x6ED9EBA1 + buff[i]; + b = (b << 30) | (b >> 2); + + d += ((e << 5) | (e >> 27)) + (a ^ b ^ c) + 0x6ED9EBA1 + buff[i + 1]; + a = (a << 30) | (a >> 2); + + c += ((d << 5) | (d >> 27)) + (e ^ a ^ b) + 0x6ED9EBA1 + buff[i + 2]; + e = (e << 30) | (e >> 2); + + b += ((c << 5) | (c >> 27)) + (d ^ e ^ a) + 0x6ED9EBA1 + buff[i + 3]; + d = (d << 30) | (d >> 2); + + a += ((b << 5) | (b >> 27)) + (c ^ d ^ e) + 0x6ED9EBA1 + buff[i + 4]; + c = (c << 30) | (c >> 2); + i += 5; + } + + // ---- Round 3 -------- + while (i < 60) + { + e += ((a << 5) | (a >> 27)) + ((b & c) | (b & d) | (c & d)) + 0x8F1BBCDC + buff[i]; + b = (b << 30) | (b >> 2); + + d += ((e << 5) | (e >> 27)) + ((a & b) | (a & c) | (b & c)) + 0x8F1BBCDC + buff[i + 1]; + a = (a << 30) | (a >> 2); + + c += ((d << 5) | (d >> 27)) + ((e & a) | (e & b) | (a & b)) + 0x8F1BBCDC + buff[i + 2]; + e = (e << 30) | (e >> 2); + + b += ((c << 5) | (c >> 27)) + ((d & e) | (d & a) | (e & a)) + 0x8F1BBCDC + buff[i + 3]; + d = (d << 30) | (d >> 2); + + a += ((b << 5) | (b >> 27)) + ((c & d) | (c & e) | (d & e)) + 0x8F1BBCDC + buff[i + 4]; + c = (c << 30) | (c >> 2); + i += 5; + } + + // ---- Round 4 -------- + while (i < 80) + { + e += ((a << 5) | (a >> 27)) + (b ^ c ^ d) + 0xCA62C1D6 + buff[i]; + b = (b << 30) | (b >> 2); + + d += ((e << 5) | (e >> 27)) + (a ^ b ^ c) + 0xCA62C1D6 + buff[i + 1]; + a = (a << 30) | (a >> 2); + + c += ((d << 5) | (d >> 27)) + (e ^ a ^ b) + 0xCA62C1D6 + buff[i + 2]; + e = (e << 30) | (e >> 2); + + b += ((c << 5) | (c >> 27)) + (d ^ e ^ a) + 0xCA62C1D6 + buff[i + 3]; + d = (d << 30) | (d >> 2); + + a += ((b << 5) | (b >> 27)) + (c ^ d ^ e) + 0xCA62C1D6 + buff[i + 4]; + c = (c << 30) | (c >> 2); + i += 5; + } + + _H[0] += a; + _H[1] += b; + _H[2] += c; + _H[3] += d; + _H[4] += e; + } + + private static void InitialiseBuff(uint[] buff, byte[] input, uint inputOffset) + { + buff[0] = (uint)((input[inputOffset + 0] << 24) | (input[inputOffset + 1] << 16) | (input[inputOffset + 2] << 8) | (input[inputOffset + 3])); + buff[1] = (uint)((input[inputOffset + 4] << 24) | (input[inputOffset + 5] << 16) | (input[inputOffset + 6] << 8) | (input[inputOffset + 7])); + buff[2] = (uint)((input[inputOffset + 8] << 24) | (input[inputOffset + 9] << 16) | (input[inputOffset + 10] << 8) | (input[inputOffset + 11])); + buff[3] = (uint)((input[inputOffset + 12] << 24) | (input[inputOffset + 13] << 16) | (input[inputOffset + 14] << 8) | (input[inputOffset + 15])); + buff[4] = (uint)((input[inputOffset + 16] << 24) | (input[inputOffset + 17] << 16) | (input[inputOffset + 18] << 8) | (input[inputOffset + 19])); + buff[5] = (uint)((input[inputOffset + 20] << 24) | (input[inputOffset + 21] << 16) | (input[inputOffset + 22] << 8) | (input[inputOffset + 23])); + buff[6] = (uint)((input[inputOffset + 24] << 24) | (input[inputOffset + 25] << 16) | (input[inputOffset + 26] << 8) | (input[inputOffset + 27])); + buff[7] = (uint)((input[inputOffset + 28] << 24) | (input[inputOffset + 29] << 16) | (input[inputOffset + 30] << 8) | (input[inputOffset + 31])); + buff[8] = (uint)((input[inputOffset + 32] << 24) | (input[inputOffset + 33] << 16) | (input[inputOffset + 34] << 8) | (input[inputOffset + 35])); + buff[9] = (uint)((input[inputOffset + 36] << 24) | (input[inputOffset + 37] << 16) | (input[inputOffset + 38] << 8) | (input[inputOffset + 39])); + buff[10] = (uint)((input[inputOffset + 40] << 24) | (input[inputOffset + 41] << 16) | (input[inputOffset + 42] << 8) | (input[inputOffset + 43])); + buff[11] = (uint)((input[inputOffset + 44] << 24) | (input[inputOffset + 45] << 16) | (input[inputOffset + 46] << 8) | (input[inputOffset + 47])); + buff[12] = (uint)((input[inputOffset + 48] << 24) | (input[inputOffset + 49] << 16) | (input[inputOffset + 50] << 8) | (input[inputOffset + 51])); + buff[13] = (uint)((input[inputOffset + 52] << 24) | (input[inputOffset + 53] << 16) | (input[inputOffset + 54] << 8) | (input[inputOffset + 55])); + buff[14] = (uint)((input[inputOffset + 56] << 24) | (input[inputOffset + 57] << 16) | (input[inputOffset + 58] << 8) | (input[inputOffset + 59])); + buff[15] = (uint)((input[inputOffset + 60] << 24) | (input[inputOffset + 61] << 16) | (input[inputOffset + 62] << 8) | (input[inputOffset + 63])); + } + + private static void FillBuff(uint[] buff) + { + uint val; + for (int i = 16; i < 80; i += 8) + { + val = buff[i - 3] ^ buff[i - 8] ^ buff[i - 14] ^ buff[i - 16]; + buff[i] = (val << 1) | (val >> 31); + + val = buff[i - 2] ^ buff[i - 7] ^ buff[i - 13] ^ buff[i - 15]; + buff[i + 1] = (val << 1) | (val >> 31); + + val = buff[i - 1] ^ buff[i - 6] ^ buff[i - 12] ^ buff[i - 14]; + buff[i + 2] = (val << 1) | (val >> 31); + + val = buff[i + 0] ^ buff[i - 5] ^ buff[i - 11] ^ buff[i - 13]; + buff[i + 3] = (val << 1) | (val >> 31); + + val = buff[i + 1] ^ buff[i - 4] ^ buff[i - 10] ^ buff[i - 12]; + buff[i + 4] = (val << 1) | (val >> 31); + + val = buff[i + 2] ^ buff[i - 3] ^ buff[i - 9] ^ buff[i - 11]; + buff[i + 5] = (val << 1) | (val >> 31); + + val = buff[i + 3] ^ buff[i - 2] ^ buff[i - 8] ^ buff[i - 10]; + buff[i + 6] = (val << 1) | (val >> 31); + + val = buff[i + 4] ^ buff[i - 1] ^ buff[i - 7] ^ buff[i - 9]; + buff[i + 7] = (val << 1) | (val >> 31); + } + } + + private void ProcessFinalBlock (byte[] inputBuffer, int inputOffset, int inputCount) + { + ulong total = count + (ulong)inputCount; + int paddingSize = (56 - (int)(total % BLOCK_SIZE_BYTES)); + + if (paddingSize < 1) + paddingSize += BLOCK_SIZE_BYTES; + + int length = inputCount+paddingSize+8; + byte[] fooBuffer = (length == 64) ? _ProcessingBuffer : new byte[length]; + + for (int i=0; i> 56); + buffer [position++] = (byte)(length >> 48); + buffer [position++] = (byte)(length >> 40); + buffer [position++] = (byte)(length >> 32); + buffer [position++] = (byte)(length >> 24); + buffer [position++] = (byte)(length >> 16); + buffer [position++] = (byte)(length >> 8); + buffer [position] = (byte)(length); + } + } + + class SHA1Managed { + + private SHA1Internal sha; + + public SHA1Managed () + { + sha = new SHA1Internal (); + } + + public byte[] ComputeHash (byte[] buffer) + { + if (buffer == null) + throw new ArgumentNullException ("buffer"); + + return ComputeHash (buffer, 0, buffer.Length); + } + + public byte[] ComputeHash (byte[] buffer, int offset, int count) + { + if (buffer == null) + throw new ArgumentNullException ("buffer"); + if (offset < 0) + throw new ArgumentOutOfRangeException ("offset", "< 0"); + if (count < 0) + throw new ArgumentException ("count", "< 0"); + // ordered to avoid possible integer overflow + if (offset > buffer.Length - count) { + throw new ArgumentException ("offset + count", "Overflow"); + } + + HashCore (buffer, offset, count); + var hash_value = HashFinal (); + Initialize (); + + return hash_value; + } + + protected void HashCore (byte[] rgb, int ibStart, int cbSize) + { + sha.HashCore (rgb, ibStart, cbSize); + } + + protected byte[] HashFinal () + { + return sha.HashFinal (); + } + + protected void Initialize () + { + sha.Initialize (); + } + } +} + +#endif -- cgit v1.2.3 From 2cd32880c896bf22566686e5d1ed462c8120bcfa Mon Sep 17 00:00:00 2001 From: Jb Evain Date: Thu, 13 Nov 2014 18:21:43 +0100 Subject: Use the 344 profile --- Mono.Cecil.settings | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Mono.Cecil.settings b/Mono.Cecil.settings index 3a52248..7db12ff 100644 --- a/Mono.Cecil.settings +++ b/Mono.Cecil.settings @@ -64,7 +64,7 @@ {786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} - Profile158 + Profile344 v4.0 $(DefineConstants);NET_3_5;NET_4_0;SILVERLIGHT;PCL;READ_ONLY; $(MSBuildExtensionsPath32)\Microsoft\Portable\$(TargetFrameworkVersion)\Microsoft.Portable.CSharp.targets -- cgit v1.2.3 From ff1110260564d91c9d3e977c345fcbc055bc04dd Mon Sep 17 00:00:00 2001 From: Jb Evain Date: Thu, 28 May 2015 19:17:51 +0200 Subject: Remove support for building against SL and the CF in favor of a PCL --- Mono.Cecil.Cil/Symbols.cs | 2 - Mono.Cecil.settings | 27 +----------- Mono.Cecil.sln | 51 +--------------------- Mono.Cecil/AssemblyDefinition.cs | 11 +++-- Mono.Cecil/AssemblyNameReference.cs | 12 ++--- Mono.Cecil/AssemblyReader.cs | 2 +- Mono.Cecil/AssemblyWriter.cs | 12 ++++- Mono.Cecil/BaseAssemblyResolver.cs | 10 ----- Mono.Cecil/Import.cs | 30 ++----------- Mono.Cecil/MetadataResolver.cs | 4 +- Mono.Cecil/ModuleDefinition.cs | 27 ++++++------ Mono.Cecil/TypeParser.cs | 10 ----- Mono.Security.Cryptography/CryptoConvert.cs | 7 ++- Mono.Security.Cryptography/CryptoService.cs | 6 +-- Mono/Empty.cs | 7 --- ProjectInfo.cs | 2 - rocks/Mono.Cecil.Rocks/SecurityDeclarationRocks.cs | 4 -- 17 files changed, 53 insertions(+), 171 deletions(-) diff --git a/Mono.Cecil.Cil/Symbols.cs b/Mono.Cecil.Cil/Symbols.cs index aed7650..d267c5b 100644 --- a/Mono.Cecil.Cil/Symbols.cs +++ b/Mono.Cecil.Cil/Symbols.cs @@ -195,9 +195,7 @@ namespace Mono.Cecil.Cil { if (assembly != null) return assembly.GetType (fullname); } catch (FileNotFoundException) { -#if !CF } catch (FileLoadException) { -#endif } return null; diff --git a/Mono.Cecil.settings b/Mono.Cecil.settings index 7db12ff..5e6fe65 100644 --- a/Mono.Cecil.settings +++ b/Mono.Cecil.settings @@ -45,28 +45,11 @@ v4.5 $(DefineConstants);NET_3_5;NET_4_0;NET_4_5; - - Silverlight - v4.0 - $(DefineConstants);NET_3_5;NET_4_0;SILVERLIGHT - - - WindowsPhone - Silverlight - v4.0 - $(DefineConstants);NET_3_5;NET_4_0;SILVERLIGHT;CF - - - WindowsPhone - Silverlight - v4.0 - $(DefineConstants);NET_3_5;NET_4_0;SILVERLIGHT;CF - {786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} Profile344 v4.0 - $(DefineConstants);NET_3_5;NET_4_0;SILVERLIGHT;PCL;READ_ONLY; + $(DefineConstants);NET_3_5;NET_4_0;PCL; $(MSBuildExtensionsPath32)\Microsoft\Portable\$(TargetFrameworkVersion)\Microsoft.Portable.CSharp.targets @@ -83,10 +66,6 @@ - - - - @@ -97,10 +76,6 @@ - - - - - - + + - - diff --git a/Mono.Cecil.sln b/Mono.Cecil.sln index f6f85fe..51fef56 100644 --- a/Mono.Cecil.sln +++ b/Mono.Cecil.sln @@ -24,8 +24,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Mono.Cecil.Rocks", "rocks\M EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution - net_2_0_Debug|Any CPU = net_2_0_Debug|Any CPU - net_2_0_Release|Any CPU = net_2_0_Release|Any CPU net_3_5_Debug|Any CPU = net_3_5_Debug|Any CPU net_3_5_Release|Any CPU = net_3_5_Release|Any CPU net_4_0_Debug|Any CPU = net_4_0_Debug|Any CPU @@ -36,10 +34,6 @@ Global pcl_Release|Any CPU = pcl_Release|Any CPU EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {D68133BD-1E63-496E-9EDE-4FBDBF77B486}.net_2_0_Debug|Any CPU.ActiveCfg = net_2_0_Debug|Any CPU - {D68133BD-1E63-496E-9EDE-4FBDBF77B486}.net_2_0_Debug|Any CPU.Build.0 = net_2_0_Debug|Any CPU - {D68133BD-1E63-496E-9EDE-4FBDBF77B486}.net_2_0_Release|Any CPU.ActiveCfg = net_2_0_Release|Any CPU - {D68133BD-1E63-496E-9EDE-4FBDBF77B486}.net_2_0_Release|Any CPU.Build.0 = net_2_0_Release|Any CPU {D68133BD-1E63-496E-9EDE-4FBDBF77B486}.net_3_5_Debug|Any CPU.ActiveCfg = net_3_5_Debug|Any CPU {D68133BD-1E63-496E-9EDE-4FBDBF77B486}.net_3_5_Debug|Any CPU.Build.0 = net_3_5_Debug|Any CPU {D68133BD-1E63-496E-9EDE-4FBDBF77B486}.net_3_5_Release|Any CPU.ActiveCfg = net_3_5_Release|Any CPU @@ -56,10 +50,6 @@ Global {D68133BD-1E63-496E-9EDE-4FBDBF77B486}.pcl_Debug|Any CPU.Build.0 = pcl_Debug|Any CPU {D68133BD-1E63-496E-9EDE-4FBDBF77B486}.pcl_Release|Any CPU.ActiveCfg = pcl_Release|Any CPU {D68133BD-1E63-496E-9EDE-4FBDBF77B486}.pcl_Release|Any CPU.Build.0 = pcl_Release|Any CPU - {A47B1F49-A81A-43E8-BE6B-DD28AF2C4055}.net_2_0_Debug|Any CPU.ActiveCfg = net_2_0_Debug|Any CPU - {A47B1F49-A81A-43E8-BE6B-DD28AF2C4055}.net_2_0_Debug|Any CPU.Build.0 = net_2_0_Debug|Any CPU - {A47B1F49-A81A-43E8-BE6B-DD28AF2C4055}.net_2_0_Release|Any CPU.ActiveCfg = net_2_0_Release|Any CPU - {A47B1F49-A81A-43E8-BE6B-DD28AF2C4055}.net_2_0_Release|Any CPU.Build.0 = net_2_0_Release|Any CPU {A47B1F49-A81A-43E8-BE6B-DD28AF2C4055}.net_3_5_Debug|Any CPU.ActiveCfg = net_3_5_Debug|Any CPU {A47B1F49-A81A-43E8-BE6B-DD28AF2C4055}.net_3_5_Debug|Any CPU.Build.0 = net_3_5_Debug|Any CPU {A47B1F49-A81A-43E8-BE6B-DD28AF2C4055}.net_3_5_Release|Any CPU.ActiveCfg = net_3_5_Release|Any CPU @@ -74,10 +64,6 @@ Global {A47B1F49-A81A-43E8-BE6B-DD28AF2C4055}.net_4_5_Release|Any CPU.Build.0 = net_4_5_Release|Any CPU {A47B1F49-A81A-43E8-BE6B-DD28AF2C4055}.pcl_Debug|Any CPU.ActiveCfg = net_4_0_Debug|Any CPU {A47B1F49-A81A-43E8-BE6B-DD28AF2C4055}.pcl_Release|Any CPU.ActiveCfg = net_4_0_Release|Any CPU - {8559DD7F-A16F-46D0-A05A-9139FAEBA8FD}.net_2_0_Debug|Any CPU.ActiveCfg = net_2_0_Debug|Any CPU - {8559DD7F-A16F-46D0-A05A-9139FAEBA8FD}.net_2_0_Debug|Any CPU.Build.0 = net_2_0_Debug|Any CPU - {8559DD7F-A16F-46D0-A05A-9139FAEBA8FD}.net_2_0_Release|Any CPU.ActiveCfg = net_2_0_Release|Any CPU - {8559DD7F-A16F-46D0-A05A-9139FAEBA8FD}.net_2_0_Release|Any CPU.Build.0 = net_2_0_Release|Any CPU {8559DD7F-A16F-46D0-A05A-9139FAEBA8FD}.net_3_5_Debug|Any CPU.ActiveCfg = net_3_5_Debug|Any CPU {8559DD7F-A16F-46D0-A05A-9139FAEBA8FD}.net_3_5_Debug|Any CPU.Build.0 = net_3_5_Debug|Any CPU {8559DD7F-A16F-46D0-A05A-9139FAEBA8FD}.net_3_5_Release|Any CPU.ActiveCfg = net_3_5_Release|Any CPU @@ -92,10 +78,6 @@ Global {8559DD7F-A16F-46D0-A05A-9139FAEBA8FD}.net_4_5_Release|Any CPU.Build.0 = net_4_5_Release|Any CPU {8559DD7F-A16F-46D0-A05A-9139FAEBA8FD}.pcl_Debug|Any CPU.ActiveCfg = pcl_Debug|Any CPU {8559DD7F-A16F-46D0-A05A-9139FAEBA8FD}.pcl_Release|Any CPU.ActiveCfg = net_4_0_Release|Any CPU - {AC71DF9C-99FA-4A63-990A-66C8010355A6}.net_2_0_Debug|Any CPU.ActiveCfg = net_2_0_Debug|Any CPU - {AC71DF9C-99FA-4A63-990A-66C8010355A6}.net_2_0_Debug|Any CPU.Build.0 = net_2_0_Debug|Any CPU - {AC71DF9C-99FA-4A63-990A-66C8010355A6}.net_2_0_Release|Any CPU.ActiveCfg = net_2_0_Release|Any CPU - {AC71DF9C-99FA-4A63-990A-66C8010355A6}.net_2_0_Release|Any CPU.Build.0 = net_2_0_Release|Any CPU {AC71DF9C-99FA-4A63-990A-66C8010355A6}.net_3_5_Debug|Any CPU.ActiveCfg = net_3_5_Debug|Any CPU {AC71DF9C-99FA-4A63-990A-66C8010355A6}.net_3_5_Debug|Any CPU.Build.0 = net_3_5_Debug|Any CPU {AC71DF9C-99FA-4A63-990A-66C8010355A6}.net_3_5_Release|Any CPU.ActiveCfg = net_3_5_Release|Any CPU @@ -110,10 +92,6 @@ Global {AC71DF9C-99FA-4A63-990A-66C8010355A6}.net_4_5_Release|Any CPU.Build.0 = net_4_5_Release|Any CPU {AC71DF9C-99FA-4A63-990A-66C8010355A6}.pcl_Debug|Any CPU.ActiveCfg = net_4_0_Debug|Any CPU {AC71DF9C-99FA-4A63-990A-66C8010355A6}.pcl_Release|Any CPU.ActiveCfg = net_4_0_Release|Any CPU - {63E6915C-7EA4-4D76-AB28-0D7191EEA626}.net_2_0_Debug|Any CPU.ActiveCfg = net_2_0_Debug|Any CPU - {63E6915C-7EA4-4D76-AB28-0D7191EEA626}.net_2_0_Debug|Any CPU.Build.0 = net_2_0_Debug|Any CPU - {63E6915C-7EA4-4D76-AB28-0D7191EEA626}.net_2_0_Release|Any CPU.ActiveCfg = net_2_0_Release|Any CPU - {63E6915C-7EA4-4D76-AB28-0D7191EEA626}.net_2_0_Release|Any CPU.Build.0 = net_2_0_Release|Any CPU {63E6915C-7EA4-4D76-AB28-0D7191EEA626}.net_3_5_Debug|Any CPU.ActiveCfg = net_3_5_Debug|Any CPU {63E6915C-7EA4-4D76-AB28-0D7191EEA626}.net_3_5_Debug|Any CPU.Build.0 = net_3_5_Debug|Any CPU {63E6915C-7EA4-4D76-AB28-0D7191EEA626}.net_3_5_Release|Any CPU.ActiveCfg = net_3_5_Release|Any CPU @@ -128,10 +106,6 @@ Global {63E6915C-7EA4-4D76-AB28-0D7191EEA626}.net_4_5_Release|Any CPU.Build.0 = net_4_5_Release|Any CPU {63E6915C-7EA4-4D76-AB28-0D7191EEA626}.pcl_Debug|Any CPU.ActiveCfg = pcl_Debug|Any CPU {63E6915C-7EA4-4D76-AB28-0D7191EEA626}.pcl_Release|Any CPU.ActiveCfg = net_4_0_Release|Any CPU - {29300103-CB76-4A1D-B6FD-FFD91C1EC8AA}.net_2_0_Debug|Any CPU.ActiveCfg = net_2_0_Debug|Any CPU - {29300103-CB76-4A1D-B6FD-FFD91C1EC8AA}.net_2_0_Debug|Any CPU.Build.0 = net_2_0_Debug|Any CPU - {29300103-CB76-4A1D-B6FD-FFD91C1EC8AA}.net_2_0_Release|Any CPU.ActiveCfg = net_2_0_Release|Any CPU - {29300103-CB76-4A1D-B6FD-FFD91C1EC8AA}.net_2_0_Release|Any CPU.Build.0 = net_2_0_Release|Any CPU {29300103-CB76-4A1D-B6FD-FFD91C1EC8AA}.net_3_5_Debug|Any CPU.ActiveCfg = net_3_5_Debug|Any CPU {29300103-CB76-4A1D-B6FD-FFD91C1EC8AA}.net_3_5_Debug|Any CPU.Build.0 = net_3_5_Debug|Any CPU {29300103-CB76-4A1D-B6FD-FFD91C1EC8AA}.net_3_5_Release|Any CPU.ActiveCfg = net_3_5_Release|Any CPU @@ -146,8 +120,6 @@ Global {29300103-CB76-4A1D-B6FD-FFD91C1EC8AA}.net_4_5_Release|Any CPU.Build.0 = net_4_5_Release|Any CPU {29300103-CB76-4A1D-B6FD-FFD91C1EC8AA}.pcl_Debug|Any CPU.ActiveCfg = net_4_0_Debug|Any CPU {29300103-CB76-4A1D-B6FD-FFD91C1EC8AA}.pcl_Release|Any CPU.ActiveCfg = net_4_0_Release|Any CPU - {C6CFD7E1-B855-44DC-B4CE-9CD72984AF52}.net_2_0_Debug|Any CPU.ActiveCfg = net_4_0_Debug|Any CPU - {C6CFD7E1-B855-44DC-B4CE-9CD72984AF52}.net_2_0_Release|Any CPU.ActiveCfg = net_4_0_Release|Any CPU {C6CFD7E1-B855-44DC-B4CE-9CD72984AF52}.net_3_5_Debug|Any CPU.ActiveCfg = net_3_5_Debug|Any CPU {C6CFD7E1-B855-44DC-B4CE-9CD72984AF52}.net_3_5_Debug|Any CPU.Build.0 = net_3_5_Debug|Any CPU {C6CFD7E1-B855-44DC-B4CE-9CD72984AF52}.net_3_5_Release|Any CPU.ActiveCfg = net_3_5_Release|Any CPU @@ -162,8 +134,6 @@ Global {C6CFD7E1-B855-44DC-B4CE-9CD72984AF52}.net_4_5_Release|Any CPU.Build.0 = net_4_5_Release|Any CPU {C6CFD7E1-B855-44DC-B4CE-9CD72984AF52}.pcl_Debug|Any CPU.ActiveCfg = net_4_0_Debug|Any CPU {C6CFD7E1-B855-44DC-B4CE-9CD72984AF52}.pcl_Release|Any CPU.ActiveCfg = net_4_0_Release|Any CPU - {FBC6DD59-D09D-499C-B03C-99C1C78FF2AC}.net_2_0_Debug|Any CPU.ActiveCfg = net_4_0_Debug|Any CPU - {FBC6DD59-D09D-499C-B03C-99C1C78FF2AC}.net_2_0_Release|Any CPU.ActiveCfg = net_4_0_Release|Any CPU {FBC6DD59-D09D-499C-B03C-99C1C78FF2AC}.net_3_5_Debug|Any CPU.ActiveCfg = net_3_5_Debug|Any CPU {FBC6DD59-D09D-499C-B03C-99C1C78FF2AC}.net_3_5_Debug|Any CPU.Build.0 = net_3_5_Debug|Any CPU {FBC6DD59-D09D-499C-B03C-99C1C78FF2AC}.net_3_5_Release|Any CPU.ActiveCfg = net_3_5_Release|Any CPU diff --git a/Mono/Actions.cs b/Mono/Actions.cs deleted file mode 100644 index fdc9bdf..0000000 --- a/Mono/Actions.cs +++ /dev/null @@ -1,20 +0,0 @@ -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// Copyright (c) 2008 - 2015 Jb Evain -// Copyright (c) 2008 - 2011 Novell, Inc. -// -// Licensed under the MIT/X11 license. -// - -#if !NET_3_5 && !NET_4_0 - -namespace Mono { - //delegate void Action (); - delegate void Action (T1 arg1, T2 arg2); - //delegate void Action (T1 arg1, T2 arg2, T3 arg3); - //delegate void Action (T1 arg1, T2 arg2, T3 arg3, T4 arg4); -} - -#endif diff --git a/Mono/Funcs.cs b/Mono/Funcs.cs deleted file mode 100644 index 9e2de16..0000000 --- a/Mono/Funcs.cs +++ /dev/null @@ -1,21 +0,0 @@ -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// Copyright (c) 2008 - 2015 Jb Evain -// Copyright (c) 2008 - 2011 Novell, Inc. -// -// Licensed under the MIT/X11 license. -// - -#if !NET_3_5 && !NET_4_0 - -namespace Mono { - delegate TResult Func (); - delegate TResult Func (T arg1); - delegate TResult Func (T1 arg1, T2 arg2); - //delegate TResult Func (T1 arg1, T2 arg2, T3 arg3); - //delegate TResult Func (T1 arg1, T2 arg2, T3 arg3, T4 arg4); -} - -#endif diff --git a/System.Runtime.CompilerServices/ExtensionAttribute.cs b/System.Runtime.CompilerServices/ExtensionAttribute.cs deleted file mode 100644 index 5b85f12..0000000 --- a/System.Runtime.CompilerServices/ExtensionAttribute.cs +++ /dev/null @@ -1,22 +0,0 @@ -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// Copyright (c) 2008 - 2015 Jb Evain -// Copyright (c) 2008 - 2011 Novell, Inc. -// -// Licensed under the MIT/X11 license. -// - -using System; - -#if !NET_3_5 && !NET_4_0 - -namespace System.Runtime.CompilerServices { - - [AttributeUsage (AttributeTargets.Method | AttributeTargets.Class | AttributeTargets.Assembly)] - sealed class ExtensionAttribute : Attribute { - } -} - -#endif diff --git a/Test/Mono.Cecil.Tests.csproj b/Test/Mono.Cecil.Tests.csproj index ca324f3..6559511 100644 --- a/Test/Mono.Cecil.Tests.csproj +++ b/Test/Mono.Cecil.Tests.csproj @@ -19,7 +19,6 @@ - diff --git a/Test/Mono.Cecil.Tests/Linq.cs b/Test/Mono.Cecil.Tests/Linq.cs deleted file mode 100644 index 4f870e0..0000000 --- a/Test/Mono.Cecil.Tests/Linq.cs +++ /dev/null @@ -1,47 +0,0 @@ -using System; -using System.Collections.Generic; - -using Mono; - -#if !NET_3_5 && !NET_4_0 - -namespace System.Linq { - - static class Enumerable { - - public static IEnumerable Select (this IEnumerable self, Func selector) - { - foreach (var item in self) - yield return selector (item); - } - - public static IEnumerable Where (this IEnumerable self, Func predicate) - { - foreach (var item in self) - if (predicate (item)) - yield return item; - } - - public static List ToList (this IEnumerable self) - { - return new List (self); - } - - public static T [] ToArray (this IEnumerable self) - { - return self.ToList ().ToArray (); - } - - public static T First (this IEnumerable self) - { - using (var enumerator = self.GetEnumerator ()) { - if (!enumerator.MoveNext ()) - throw new InvalidOperationException (); - - return enumerator.Current; - } - } - } -} - -#endif diff --git a/symbols/pdb/Test/Mono.Cecil.Pdb.Tests.csproj b/symbols/pdb/Test/Mono.Cecil.Pdb.Tests.csproj index b3544b5..bdd6fc5 100644 --- a/symbols/pdb/Test/Mono.Cecil.Pdb.Tests.csproj +++ b/symbols/pdb/Test/Mono.Cecil.Pdb.Tests.csproj @@ -20,7 +20,6 @@ - diff --git a/symbols/pdb/Test/Mono.Cecil.Tests/Linq.cs b/symbols/pdb/Test/Mono.Cecil.Tests/Linq.cs deleted file mode 100644 index 0950ce1..0000000 --- a/symbols/pdb/Test/Mono.Cecil.Tests/Linq.cs +++ /dev/null @@ -1,47 +0,0 @@ -using System; -using System.Collections.Generic; - -#if !NET_3_5 && !NET_4_0 - -namespace System { - - delegate TResult Func (T t); -} - -namespace System.Runtime.CompilerServices { - - [AttributeUsage (AttributeTargets.Method | AttributeTargets.Class | AttributeTargets.Assembly)] - sealed class ExtensionAttribute : Attribute { - } -} - -namespace System.Linq { - - static class Enumerable { - - public static IEnumerable Select (this IEnumerable self, Func selector) - { - foreach (var item in self) - yield return selector (item); - } - - public static IEnumerable Where (this IEnumerable self, Func predicate) - { - foreach (var item in self) - if (predicate (item)) - yield return item; - } - - public static T First (this IEnumerable self) - { - using (var enumerator = self.GetEnumerator ()) { - if (!enumerator.MoveNext ()) - throw new InvalidOperationException (); - - return enumerator.Current; - } - } - } -} - -#endif -- cgit v1.2.3