diff options
author | Jb Evain <jbevain@gmail.com> | 2015-07-30 17:08:03 +0300 |
---|---|---|
committer | Jb Evain <jbevain@gmail.com> | 2015-07-30 17:08:03 +0300 |
commit | 12f981e0b482d7dce21c2efa935c9f4d5cbed8b3 (patch) | |
tree | b0be3b18d3329a6c8d1e96fc903f38ad655f6ce9 | |
parent | 569e764367245064a2d4a168eb7178918f34830c (diff) | |
parent | 3b21b22e454faec782d1b21ad1e98b88fd297a2a (diff) |
Merge branch 'pcl'
34 files changed, 554 insertions, 406 deletions
diff --git a/Mono.Cecil.Cil/Symbols.cs b/Mono.Cecil.Cil/Symbols.cs index ac685d8..d267c5b 100644 --- a/Mono.Cecil.Cil/Symbols.cs +++ b/Mono.Cecil.Cil/Symbols.cs @@ -159,6 +159,7 @@ namespace Mono.Cecil.Cil { ISymbolReader GetSymbolReader (ModuleDefinition module, Stream symbolStream); } +#if !PCL static class SymbolProvider { static readonly string symbol_kind = Type.GetType ("Mono.Runtime") != null ? "Mdb" : "Pdb"; @@ -194,9 +195,7 @@ namespace Mono.Cecil.Cil { if (assembly != null) return assembly.GetType (fullname); } catch (FileNotFoundException) { -#if !CF } catch (FileLoadException) { -#endif } return null; @@ -239,6 +238,7 @@ namespace Mono.Cecil.Cil { #endif } +#endif #if !READ_ONLY diff --git a/Mono.Cecil.csproj b/Mono.Cecil.csproj index 0a5ea38..e14a1b9 100644 --- a/Mono.Cecil.csproj +++ b/Mono.Cecil.csproj @@ -5,9 +5,6 @@ <RootNamespace>Mono.Cecil</RootNamespace> <AssemblyName>Mono.Cecil</AssemblyName> </PropertyGroup> - <ItemGroup Condition=" '$(TargetFrameworkVersion)' != 'v2.0' "> - <Reference Include="System.Core" /> - </ItemGroup> <ItemGroup> <Compile Include="Mono.Cecil.Cil\Code.cs" /> <Compile Include="Mono.Cecil.Cil\CodeWriter.cs" /> @@ -133,11 +130,9 @@ <Compile Include="Mono.Security.Cryptography\CryptoConvert.cs" /> <Compile Include="Mono.Security.Cryptography\CryptoService.cs" /> <Compile Include="ProjectInfo.cs" /> - <Compile Include="System.Runtime.CompilerServices\ExtensionAttribute.cs" /> - <Compile Include="Mono\Actions.cs" /> <Compile Include="Mono\Empty.cs" /> - <Compile Include="Mono\Funcs.cs" /> + <Compile Include="System.Security.Cryptography\SHA1Managed.cs" /> </ItemGroup> <Import Project="Mono.Cecil.settings" /> - <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> + <Import Project="$(MSBuildCSharpTargets)" /> </Project>
\ No newline at end of file diff --git a/Mono.Cecil.nuspec b/Mono.Cecil.nuspec index ee49691..e01234e 100644 --- a/Mono.Cecil.nuspec +++ b/Mono.Cecil.nuspec @@ -15,11 +15,9 @@ <tags>assembly assemblies module modules il cil msil bytecode reflection injection cecil mono aop</tags> </metadata> <files> - <file src="bin\net_2_0_Release\*.dll" target="lib/net20" /> - <file src="bin\net_2_0_Release\*.dll" target="lib/net20" /> <file src="bin\net_3_5_Release\*.dll" target="lib/net35" /> <file src="bin\net_4_0_Release\*.dll" target="lib/net40" /> <file src="bin\net_4_5_Release\*.dll" target="lib/net45" /> - <file src="bin\silverlight_Release\*.dll" target="lib/sl5" /> + <file src="bin\pcl_Release\*.dll" target="lib/portable-net40+sl5+win8+wp8+wpa" /> </files> </package> diff --git a/Mono.Cecil.settings b/Mono.Cecil.settings index c1ca9d3..fc04139 100644 --- a/Mono.Cecil.settings +++ b/Mono.Cecil.settings @@ -11,6 +11,7 @@ <AssemblyOriginatorKeyFile>$(MSBuildThisFileDirectory)\mono.snk</AssemblyOriginatorKeyFile> <OutputType>Library</OutputType> <OutputPath>$(BuildDirectory)\bin\$(Configuration)\</OutputPath> + <MSBuildCSharpTargets>$(MSBuildToolsPath)\Microsoft.CSharp.targets</MSBuildCSharpTargets> </PropertyGroup> <PropertyGroup Condition=" $(Configuration.EndsWith('Debug')) "> <DebugSymbols>true</DebugSymbols> @@ -28,9 +29,6 @@ <WarningLevel>4</WarningLevel> <RunCodeAnalysis>false</RunCodeAnalysis> </PropertyGroup> - <PropertyGroup Condition=" $(Configuration.StartsWith('net_2_0')) "> - <TargetFrameworkVersion>v2.0</TargetFrameworkVersion> - </PropertyGroup> <PropertyGroup Condition=" $(Configuration.StartsWith('net_3_5')) "> <TargetFrameworkVersion>v3.5</TargetFrameworkVersion> <DefineConstants>$(DefineConstants);NET_3_5;</DefineConstants> @@ -43,36 +41,26 @@ <TargetFrameworkVersion>v4.5</TargetFrameworkVersion> <DefineConstants>$(DefineConstants);NET_3_5;NET_4_0;NET_4_5;</DefineConstants> </PropertyGroup> - <PropertyGroup Condition=" $(Configuration.StartsWith('silverlight')) "> - <TargetFrameworkIdentifier>Silverlight</TargetFrameworkIdentifier> - <TargetFrameworkVersion>v4.0</TargetFrameworkVersion> - <DefineConstants>$(DefineConstants);NET_3_5;NET_4_0;SILVERLIGHT</DefineConstants> - </PropertyGroup> - <PropertyGroup Condition=" $(Configuration.StartsWith('winphone')) "> - <TargetFrameworkProfile>WindowsPhone</TargetFrameworkProfile> - <TargetFrameworkIdentifier>Silverlight</TargetFrameworkIdentifier> + <PropertyGroup Condition=" $(Configuration.StartsWith('pcl')) "> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <TargetFrameworkProfile>Profile344</TargetFrameworkProfile> <TargetFrameworkVersion>v4.0</TargetFrameworkVersion> - <DefineConstants>$(DefineConstants);NET_3_5;NET_4_0;SILVERLIGHT;CF</DefineConstants> + <DefineConstants>$(DefineConstants);NET_3_5;NET_4_0;PCL;</DefineConstants> + <MSBuildCSharpTargets>$(MSBuildExtensionsPath32)\Microsoft\Portable\$(TargetFrameworkVersion)\Microsoft.Portable.CSharp.targets</MSBuildCSharpTargets> </PropertyGroup> <!-- Shared References --> - <ItemGroup Condition=" '$(TargetFrameworkVersion)' != 'v2.0' "> - <Reference Include="System.Core" /> - </ItemGroup> <ItemGroup> + <Reference Include="System.Core" /> <Reference Include="System" /> </ItemGroup> <!-- The following keeps Visual Studio happy; let's keep Visual Studio happy --> - <PropertyGroup Condition=" '$(Configuration)' == 'net_2_0_Debug' "> - </PropertyGroup> <PropertyGroup Condition=" '$(Configuration)' == 'net_3_5_Debug' "> </PropertyGroup> <PropertyGroup Condition=" '$(Configuration)' == 'net_4_0_Debug' "> </PropertyGroup> <PropertyGroup Condition=" '$(Configuration)' == 'net_4_5_Debug' "> </PropertyGroup> - <PropertyGroup Condition=" '$(Configuration)' == 'silverlight_Debug' "> - </PropertyGroup> - <PropertyGroup Condition=" '$(Configuration)' == 'winphone_Debug' "> + <PropertyGroup Condition=" '$(Configuration)' == 'pcl_Debug' "> </PropertyGroup> <PropertyGroup Condition=" '$(Configuration)' == 'net_2_0_Release' "> </PropertyGroup> @@ -82,11 +70,8 @@ </PropertyGroup> <PropertyGroup Condition=" '$(Configuration)' == 'net_4_5_Release' "> </PropertyGroup> - <PropertyGroup Condition=" '$(Configuration)' == 'silverlight_Release' "> + <PropertyGroup Condition=" '$(Configuration)' == 'pcl_Release' "> </PropertyGroup> - <PropertyGroup Condition=" '$(Configuration)' == 'winphone_Release' "> - </PropertyGroup> - <!-- This optional import allows products that distribute Cecil to tweak settings that will affect its build, without having to fork the project unnecessarily. The Mono.Cecil.overrides file is a plain MSBuild file with additional properties, and can exist anywhere upwards from the current Cecil repo diff --git a/Mono.Cecil.sln b/Mono.Cecil.sln index 972649a..51fef56 100644 --- a/Mono.Cecil.sln +++ b/Mono.Cecil.sln @@ -1,5 +1,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 2012 +# Visual Studio 2013 +VisualStudioVersion = 12.0.30501.0 +MinimumVisualStudioVersion = 10.0.40219.1 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tests", "Tests", "{74E5ECE0-06B4-401C-AEBA-E8DD53E17943}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Symbols", "Symbols", "{929D5B3B-E29A-40CC-93D8-0FF43A6F9FA1}" @@ -22,24 +24,16 @@ 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 net_4_0_Release|Any CPU = net_4_0_Release|Any CPU net_4_5_Debug|Any CPU = net_4_5_Debug|Any CPU net_4_5_Release|Any CPU = net_4_5_Release|Any CPU - silverlight_Debug|Any CPU = silverlight_Debug|Any CPU - silverlight_Release|Any CPU = silverlight_Release|Any CPU - winphone_Debug|Any CPU = winphone_Debug|Any CPU - winphone_Release|Any CPU = winphone_Release|Any CPU + pcl_Debug|Any CPU = pcl_Debug|Any CPU + 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 @@ -52,18 +46,10 @@ Global {D68133BD-1E63-496E-9EDE-4FBDBF77B486}.net_4_5_Debug|Any CPU.Build.0 = net_4_5_Debug|Any CPU {D68133BD-1E63-496E-9EDE-4FBDBF77B486}.net_4_5_Release|Any CPU.ActiveCfg = net_4_5_Release|Any CPU {D68133BD-1E63-496E-9EDE-4FBDBF77B486}.net_4_5_Release|Any CPU.Build.0 = net_4_5_Release|Any CPU - {D68133BD-1E63-496E-9EDE-4FBDBF77B486}.silverlight_Debug|Any CPU.ActiveCfg = silverlight_Debug|Any CPU - {D68133BD-1E63-496E-9EDE-4FBDBF77B486}.silverlight_Debug|Any CPU.Build.0 = silverlight_Debug|Any CPU - {D68133BD-1E63-496E-9EDE-4FBDBF77B486}.silverlight_Release|Any CPU.ActiveCfg = silverlight_Release|Any CPU - {D68133BD-1E63-496E-9EDE-4FBDBF77B486}.silverlight_Release|Any CPU.Build.0 = silverlight_Release|Any CPU - {D68133BD-1E63-496E-9EDE-4FBDBF77B486}.winphone_Debug|Any CPU.ActiveCfg = winphone_Debug|Any CPU - {D68133BD-1E63-496E-9EDE-4FBDBF77B486}.winphone_Debug|Any CPU.Build.0 = winphone_Debug|Any CPU - {D68133BD-1E63-496E-9EDE-4FBDBF77B486}.winphone_Release|Any CPU.ActiveCfg = winphone_Release|Any CPU - {D68133BD-1E63-496E-9EDE-4FBDBF77B486}.winphone_Release|Any CPU.Build.0 = winphone_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 + {D68133BD-1E63-496E-9EDE-4FBDBF77B486}.pcl_Debug|Any CPU.ActiveCfg = pcl_Debug|Any CPU + {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_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 @@ -76,14 +62,8 @@ Global {A47B1F49-A81A-43E8-BE6B-DD28AF2C4055}.net_4_5_Debug|Any CPU.Build.0 = net_4_5_Debug|Any CPU {A47B1F49-A81A-43E8-BE6B-DD28AF2C4055}.net_4_5_Release|Any CPU.ActiveCfg = net_4_5_Release|Any CPU {A47B1F49-A81A-43E8-BE6B-DD28AF2C4055}.net_4_5_Release|Any CPU.Build.0 = net_4_5_Release|Any CPU - {A47B1F49-A81A-43E8-BE6B-DD28AF2C4055}.silverlight_Debug|Any CPU.ActiveCfg = net_4_0_Release|Any CPU - {A47B1F49-A81A-43E8-BE6B-DD28AF2C4055}.silverlight_Release|Any CPU.ActiveCfg = net_4_0_Release|Any CPU - {A47B1F49-A81A-43E8-BE6B-DD28AF2C4055}.winphone_Debug|Any CPU.ActiveCfg = net_4_0_Release|Any CPU - {A47B1F49-A81A-43E8-BE6B-DD28AF2C4055}.winphone_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 + {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_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 @@ -96,14 +76,8 @@ Global {8559DD7F-A16F-46D0-A05A-9139FAEBA8FD}.net_4_5_Debug|Any CPU.Build.0 = net_4_5_Debug|Any CPU {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}.silverlight_Debug|Any CPU.ActiveCfg = net_4_0_Release|Any CPU - {8559DD7F-A16F-46D0-A05A-9139FAEBA8FD}.silverlight_Release|Any CPU.ActiveCfg = net_4_0_Release|Any CPU - {8559DD7F-A16F-46D0-A05A-9139FAEBA8FD}.winphone_Debug|Any CPU.ActiveCfg = net_4_0_Release|Any CPU - {8559DD7F-A16F-46D0-A05A-9139FAEBA8FD}.winphone_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 + {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_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 @@ -116,14 +90,8 @@ Global {AC71DF9C-99FA-4A63-990A-66C8010355A6}.net_4_5_Debug|Any CPU.Build.0 = net_4_5_Debug|Any CPU {AC71DF9C-99FA-4A63-990A-66C8010355A6}.net_4_5_Release|Any CPU.ActiveCfg = net_4_5_Release|Any CPU {AC71DF9C-99FA-4A63-990A-66C8010355A6}.net_4_5_Release|Any CPU.Build.0 = net_4_5_Release|Any CPU - {AC71DF9C-99FA-4A63-990A-66C8010355A6}.silverlight_Debug|Any CPU.ActiveCfg = net_4_0_Release|Any CPU - {AC71DF9C-99FA-4A63-990A-66C8010355A6}.silverlight_Release|Any CPU.ActiveCfg = net_4_0_Release|Any CPU - {AC71DF9C-99FA-4A63-990A-66C8010355A6}.winphone_Debug|Any CPU.ActiveCfg = net_4_0_Release|Any CPU - {AC71DF9C-99FA-4A63-990A-66C8010355A6}.winphone_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 + {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_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 @@ -136,14 +104,8 @@ Global {63E6915C-7EA4-4D76-AB28-0D7191EEA626}.net_4_5_Debug|Any CPU.Build.0 = net_4_5_Debug|Any CPU {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}.silverlight_Debug|Any CPU.ActiveCfg = net_4_0_Release|Any CPU - {63E6915C-7EA4-4D76-AB28-0D7191EEA626}.silverlight_Release|Any CPU.ActiveCfg = net_4_0_Release|Any CPU - {63E6915C-7EA4-4D76-AB28-0D7191EEA626}.winphone_Debug|Any CPU.ActiveCfg = net_4_0_Release|Any CPU - {63E6915C-7EA4-4D76-AB28-0D7191EEA626}.winphone_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 + {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_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 @@ -156,12 +118,8 @@ Global {29300103-CB76-4A1D-B6FD-FFD91C1EC8AA}.net_4_5_Debug|Any CPU.Build.0 = net_4_5_Debug|Any CPU {29300103-CB76-4A1D-B6FD-FFD91C1EC8AA}.net_4_5_Release|Any CPU.ActiveCfg = net_4_5_Release|Any CPU {29300103-CB76-4A1D-B6FD-FFD91C1EC8AA}.net_4_5_Release|Any CPU.Build.0 = net_4_5_Release|Any CPU - {29300103-CB76-4A1D-B6FD-FFD91C1EC8AA}.silverlight_Debug|Any CPU.ActiveCfg = net_4_0_Release|Any CPU - {29300103-CB76-4A1D-B6FD-FFD91C1EC8AA}.silverlight_Release|Any CPU.ActiveCfg = net_4_0_Release|Any CPU - {29300103-CB76-4A1D-B6FD-FFD91C1EC8AA}.winphone_Debug|Any CPU.ActiveCfg = net_4_0_Release|Any CPU - {29300103-CB76-4A1D-B6FD-FFD91C1EC8AA}.winphone_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 + {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_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 @@ -174,12 +132,8 @@ Global {C6CFD7E1-B855-44DC-B4CE-9CD72984AF52}.net_4_5_Debug|Any CPU.Build.0 = net_4_5_Debug|Any CPU {C6CFD7E1-B855-44DC-B4CE-9CD72984AF52}.net_4_5_Release|Any CPU.ActiveCfg = net_4_5_Release|Any CPU {C6CFD7E1-B855-44DC-B4CE-9CD72984AF52}.net_4_5_Release|Any CPU.Build.0 = net_4_5_Release|Any CPU - {C6CFD7E1-B855-44DC-B4CE-9CD72984AF52}.silverlight_Debug|Any CPU.ActiveCfg = net_4_0_Release|Any CPU - {C6CFD7E1-B855-44DC-B4CE-9CD72984AF52}.silverlight_Release|Any CPU.ActiveCfg = net_4_0_Release|Any CPU - {C6CFD7E1-B855-44DC-B4CE-9CD72984AF52}.winphone_Debug|Any CPU.ActiveCfg = net_4_0_Release|Any CPU - {C6CFD7E1-B855-44DC-B4CE-9CD72984AF52}.winphone_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 + {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_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 @@ -192,24 +146,18 @@ Global {FBC6DD59-D09D-499C-B03C-99C1C78FF2AC}.net_4_5_Debug|Any CPU.Build.0 = net_4_5_Debug|Any CPU {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}.silverlight_Debug|Any CPU.ActiveCfg = silverlight_Debug|Any CPU - {FBC6DD59-D09D-499C-B03C-99C1C78FF2AC}.silverlight_Debug|Any CPU.Build.0 = silverlight_Debug|Any CPU - {FBC6DD59-D09D-499C-B03C-99C1C78FF2AC}.silverlight_Release|Any CPU.ActiveCfg = silverlight_Release|Any CPU - {FBC6DD59-D09D-499C-B03C-99C1C78FF2AC}.silverlight_Release|Any CPU.Build.0 = silverlight_Release|Any CPU - {FBC6DD59-D09D-499C-B03C-99C1C78FF2AC}.winphone_Debug|Any CPU.ActiveCfg = winphone_Debug|Any CPU - {FBC6DD59-D09D-499C-B03C-99C1C78FF2AC}.winphone_Debug|Any CPU.Build.0 = winphone_Debug|Any CPU - {FBC6DD59-D09D-499C-B03C-99C1C78FF2AC}.winphone_Release|Any CPU.ActiveCfg = winphone_Release|Any CPU - {FBC6DD59-D09D-499C-B03C-99C1C78FF2AC}.winphone_Release|Any CPU.Build.0 = winphone_Release|Any CPU + {FBC6DD59-D09D-499C-B03C-99C1C78FF2AC}.pcl_Debug|Any CPU.ActiveCfg = pcl_Debug|Any CPU + {FBC6DD59-D09D-499C-B03C-99C1C78FF2AC}.pcl_Release|Any CPU.ActiveCfg = pcl_Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection GlobalSection(NestedProjects) = preSolution {A47B1F49-A81A-43E8-BE6B-DD28AF2C4055} = {74E5ECE0-06B4-401C-AEBA-E8DD53E17943} + {8559DD7F-A16F-46D0-A05A-9139FAEBA8FD} = {929D5B3B-E29A-40CC-93D8-0FF43A6F9FA1} {AC71DF9C-99FA-4A63-990A-66C8010355A6} = {74E5ECE0-06B4-401C-AEBA-E8DD53E17943} + {63E6915C-7EA4-4D76-AB28-0D7191EEA626} = {929D5B3B-E29A-40CC-93D8-0FF43A6F9FA1} {29300103-CB76-4A1D-B6FD-FFD91C1EC8AA} = {74E5ECE0-06B4-401C-AEBA-E8DD53E17943} {C6CFD7E1-B855-44DC-B4CE-9CD72984AF52} = {74E5ECE0-06B4-401C-AEBA-E8DD53E17943} - {8559DD7F-A16F-46D0-A05A-9139FAEBA8FD} = {929D5B3B-E29A-40CC-93D8-0FF43A6F9FA1} - {63E6915C-7EA4-4D76-AB28-0D7191EEA626} = {929D5B3B-E29A-40CC-93D8-0FF43A6F9FA1} EndGlobalSection EndGlobal diff --git a/Mono.Cecil/AssemblyDefinition.cs b/Mono.Cecil/AssemblyDefinition.cs index de6ed17..0cc935e 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) { @@ -142,19 +144,22 @@ namespace Mono.Cecil { } #if !READ_ONLY + +#if !PCL public void Write (string fileName) { Write (fileName, new WriterParameters ()); } - public void Write (Stream stream) + public void Write (string fileName, WriterParameters parameters) { - Write (stream, new WriterParameters ()); + main_module.Write (fileName, parameters); } +#endif - public void Write (string fileName, WriterParameters parameters) + public void Write (Stream stream) { - main_module.Write (fileName, parameters); + Write (stream, new WriterParameters ()); } public void Write (Stream stream, WriterParameters parameters) diff --git a/Mono.Cecil/AssemblyInfo.cs b/Mono.Cecil/AssemblyInfo.cs index 40cc0d4..ba0cfa6 100644 --- a/Mono.Cecil/AssemblyInfo.cs +++ b/Mono.Cecil/AssemblyInfo.cs @@ -14,7 +14,9 @@ using System.Runtime.InteropServices; [assembly: AssemblyTitle ("Mono.Cecil")] +#if !PCL [assembly: Guid ("fd225bb4-fa53-44b2-a6db-85f5e48dcb54")] +#endif [assembly: InternalsVisibleTo ("Mono.Cecil.Pdb, PublicKey=002400000480000094000000060200000024000052534131000400000100010079159977d2d03a8e6bea7a2e74e8d1afcc93e8851974952bb480a12c9134474d04062447c37e0e68c080536fcf3c3fbe2ff9c979ce998475e506e8ce82dd5b0f350dc10e93bf2eeecf874b24770c5081dbea7447fddafa277b22de47d6ffea449674a4f9fccf84d15069089380284dbdd35f46cdff12a1bd78e4ef0065d016df")] [assembly: InternalsVisibleTo ("Mono.Cecil.Mdb, PublicKey=002400000480000094000000060200000024000052534131000400000100010079159977d2d03a8e6bea7a2e74e8d1afcc93e8851974952bb480a12c9134474d04062447c37e0e68c080536fcf3c3fbe2ff9c979ce998475e506e8ce82dd5b0f350dc10e93bf2eeecf874b24770c5081dbea7447fddafa277b22de47d6ffea449674a4f9fccf84d15069089380284dbdd35f46cdff12a1bd78e4ef0065d016df")] diff --git a/Mono.Cecil/AssemblyNameReference.cs b/Mono.Cecil/AssemblyNameReference.cs index 6521dc6..78b0337 100644 --- a/Mono.Cecil/AssemblyNameReference.cs +++ b/Mono.Cecil/AssemblyNameReference.cs @@ -109,29 +109,27 @@ namespace Mono.Cecil { byte [] HashPublicKey () { +#if !PCL HashAlgorithm algorithm; switch (hash_algorithm) { case AssemblyHashAlgorithm.Reserved: -#if SILVERLIGHT - throw new NotSupportedException (); -#else algorithm = MD5.Create (); break; -#endif default: // None default to SHA1 -#if SILVERLIGHT - algorithm = new SHA1Managed (); - break; -#else algorithm = SHA1.Create (); break; -#endif } using (algorithm) return algorithm.ComputeHash (public_key); +#else + if (hash_algorithm != AssemblyHashAlgorithm.SHA1) + throw new NotSupportedException (); + + return new SHA1Managed ().ComputeHash (public_key); +#endif } public virtual MetadataScopeType MetadataScopeType { diff --git a/Mono.Cecil/AssemblyReader.cs b/Mono.Cecil/AssemblyReader.cs index 031e613..451ec56 100644 --- a/Mono.Cecil/AssemblyReader.cs +++ b/Mono.Cecil/AssemblyReader.cs @@ -72,7 +72,7 @@ namespace Mono.Cecil { #if !READ_ONLY if (parameters.metadata_importer_provider != null) module.metadata_importer = parameters.metadata_importer_provider.GetMetadataImporter (module); -#if !CF +#if !PCL if (parameters.reflection_importer_provider != null) module.reflection_importer = parameters.reflection_importer_provider.GetReflectionImporter (module); #endif @@ -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/AssemblyWriter.cs b/Mono.Cecil/AssemblyWriter.cs index f5bfe73..b96d42d 100644 --- a/Mono.Cecil/AssemblyWriter.cs +++ b/Mono.Cecil/AssemblyWriter.cs @@ -74,11 +74,13 @@ namespace Mono.Cecil { var name = module.assembly != null ? module.assembly.Name : null; var fq_name = stream.GetFullyQualifiedName (); var symbol_writer_provider = parameters.SymbolWriterProvider; +#if !PCL if (symbol_writer_provider == null && parameters.WriteSymbols) symbol_writer_provider = SymbolProvider.GetPlatformWriterProvider (); +#endif var symbol_writer = GetSymbolWriter (module, fq_name, symbol_writer_provider); -#if !SILVERLIGHT && !CF +#if !PCL if (parameters.StrongNameKeyPair != null && name != null) { name.PublicKey = parameters.StrongNameKeyPair.PublicKey; module.Attributes |= ModuleAttributes.StrongNameSigned; @@ -96,7 +98,7 @@ namespace Mono.Cecil { writer.WriteImage (); -#if !SILVERLIGHT && !CF +#if !PCL if (parameters.StrongNameKeyPair != null) CryptoService.StrongName (stream, writer, parameters.StrongNameKeyPair); #endif @@ -878,6 +880,9 @@ namespace Mono.Cecil { if (module.IsMain) continue; +#if PCL + throw new NotSupportedException (); +#else var parameters = new WriterParameters { SymbolWriterProvider = symbol_writer_provider, }; @@ -891,9 +896,11 @@ namespace Mono.Cecil { FileAttributes.ContainsMetaData, GetStringIndex (module.Name), GetBlobIndex (hash))); +#endif } } +#if !PCL string GetModuleFileName (string name) { if (string.IsNullOrEmpty (name)) @@ -902,6 +909,7 @@ namespace Mono.Cecil { var path = Path.GetDirectoryName (fq_name); return Path.Combine (path, name); } +#endif void AddAssemblyReferences () { @@ -985,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.Cecil/BaseAssemblyResolver.cs b/Mono.Cecil/BaseAssemblyResolver.cs index 76f5da1..079365a 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; @@ -33,9 +35,7 @@ namespace Mono.Cecil { } } -#if !SILVERLIGHT && !CF [Serializable] -#endif public class AssemblyResolutionException : FileNotFoundException { readonly AssemblyNameReference reference; @@ -50,14 +50,12 @@ namespace Mono.Cecil { this.reference = reference; } -#if !SILVERLIGHT && !CF protected AssemblyResolutionException ( System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) : base (info, context) { } -#endif } public abstract class BaseAssemblyResolver : IAssemblyResolver { @@ -66,9 +64,7 @@ namespace Mono.Cecil { readonly Collection<string> directories; -#if !SILVERLIGHT && !CF Collection<string> gac_paths; -#endif public void AddSearchDirectory (string directory) { @@ -131,7 +127,6 @@ namespace Mono.Cecil { if (assembly != null) return assembly; -#if !SILVERLIGHT && !CF if (name.IsRetargetable) { // if the reference is retargetable, zero it name = new AssemblyNameReference (name.Name, Mixin.ZeroVersion) { @@ -160,7 +155,6 @@ namespace Mono.Cecil { assembly = SearchDirectory (name, new [] { framework_dir }, parameters); if (assembly != null) return assembly; -#endif if (ResolveFailure != null) { assembly = ResolveFailure (this, name); @@ -190,7 +184,6 @@ namespace Mono.Cecil { return version.Major == 0 && version.Minor == 0 && version.Build == 0 && version.Revision == 0; } -#if !SILVERLIGHT && !CF AssemblyDefinition GetCorlib (AssemblyNameReference reference, ReaderParameters parameters) { var version = reference.Version; @@ -347,6 +340,7 @@ namespace Mono.Cecil { Path.Combine (gac, reference.Name), gac_folder.ToString ()), reference.Name + ".dll"); } -#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 661e867..362e490 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; @@ -29,7 +31,7 @@ namespace Mono.Cecil { MethodReference ImportReference (MethodReference method, IGenericParameterProvider context); } -#if !CF +#if !PCL public interface IReflectionImporterProvider { IReflectionImporter GetReflectionImporter (ModuleDefinition module); @@ -40,6 +42,7 @@ namespace Mono.Cecil { FieldReference ImportReference (SR.FieldInfo field, IGenericParameterProvider context); MethodReference ImportReference (SR.MethodBase method, IGenericParameterProvider context); } + #endif struct ImportGenericContext { @@ -121,7 +124,7 @@ namespace Mono.Cecil { } -#if !CF +#if !PCL public class ReflectionImporter : IReflectionImporter { readonly ModuleDefinition module; @@ -201,11 +204,7 @@ namespace Mono.Cecil { static bool IsNestedType (Type type) { -#if !SILVERLIGHT return type.IsNested; -#else - return type.DeclaringType != null; -#endif } TypeReference ImportTypeSpecification (Type type, ImportGenericContext context) @@ -292,7 +291,7 @@ namespace Mono.Cecil { AssemblyNameReference ImportScope (SR.Assembly assembly) { AssemblyNameReference scope; -#if !SILVERLIGHT + var name = assembly.GetName (); if (TryGetAssemblyNameReference (name, out scope)) @@ -307,19 +306,8 @@ namespace Mono.Cecil { module.AssemblyReferences.Add (scope); return scope; -#else - var name = AssemblyNameReference.Parse (assembly.FullName); - - if (module.TryGetAssemblyNameReference (name, out scope)) - return scope; - - module.AssemblyReferences.Add (name); - - return name; -#endif } -#if !SILVERLIGHT bool TryGetAssemblyNameReference (SR.AssemblyName name, out AssemblyNameReference assembly_reference) { var references = module.AssemblyReferences; @@ -336,7 +324,6 @@ namespace Mono.Cecil { assembly_reference = null; return false; } -#endif FieldReference ImportField (SR.FieldInfo field, ImportGenericContext context) { @@ -359,14 +346,7 @@ namespace Mono.Cecil { static SR.FieldInfo ResolveFieldDefinition (SR.FieldInfo field) { -#if !SILVERLIGHT return field.Module.ResolveField (field.MetadataToken); -#else - return field.DeclaringType.GetGenericTypeDefinition ().GetField (field.Name, - SR.BindingFlags.Public - | SR.BindingFlags.NonPublic - | (field.IsStatic ? SR.BindingFlags.Static : SR.BindingFlags.Instance)); -#endif } MethodReference ImportMethod (SR.MethodBase method, ImportGenericContext context, ImportGenericKind import_kind) @@ -810,3 +790,5 @@ namespace Mono.Cecil { #endif } + +#endif diff --git a/Mono.Cecil/MetadataResolver.cs b/Mono.Cecil/MetadataResolver.cs index 70d9265..76658bf 100644 --- a/Mono.Cecil/MetadataResolver.cs +++ b/Mono.Cecil/MetadataResolver.cs @@ -28,7 +28,7 @@ namespace Mono.Cecil { MethodDefinition Resolve (MethodReference method); } -#if !SILVERLIGHT && !CF +#if !PCL [Serializable] #endif public class ResolutionException : Exception { @@ -62,7 +62,7 @@ namespace Mono.Cecil { this.member = member; } -#if !SILVERLIGHT && !CF +#if !PCL protected ResolutionException ( System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) diff --git a/Mono.Cecil/ModuleDefinition.cs b/Mono.Cecil/ModuleDefinition.cs index aaaf244..fcbe10e 100644 --- a/Mono.Cecil/ModuleDefinition.cs +++ b/Mono.Cecil/ModuleDefinition.cs @@ -33,7 +33,7 @@ namespace Mono.Cecil { internal IMetadataResolver metadata_resolver; #if !READ_ONLY internal IMetadataImporterProvider metadata_importer_provider; -#if !CF +#if !PCL internal IReflectionImporterProvider reflection_importer_provider; #endif #endif @@ -62,7 +62,7 @@ namespace Mono.Cecil { set { metadata_importer_provider = value; } } -#if !CF +#if !PCL public IReflectionImporterProvider ReflectionImporterProvider { get { return reflection_importer_provider; } set { reflection_importer_provider = value; } @@ -107,7 +107,7 @@ namespace Mono.Cecil { IMetadataResolver metadata_resolver; #if !READ_ONLY IMetadataImporterProvider metadata_importer_provider; -#if !CF +#if !PCL IReflectionImporterProvider reflection_importer_provider; #endif #endif @@ -143,7 +143,7 @@ namespace Mono.Cecil { set { metadata_importer_provider = value; } } -#if !CF +#if !PCL public IReflectionImporterProvider ReflectionImporterProvider { get { return reflection_importer_provider; } set { reflection_importer_provider = value; } @@ -160,10 +160,11 @@ namespace Mono.Cecil { static TargetRuntime GetCurrentRuntime () { -#if !CF +#if !PCL return typeof (object).Assembly.ImageRuntimeVersion.ParseRuntime (); #else - var corlib_version = typeof (object).Assembly.GetName ().Version; + var corlib_name = AssemblyNameReference.Parse (typeof (object).Assembly.FullName); + var corlib_version = corlib_name.Version; switch (corlib_version.Major) { case 1: return corlib_version.Minor == 0 @@ -185,7 +186,7 @@ namespace Mono.Cecil { Stream symbol_stream; ISymbolWriterProvider symbol_writer_provider; bool write_symbols; -#if !SILVERLIGHT && !CF +#if !PCL SR.StrongNameKeyPair key_pair; #endif public Stream SymbolStream { @@ -202,7 +203,7 @@ namespace Mono.Cecil { get { return write_symbols; } set { write_symbols = value; } } -#if !SILVERLIGHT && !CF +#if !PCL public SR.StrongNameKeyPair StrongNameKeyPair { get { return key_pair; } set { key_pair = value; } @@ -239,7 +240,7 @@ namespace Mono.Cecil { MethodDefinition entry_point; #if !READ_ONLY -#if !CF +#if !PCL internal IReflectionImporter reflection_importer; #endif internal IMetadataImporter metadata_importer; @@ -321,7 +322,7 @@ namespace Mono.Cecil { } #if !READ_ONLY -#if !CF +#if !PCL internal IReflectionImporter ReflectionImporter { get { if (reflection_importer == null) @@ -343,8 +344,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 +652,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); } @@ -673,7 +688,7 @@ namespace Mono.Cecil { throw new ArgumentException (); } -#if !CF +#if !PCL [Obsolete ("Use ImportReference", error: false)] public TypeReference Import (Type type) @@ -944,7 +959,7 @@ namespace Mono.Cecil { #if !READ_ONLY if (parameters.MetadataImporterProvider != null) module.metadata_importer = parameters.MetadataImporterProvider.GetMetadataImporter (module); -#if !CF +#if !PCL if (parameters.ReflectionImporterProvider != null) module.reflection_importer = parameters.ReflectionImporterProvider.GetReflectionImporter (module); #endif @@ -972,6 +987,7 @@ namespace Mono.Cecil { #endif +#if !PCL public void ReadSymbols () { if (string.IsNullOrEmpty (fq_name)) @@ -983,6 +999,7 @@ namespace Mono.Cecil { ReadSymbols (provider.GetSymbolReader (this, fq_name)); } +#endif public void ReadSymbols (ISymbolReader reader) { @@ -994,21 +1011,39 @@ namespace Mono.Cecil { ProcessDebugHeader (); } +#if !PCL public static ModuleDefinition ReadModule (string fileName) { return ReadModule (fileName, new ReaderParameters (ReadingMode.Deferred)); } + public static ModuleDefinition ReadModule (string fileName, ReaderParameters parameters) + { + using (var stream = GetFileStream (fileName, FileMode.Open, FileAccess.Read, FileShare.Read)) { + return ReadModule (stream, parameters); + } + } + + static Stream GetFileStream (string fileName, FileMode mode, FileAccess access, FileShare share) + { + if (fileName == null) + throw new ArgumentNullException ("fileName"); + if (fileName.Length == 0) + throw new ArgumentException (); + + return new FileStream (fileName, mode, access, share); + } +#endif + public static ModuleDefinition ReadModule (Stream stream) { return ReadModule (stream, new ReaderParameters (ReadingMode.Deferred)); } - public static ModuleDefinition ReadModule (string fileName, ReaderParameters parameters) + static void CheckStream (object stream) { - using (var stream = GetFileStream (fileName, FileMode.Open, FileAccess.Read, FileShare.Read)) { - return ReadModule (stream, parameters); - } + if (stream == null) + throw new ArgumentNullException ("stream"); } public static ModuleDefinition ReadModule (Stream stream, ReaderParameters parameters) @@ -1023,34 +1058,26 @@ namespace Mono.Cecil { parameters); } - static Stream GetFileStream (string fileName, FileMode mode, FileAccess access, FileShare share) - { - if (fileName == null) - throw new ArgumentNullException ("fileName"); - if (fileName.Length == 0) - throw new ArgumentException (); - - return new FileStream (fileName, mode, access, share); - } - #if !READ_ONLY +#if !PCL public void Write (string fileName) { Write (fileName, new WriterParameters ()); } - public void Write (Stream stream) - { - Write (stream, new WriterParameters ()); - } - public void Write (string fileName, WriterParameters parameters) { using (var stream = GetFileStream (fileName, FileMode.Create, FileAccess.ReadWrite, FileShare.None)) { Write (stream, parameters); } } +#endif + + public void Write (Stream stream) + { + Write (stream, new WriterParameters ()); + } public void Write (Stream stream, WriterParameters parameters) { @@ -1125,7 +1152,7 @@ namespace Mono.Cecil { public static string GetFullyQualifiedName (this Stream self) { -#if !SILVERLIGHT +#if !PCL var file_stream = self as FileStream; if (file_stream == null) return string.Empty; diff --git a/Mono.Cecil/TypeParser.cs b/Mono.Cecil/TypeParser.cs index 3345aa7..c6069b9 100644 --- a/Mono.Cecil/TypeParser.cs +++ b/Mono.Cecil/TypeParser.cs @@ -87,17 +87,7 @@ namespace Mono.Cecil { static bool ParseInt32 (string value, out int result) { -#if CF - try { - result = int.Parse (value); - return true; - } catch { - result = 0; - return false; - } -#else return int.TryParse (value, out result); -#endif } static void TryAddArity (string name, ref int arity) diff --git a/Mono.Security.Cryptography/CryptoConvert.cs b/Mono.Security.Cryptography/CryptoConvert.cs index bd38900..20a6821 100644 --- a/Mono.Security.Cryptography/CryptoConvert.cs +++ b/Mono.Security.Cryptography/CryptoConvert.cs @@ -27,11 +27,13 @@ // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // +#if !READ_ONLY + +#if !PCL + using System; using System.Security.Cryptography; -#if !(SILVERLIGHT || READ_ONLY) - namespace Mono.Security.Cryptography { static class CryptoConvert { @@ -246,3 +248,6 @@ namespace Mono.Security.Cryptography { } #endif + +#endif + diff --git a/Mono.Security.Cryptography/CryptoService.cs b/Mono.Security.Cryptography/CryptoService.cs index 6f28623..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 !SILVERLIGHT && !CF using System.Runtime.Serialization; + using Mono.Security.Cryptography; -#endif using Mono.Cecil.PE; @@ -30,7 +30,6 @@ namespace Mono.Cecil { static class CryptoService { -#if !SILVERLIGHT && !CF 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) { @@ -123,7 +122,6 @@ namespace Mono.Cecil { } } -#if !SILVERLIGHT && !CF static partial class Mixin { public static RSA CreateRSA (this StrongNameKeyPair key_pair) @@ -153,7 +151,8 @@ namespace Mono.Cecil { return key_container != null; } } -#endif } #endif + +#endif 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, T2> (T1 arg1, T2 arg2); - //delegate void Action<T1, T2, T3> (T1 arg1, T2 arg2, T3 arg3); - //delegate void Action<T1, T2, T3, T4> (T1 arg1, T2 arg2, T3 arg3, T4 arg4); -} - -#endif diff --git a/Mono/Empty.cs b/Mono/Empty.cs index d832065..cef2078 100644 --- a/Mono/Empty.cs +++ b/Mono/Empty.cs @@ -35,14 +35,7 @@ namespace Mono.Cecil { public static T [] Resize<T> (this T [] self, int length) { -#if !CF Array.Resize (ref self, length); -#else - var copy = new T [length]; - Array.Copy (self, copy, self.Length); - self = copy; -#endif - return self; } } 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<TResult> (); - delegate TResult Func<T, TResult> (T arg1); - delegate TResult Func<T1, T2, TResult> (T1 arg1, T2 arg2); - //delegate TResult Func<T1, T2, T3, TResult> (T1 arg1, T2 arg2, T3 arg3); - //delegate TResult Func<T1, T2, T3, T4, TResult> (T1 arg1, T2 arg2, T3 arg3, T4 arg4); -} - -#endif diff --git a/ProjectInfo.cs b/ProjectInfo.cs index 8d427a7..2ebd18d 100644 --- a/ProjectInfo.cs +++ b/ProjectInfo.cs @@ -13,9 +13,9 @@ using System.Runtime.InteropServices; [assembly: AssemblyProduct ("Mono.Cecil")] [assembly: AssemblyCopyright ("Copyright © 2008 - 2015 Jb Evain")] +#if !PCL [assembly: ComVisible (false)] +#endif [assembly: AssemblyVersion ("0.9.6.0")] -#if !CF [assembly: AssemblyFileVersion ("0.9.6.0")] -#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/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<inputCount; i++) { + fooBuffer[i] = inputBuffer[i+inputOffset]; + } + + fooBuffer[inputCount] = 0x80; + for (int i=inputCount+1; i<inputCount+paddingSize; i++) { + fooBuffer[i] = 0x00; + } + + // I deal in bytes. The algorithm deals in bits. + ulong size = total << 3; + AddLength (size, fooBuffer, inputCount+paddingSize); + ProcessBlock (fooBuffer, 0); + + if (length == 128) + ProcessBlock (fooBuffer, 64); + } + + internal void AddLength (ulong length, byte[] buffer, int position) + { + buffer [position++] = (byte)(length >> 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 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 @@ <Compile Include="Mono.Cecil.Tests\SecurityDeclarationTests.cs" /> <Compile Include="Mono.Cecil.Tests\ParameterTests.cs" /> <Compile Include="Mono.Cecil.Tests\Extensions.cs" /> - <Compile Include="Mono.Cecil.Tests\Linq.cs" /> <Compile Include="Mono.Cecil.Tests\ResolveTests.cs" /> <Compile Include="Mono.Cecil.Tests\CustomAttributesTests.cs" /> <Compile Include="Mono.Cecil.Tests\Formatter.cs" /> diff --git a/Test/Mono.Cecil.Tests/Linq.cs b/Test/Mono.Cecil.Tests/Linq.cs deleted file mode 100644 index d1fac18..0000000 --- a/Test/Mono.Cecil.Tests/Linq.cs +++ /dev/null @@ -1,52 +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<TRet> Select<TItem, TRet> (this IEnumerable<TItem> self, Func<TItem, TRet> selector) - { - foreach (var item in self) - yield return selector (item); - } - - public static IEnumerable<T> Where<T> (this IEnumerable<T> self, Func<T, bool> predicate) - { - foreach (var item in self) - if (predicate (item)) - yield return item; - } - - public static List<T> ToList<T> (this IEnumerable<T> self) - { - return new List<T> (self); - } - - public static T [] ToArray<T> (this IEnumerable<T> self) - { - return self.ToList ().ToArray (); - } - - public static T First<T> (this IEnumerable<T> self) - { - using (var enumerator = self.GetEnumerator ()) { - if (!enumerator.MoveNext ()) - throw new InvalidOperationException (); - - return enumerator.Current; - } - } - - public static T First<T> (this IEnumerable<T> self, Func<T, bool> predicate) - { - return self.Where (t => predicate (t)).First (); - } - } -} - -#endif diff --git a/rocks/Mono.Cecil.Rocks.csproj b/rocks/Mono.Cecil.Rocks.csproj index 79d3a49..52576c6 100644 --- a/rocks/Mono.Cecil.Rocks.csproj +++ b/rocks/Mono.Cecil.Rocks.csproj @@ -25,5 +25,5 @@ </ProjectReference> </ItemGroup> <Import Project="..\Mono.Cecil.settings" /> - <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> + <Import Project="$(MSBuildCSharpTargets)" /> </Project>
\ No newline at end of file diff --git a/rocks/Mono.Cecil.Rocks/SecurityDeclarationRocks.cs b/rocks/Mono.Cecil.Rocks/SecurityDeclarationRocks.cs index e901081..5c75172 100644 --- a/rocks/Mono.Cecil.Rocks/SecurityDeclarationRocks.cs +++ b/rocks/Mono.Cecil.Rocks/SecurityDeclarationRocks.cs @@ -8,8 +8,6 @@ // Licensed under the MIT/X11 license. // -#if !SILVERLIGHT && !CF - using System; using System.Security; using SSP = System.Security.Permissions; @@ -152,5 +150,3 @@ namespace Mono.Cecil.Rocks { } } } - -#endif diff --git a/rocks/Test/Mono.Cecil.Rocks.Tests.csproj b/rocks/Test/Mono.Cecil.Rocks.Tests.csproj index bd03aa2..be0f3eb 100644 --- a/rocks/Test/Mono.Cecil.Rocks.Tests.csproj +++ b/rocks/Test/Mono.Cecil.Rocks.Tests.csproj @@ -32,5 +32,5 @@ <Content Include="Resources\assemblies\decsec-xml.dll" /> </ItemGroup> <Import Project="..\..\Mono.Cecil.Tests.settings" /> - <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> + <Import Project="$(MSBuildCSharpTargets)" /> </Project>
\ No newline at end of file diff --git a/symbols/mdb/Mono.Cecil.Mdb.csproj b/symbols/mdb/Mono.Cecil.Mdb.csproj index 2161dc7..8882a96 100644 --- a/symbols/mdb/Mono.Cecil.Mdb.csproj +++ b/symbols/mdb/Mono.Cecil.Mdb.csproj @@ -30,5 +30,5 @@ <Compile Include="Mono.CompilerServices.SymbolWriter\SymbolWriterImpl.cs" /> </ItemGroup> <Import Project="..\..\Mono.Cecil.settings" /> - <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> + <Import Project="$(MSBuildCSharpTargets)" /> </Project>
\ No newline at end of file diff --git a/symbols/mdb/Test/Mono.Cecil.Mdb.Tests.csproj b/symbols/mdb/Test/Mono.Cecil.Mdb.Tests.csproj index 3cc0242..c9d2904 100644 --- a/symbols/mdb/Test/Mono.Cecil.Mdb.Tests.csproj +++ b/symbols/mdb/Test/Mono.Cecil.Mdb.Tests.csproj @@ -27,5 +27,5 @@ <Content Include="Resources\assemblies\hello.exe.mdb" /> </ItemGroup> <Import Project="..\..\..\Mono.Cecil.Tests.settings" /> - <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> + <Import Project="$(MSBuildCSharpTargets)" /> </Project>
\ No newline at end of file diff --git a/symbols/pdb/Mono.Cecil.Pdb.csproj b/symbols/pdb/Mono.Cecil.Pdb.csproj index 76da79a..231d053 100644 --- a/symbols/pdb/Mono.Cecil.Pdb.csproj +++ b/symbols/pdb/Mono.Cecil.Pdb.csproj @@ -50,5 +50,5 @@ <Compile Include="Mono.Cecil.Pdb\SymWriter.cs" /> </ItemGroup> <Import Project="..\..\Mono.Cecil.settings" /> - <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> + <Import Project="$(MSBuildCSharpTargets)" /> </Project>
\ No newline at end of file diff --git a/symbols/pdb/Test/Mono.Cecil.Pdb.Tests.csproj b/symbols/pdb/Test/Mono.Cecil.Pdb.Tests.csproj index 27bb988..bdd6fc5 100644 --- a/symbols/pdb/Test/Mono.Cecil.Pdb.Tests.csproj +++ b/symbols/pdb/Test/Mono.Cecil.Pdb.Tests.csproj @@ -20,7 +20,6 @@ </ProjectReference> </ItemGroup> <ItemGroup> - <Compile Include="Mono.Cecil.Tests\Linq.cs" /> <Compile Include="Mono.Cecil.Tests\PdbTests.cs" /> </ItemGroup> <ItemGroup> @@ -32,5 +31,5 @@ <Content Include="Resources\assemblies\VBConsApp.pdb" /> </ItemGroup> <Import Project="..\..\..\Mono.Cecil.Tests.settings" /> - <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> + <Import Project="$(MSBuildCSharpTargets)" /> </Project>
\ No newline at end of file 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, TResult> (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<TRet> Select<TItem, TRet> (this IEnumerable<TItem> self, Func<TItem, TRet> selector) - { - foreach (var item in self) - yield return selector (item); - } - - public static IEnumerable<T> Where<T> (this IEnumerable<T> self, Func<T, bool> predicate) - { - foreach (var item in self) - if (predicate (item)) - yield return item; - } - - public static T First<T> (this IEnumerable<T> self) - { - using (var enumerator = self.GetEnumerator ()) { - if (!enumerator.MoveNext ()) - throw new InvalidOperationException (); - - return enumerator.Current; - } - } - } -} - -#endif |