Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/linker.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Directory.Build.props8
-rw-r--r--Directory.Build.targets4
-rw-r--r--README.md42
-rw-r--r--eng/azure-pipelines.yml16
-rw-r--r--monobuild/Makefile13
-rw-r--r--monolinker.sln64
-rw-r--r--src/analyzer/analyzer.csproj9
-rw-r--r--src/linker/AUTHORS1
-rw-r--r--src/linker/Directory.Build.props2
-rw-r--r--src/linker/Linker.Steps/DynamicDependencyLookupStep.cs4
-rw-r--r--src/linker/Linker.Steps/LoadI18nAssemblies.cs105
-rw-r--r--src/linker/Linker.Steps/MarkStep.cs53
-rw-r--r--src/linker/Linker.Steps/PreserveCalendarsStep.cs74
-rw-r--r--src/linker/Linker.Steps/RemoveFeaturesStep.cs362
-rw-r--r--src/linker/Linker.Steps/ResolveFromAssemblyStep.cs216
-rw-r--r--src/linker/Linker.Steps/ResolveFromXApiStep.cs140
-rw-r--r--src/linker/Linker.Steps/ResolveFromXmlStep.cs69
-rw-r--r--src/linker/Linker.Steps/SweepStep.cs5
-rw-r--r--src/linker/Linker/AssemblyResolver.cs29
-rw-r--r--src/linker/Linker/DirectoryAssemblyResolver.cs10
-rw-r--r--src/linker/Linker/Driver.cs167
-rw-r--r--src/linker/Linker/I18nAssemblies.cs49
-rw-r--r--src/linker/Linker/LinkContext.cs14
-rw-r--r--src/linker/Linker/MethodDefinitionExtensions.cs15
-rw-r--r--src/linker/Linker/XApiReader.cs386
-rw-r--r--src/linker/MIT.X1121
-rw-r--r--src/linker/Mono.Linker.csproj28
-rw-r--r--src/linker/System.Diagnostics.CodeAnalysis/DynamicDependencyAttribute.cs14
-rw-r--r--src/linker/System.Diagnostics.CodeAnalysis/DynamicallyAccessedMemberTypes.cs94
-rw-r--r--src/linker/System.Diagnostics.CodeAnalysis/RequiresUnreferencedCodeAttribute.cs43
-rw-r--r--src/linker/profiler/Makefile8
-rw-r--r--src/linker/profiler/link.c362
-rw-r--r--src/tuner/Mono.Tuner.csproj71
-rw-r--r--src/tuner/Mono.Tuner/AdjustVisibility.cs164
-rw-r--r--src/tuner/Mono.Tuner/ApplyPreserveAttributeBase.cs164
-rw-r--r--src/tuner/Mono.Tuner/CecilRocks.cs519
-rw-r--r--src/tuner/Mono.Tuner/CheckVisibility.cs375
-rw-r--r--src/tuner/Mono.Tuner/CustomizeActions.cs93
-rw-r--r--src/tuner/Mono.Tuner/Dispatcher.cs310
-rw-r--r--src/tuner/Mono.Tuner/Extensions.cs36
-rw-r--r--src/tuner/Mono.Tuner/FilterAttributes.cs157
-rw-r--r--src/tuner/Mono.Tuner/FixModuleFlags.cs20
-rw-r--r--src/tuner/Mono.Tuner/InjectSecurityAttributes.cs500
-rw-r--r--src/tuner/Mono.Tuner/MarkNSObjectsBase.cs149
-rw-r--r--src/tuner/Mono.Tuner/MoonlightA11yApiMarker.cs88
-rw-r--r--src/tuner/Mono.Tuner/MoonlightA11yAssemblyStep.cs54
-rw-r--r--src/tuner/Mono.Tuner/MoonlightA11yDescriptorGenerator.cs337
-rw-r--r--src/tuner/Mono.Tuner/MoonlightA11yProcessor.cs179
-rw-r--r--src/tuner/Mono.Tuner/MoonlightA11yUsageInspectionStep.cs52
-rw-r--r--src/tuner/Mono.Tuner/MoonlightAssemblyStep.cs66
-rw-r--r--src/tuner/Mono.Tuner/PreserveCrypto.cs122
-rw-r--r--src/tuner/Mono.Tuner/PreserveHttps.cs83
-rw-r--r--src/tuner/Mono.Tuner/PreserveSoapHttpClients.cs90
-rw-r--r--src/tuner/Mono.Tuner/PrintStatus.cs86
-rw-r--r--src/tuner/Mono.Tuner/PrintTypeMap.cs71
-rw-r--r--src/tuner/Mono.Tuner/Profile.cs78
-rw-r--r--src/tuner/Mono.Tuner/RemoveAttributesBase.cs119
-rw-r--r--src/tuner/Mono.Tuner/RemoveResources.cs63
-rw-r--r--src/tuner/Mono.Tuner/RemoveSecurity.cs50
-rw-r--r--src/tuner/Mono.Tuner/RemoveSerialization.cs149
-rw-r--r--src/tuner/Mono.Tuner/TunerAnnotations.cs55
-rw-r--r--src/tuner/MonoMac.Tuner/ApplyPreserveAttribute.cs21
-rw-r--r--src/tuner/MonoMac.Tuner/Extensions.cs27
-rw-r--r--src/tuner/MonoMac.Tuner/MarkNSObjects.cs53
-rw-r--r--src/tuner/MonoMac.Tuner/MethodMapInjection.cs382
-rw-r--r--src/tuner/MonoMac.Tuner/MonoMac.xml38
-rw-r--r--src/tuner/MonoMac.Tuner/MonoMacProfile.cs117
-rw-r--r--src/tuner/MonoMac.Tuner/RemoveSelectors.cs189
-rw-r--r--test/ILLink.RoslynAnalyzer.Tests/ILLink.RoslynAnalyzer.Tests.csproj1
-rw-r--r--test/ILLink.RoslynAnalyzer.Tests/TestCaseUtils.cs20
-rw-r--r--test/Mono.Linker.Tests.Cases.Expectations/Mono.Linker.Tests.Cases.Expectations.csproj9
-rw-r--r--test/Mono.Linker.Tests.Cases.Expectations/System.Diagnostics.CodeAnalysis/DynamicDependencyAttribute.cs136
-rw-r--r--test/Mono.Linker.Tests.Cases.Expectations/System.Diagnostics.CodeAnalysis/DynamicallyAccessedMemberTypes.cs94
-rw-r--r--test/Mono.Linker.Tests.Cases.Expectations/System.Diagnostics.CodeAnalysis/DynamicallyAccessedMembersAttribute.cs45
-rw-r--r--test/Mono.Linker.Tests.Cases.Expectations/System.Diagnostics.CodeAnalysis/RequiresUnreferencedCodeAttribute.cs43
-rw-r--r--test/Mono.Linker.Tests.Cases.Expectations/System.Diagnostics.CodeAnalysis/UnconditionalSuppressMessageAttribute.cs93
-rw-r--r--test/Mono.Linker.Tests.Cases/Attributes/OnlyKeepUsed/NullableOnConstraints.cs3
-rw-r--r--test/Mono.Linker.Tests.Cases/DataFlow/IReflectDataflow.cs4
-rw-r--r--test/Mono.Linker.Tests.Cases/LinkAttributes/LinkerAttributeRemoval.cs6
-rw-r--r--test/Mono.Linker.Tests.Cases/Mono.Linker.Tests.Cases.csproj9
-rw-r--r--test/Mono.Linker.Tests.Cases/UnreachableBlock/SizeOfInConditions.cs2
-rw-r--r--test/Mono.Linker.Tests.Cases/Warnings/Individual/CanGenerateWarningSuppressionFileCSharp.cs6
-rw-r--r--test/Mono.Linker.Tests.Cases/Warnings/Individual/CanGenerateWarningSuppressionFileXml.cs2
-rw-r--r--test/Mono.Linker.Tests.Cases/Warnings/Individual/WarningsAreSorted.cs2
-rw-r--r--test/Mono.Linker.Tests.Cases/Warnings/WarningSuppression/AddSuppressionsBeforeAttributeRemoval.cs2
-rw-r--r--test/Mono.Linker.Tests.Cases/Warnings/WarningSuppression/SuppressWarningsInAssembly.cs2
-rw-r--r--test/Mono.Linker.Tests.Cases/Warnings/WarningSuppression/SuppressWarningsInMembersAndTypes.cs2
-rw-r--r--test/Mono.Linker.Tests.Cases/Warnings/WarningSuppression/SuppressWarningsInMembersAndTypesUsingTarget.cs2
-rw-r--r--test/Mono.Linker.Tests.Cases/Warnings/WarningSuppression/SuppressWarningsInModule.cs2
-rw-r--r--test/Mono.Linker.Tests.Cases/Warnings/WarningSuppression/SuppressWarningsUsingTargetViaXml.cs5
-rw-r--r--test/Mono.Linker.Tests/Mono.Linker.Tests.csproj22
-rw-r--r--test/Mono.Linker.Tests/TestCasesRunner/ILCompiler.cs4
-rw-r--r--test/Mono.Linker.Tests/TestCasesRunner/PathUtilities.cs8
93 files changed, 82 insertions, 7996 deletions
diff --git a/Directory.Build.props b/Directory.Build.props
index 920bc6e1c..7f80dfe27 100644
--- a/Directory.Build.props
+++ b/Directory.Build.props
@@ -1,9 +1,5 @@
<Project>
<PropertyGroup>
- <MonoBuild Condition="'$(MonoBuild)' == '' and '$(SolutionName)' == 'monolinker'">true</MonoBuild>
- </PropertyGroup>
-
- <PropertyGroup>
<IsReferenceAssembly Condition="'$(IsReferenceAssembly)' == '' and '$([System.IO.Path]::GetFileName($(MSBuildProjectDirectory)))' == 'ref'">true</IsReferenceAssembly>
</PropertyGroup>
<PropertyGroup Condition=" '$(IsReferenceAssembly)' == 'true' ">
@@ -17,9 +13,7 @@
<RunApiCompat>false</RunApiCompat>
</PropertyGroup>
- <Import Project="Sdk.props" Sdk="Microsoft.DotNet.Arcade.Sdk" Condition="'$(MonoBuild)' == ''" />
- <!-- Still use global versions even if not using arcade. -->
- <Import Project="eng/Versions.props" Condition="'$(MonoBuild)' != ''" />
+ <Import Project="Sdk.props" Sdk="Microsoft.DotNet.Arcade.Sdk" />
<Import Project="eng/Analyzers.props" />
<PropertyGroup>
<IsPackable>false</IsPackable>
diff --git a/Directory.Build.targets b/Directory.Build.targets
index c8d68655d..e107f5aa8 100644
--- a/Directory.Build.targets
+++ b/Directory.Build.targets
@@ -1,5 +1,5 @@
<Project>
- <Import Project="Sdk.targets" Sdk="Microsoft.DotNet.Arcade.Sdk" Condition="'$(MonoBuild)' == ''" />
+ <Import Project="Sdk.targets" Sdk="Microsoft.DotNet.Arcade.Sdk" />
<Import Project="$(_ToolsProjectTargets)" Condition="Exists('$(_ToolsProjectTargets)')" />
@@ -10,7 +10,7 @@
<!-- Shared logic for reference assemblies. This enables apicompat and
packaging logic for projects that have corresponding reference assemblies. -->
- <PropertyGroup Condition="'$(MonoBuild)' == ''">
+ <PropertyGroup>
<ContractProject Condition="'$(ContractProject)' == ''">$(MSBuildProjectDirectory)\ref\$(MSBuildProjectName).csproj</ContractProject>
<HasMatchingContract Condition="Exists('$(ContractProject)')">true</HasMatchingContract>
<RunApiCompat Condition="'$(HasMatchingContract)' != 'true'">false</RunApiCompat>
diff --git a/README.md b/README.md
index f9a4b2bdb..45ac8dff0 100644
--- a/README.md
+++ b/README.md
@@ -1,20 +1,31 @@
-# IL Linker
+# Trimming Tools
-The [IL Linker](src/linker/README.md) is a tool one can use to only ship the minimal possible IL code and metadata that a set of
-programs might require to run as opposed to the full libraries.
+This repository hosts various tools and msbuild tasks which are used when trimming managed applications with .NET 5 and newer.
-It is used by the various Xamarin products to extract only the bits of code that are needed to run
-an application on Android, iOS and other platforms.
+## IL Linker
-It can also be used in the form of [ILLink.Tasks](src/ILLink.Tasks/README.md) to reduce the size of .NET Core apps.
+The [IL Linker](src/linker/README.md) is the developer's tool that can be used to produce apps that contain only code and assembly dependencies which are necessary to run the app. It's fully integrated into
+.NET SDKs via [ILLink.Tasks](src/ILLink.Tasks/README.md) build task and exposed via `dotnet publish` trimming [settings](https://docs.microsoft.com/en-us/dotnet/core/deploying/trim-self-contained#trim-your-app---cli).
-# Analyzer
+The linker is always enabled for all size sensitive .NET workloads like Blazor WebAssembly, Xamarin or .NET mobile and can be manually enabled for other project types. The default apps trimming setting can be further customized by using a number of [msbuild properties](https://docs.microsoft.com/en-us/dotnet/core/deploying/trimming-options).
-The [analyzer](src/analyzer/README.md) is a tool to analyze dependencies which were recorded during linker processing and led linker to mark an item to keep it in the resulting linked assembly.
+## Dependencies Analyzer
-It can be used to better understand the dependencies between different metadata members to help further reduce the linked output.
+The [analyzer](src/analyzer/README.md) is a tool to analyze dependencies which were recorded during linker processing. It tracks details about reasons and connection between elements to keep it in the resulting linked assembly. It can be used to better understand the dependencies between different types and members to help further reduce the linked output.
-## How to build the IL Linker
+## Trimming Lens
+
+The [tlens](src/tlens/README.md) is another tool for developers which can be used to explore ways to reduce the size of trimmed apps or exploring libraries readiness for trimming. The tool produces a recommendation where the compiled source could be improved to produce even smaller outputs when trimmed using the linker.
+
+## Source Code Analyzer
+
+Another tool available for developers is implemented as [Roslyn Analyzer](src/ILLink.RoslynAnalyzer) which runs on source code and warns developers about code patterns and APIs which are problematic when building code which could be used with trimmed apps.
+
+# Contributing
+
+We welcome contributions! Many developers have helped make this project better by reporting [issues](https://github.com/mono/linker/issues) or contributing [pull requests](https://github.com/mono/linker/pulls).
+
+## How to build all projects
There is a shell script available in the root folder which can build the whole project and much more (build.cmd on Windows).
@@ -22,8 +33,15 @@ There is a shell script available in the root folder which can build the whole p
./build.sh
```
-## Build & Test Status
+## Running tests from CLI
+
+The same script can be used to run all tests from the terminal. We also have integration into Visual Studio and individual tests or whole test suites can be run within IDE as well.
+
+```sh
+./build.sh -test
+```
+
-**.NET Core / Mono**
+## CI Build & Test Status
[![Build Status](https://dev.azure.com/dnceng/public/_apis/build/status/mono/linker-ci?branchName=master)](https://dev.azure.com/dnceng/public/_build/latest?definitionId=364&branchName=master)
diff --git a/eng/azure-pipelines.yml b/eng/azure-pipelines.yml
index 4a361c728..92ca830ad 100644
--- a/eng/azure-pipelines.yml
+++ b/eng/azure-pipelines.yml
@@ -126,22 +126,6 @@ stages:
submodules: true
- script: ./lint.sh --check
- - ${{ if eq(variables.officialBuild, 'false') }}:
- - job: Linux_Mono
- pool:
- name: Hosted Ubuntu 1604
- steps:
- - checkout: self
- submodules: true
- - script: |
- mono --version
- make -C monobuild CONFIGURATION=$(_BuildConfig)
- displayName: Build and test
- - task: PublishTestResults@2
- inputs:
- testResultsFormat: 'NUnit'
- testResultsFiles: 'test/Mono.Linker.Tests/TestResults.xml'
-
# Post-Build Arcade logic
- ${{ if eq(variables.officialBuild, 'true') }}:
- template: /eng/common/templates/post-build/post-build.yml
diff --git a/monobuild/Makefile b/monobuild/Makefile
deleted file mode 100644
index aff96e692..000000000
--- a/monobuild/Makefile
+++ /dev/null
@@ -1,13 +0,0 @@
-MSBUILD = msbuild
-CONFIGURATION = Debug
-
-all: build check
-
-build:
- $(MSBUILD) ../monolinker.sln /restore /p:Configuration=$(CONFIGURATION) /p:MonoBuild=true
-
-clean:
- $(MSBUILD) ../monolinker.sln /p:MonoBuild=true /t:clean
-
-check:
- $(MSBUILD) ../test/Mono.Linker.Tests/Mono.Linker.Tests.csproj /p:MonoBuild=true /t:RunTestsOnMono
diff --git a/monolinker.sln b/monolinker.sln
deleted file mode 100644
index ca9420ded..000000000
--- a/monolinker.sln
+++ /dev/null
@@ -1,64 +0,0 @@
-
-Microsoft Visual Studio Solution File, Format Version 12.00
-# Visual Studio 15
-VisualStudioVersion = 15.0.26403.7
-MinimumVisualStudioVersion = 10.0.40219.1
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Mono.Linker", "src\linker\Mono.Linker.csproj", "{DD28E2B1-057B-4B4D-A04D-B2EBD9E76E46}"
-EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Mono.Linker.Tests", "test\Mono.Linker.Tests\Mono.Linker.Tests.csproj", "{400A1561-B6B6-482D-9E4C-3DDAEDE5BD07}"
-EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Mono.Linker.Tests.Cases", "test\Mono.Linker.Tests.Cases\Mono.Linker.Tests.Cases.csproj", "{B6BEE6AA-ADA0-4E1D-9A17-FBF2936F82B5}"
-EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Mono.Linker.Tests.Cases.Expectations", "test\Mono.Linker.Tests.Cases.Expectations\Mono.Linker.Tests.Cases.Expectations.csproj", "{2C26601F-3E2F-45B9-A02F-58EE9296E19E}"
-EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Mono.Cecil", "external\cecil\Mono.Cecil.csproj", "{5E89AB62-1526-41F7-AAA3-D9119C9451EA}"
-EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Mono.Cecil.Mdb", "external\cecil\symbols\mdb\Mono.Cecil.Mdb.csproj", "{76602591-ACB6-42DF-A6F6-8FE64B0E929F}"
-EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Mono.Cecil.Pdb", "external\cecil\symbols\pdb\Mono.Cecil.Pdb.csproj", "{EC2FE89A-5B34-425A-BBCC-F28E5BA3EE2A}"
-EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "analyzer", "src\analyzer\analyzer.csproj", "{0DF04C42-2EFE-44B9-BDE3-1C804D7DC67A}"
-EndProject
-Global
- GlobalSection(SolutionConfigurationPlatforms) = preSolution
- Debug|Any CPU = Debug|Any CPU
- Release|Any CPU = Release|Any CPU
- EndGlobalSection
- GlobalSection(ProjectConfigurationPlatforms) = postSolution
- {DD28E2B1-057B-4B4D-A04D-B2EBD9E76E46}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {DD28E2B1-057B-4B4D-A04D-B2EBD9E76E46}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {DD28E2B1-057B-4B4D-A04D-B2EBD9E76E46}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {DD28E2B1-057B-4B4D-A04D-B2EBD9E76E46}.Release|Any CPU.Build.0 = Release|Any CPU
- {400A1561-B6B6-482D-9E4C-3DDAEDE5BD07}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {400A1561-B6B6-482D-9E4C-3DDAEDE5BD07}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {400A1561-B6B6-482D-9E4C-3DDAEDE5BD07}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {400A1561-B6B6-482D-9E4C-3DDAEDE5BD07}.Release|Any CPU.Build.0 = Release|Any CPU
- {B6BEE6AA-ADA0-4E1D-9A17-FBF2936F82B5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {B6BEE6AA-ADA0-4E1D-9A17-FBF2936F82B5}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {B6BEE6AA-ADA0-4E1D-9A17-FBF2936F82B5}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {B6BEE6AA-ADA0-4E1D-9A17-FBF2936F82B5}.Release|Any CPU.Build.0 = Release|Any CPU
- {2C26601F-3E2F-45B9-A02F-58EE9296E19E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {2C26601F-3E2F-45B9-A02F-58EE9296E19E}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {2C26601F-3E2F-45B9-A02F-58EE9296E19E}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {2C26601F-3E2F-45B9-A02F-58EE9296E19E}.Release|Any CPU.Build.0 = Release|Any CPU
- {5E89AB62-1526-41F7-AAA3-D9119C9451EA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {5E89AB62-1526-41F7-AAA3-D9119C9451EA}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {5E89AB62-1526-41F7-AAA3-D9119C9451EA}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {5E89AB62-1526-41F7-AAA3-D9119C9451EA}.Release|Any CPU.Build.0 = Release|Any CPU
- {76602591-ACB6-42DF-A6F6-8FE64B0E929F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {76602591-ACB6-42DF-A6F6-8FE64B0E929F}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {76602591-ACB6-42DF-A6F6-8FE64B0E929F}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {76602591-ACB6-42DF-A6F6-8FE64B0E929F}.Release|Any CPU.Build.0 = Release|Any CPU
- {EC2FE89A-5B34-425A-BBCC-F28E5BA3EE2A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {EC2FE89A-5B34-425A-BBCC-F28E5BA3EE2A}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {EC2FE89A-5B34-425A-BBCC-F28E5BA3EE2A}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {EC2FE89A-5B34-425A-BBCC-F28E5BA3EE2A}.Release|Any CPU.Build.0 = Release|Any CPU
- {0DF04C42-2EFE-44B9-BDE3-1C804D7DC67A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {0DF04C42-2EFE-44B9-BDE3-1C804D7DC67A}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {0DF04C42-2EFE-44B9-BDE3-1C804D7DC67A}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {0DF04C42-2EFE-44B9-BDE3-1C804D7DC67A}.Release|Any CPU.Build.0 = Release|Any CPU
- EndGlobalSection
- GlobalSection(SolutionProperties) = preSolution
- HideSolutionNode = FALSE
- EndGlobalSection
-EndGlobal
diff --git a/src/analyzer/analyzer.csproj b/src/analyzer/analyzer.csproj
index 90eeaa7da..5f704947d 100644
--- a/src/analyzer/analyzer.csproj
+++ b/src/analyzer/analyzer.csproj
@@ -7,15 +7,10 @@
<LangVersion>latest</LangVersion>
</PropertyGroup>
- <PropertyGroup Condition="'$(MonoBuild)' == ''">
- <DefineConstants>$(DefineConstants);FEATURE_ILLINK</DefineConstants>
+ <PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
</PropertyGroup>
- <PropertyGroup Condition="'$(MonoBuild)' != ''">
- <TargetFrameworks>net471</TargetFrameworks>
- </PropertyGroup>
-
<ItemGroup>
<Compile Include="..\..\external\Mono.Options\*.cs" />
</ItemGroup>
@@ -25,7 +20,7 @@
<ProjectReference Condition="'$(UseCecilPackage)' != 'true'" Include="../../external/cecil/Mono.Cecil.csproj" />
</ItemGroup>
- <ItemGroup Condition="'$(MonoBuild)' == ''">
+ <ItemGroup>
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" PrivateAssets="All" Version="1.0.0" />
</ItemGroup>
diff --git a/src/linker/AUTHORS b/src/linker/AUTHORS
deleted file mode 100644
index 4af5896a1..000000000
--- a/src/linker/AUTHORS
+++ /dev/null
@@ -1 +0,0 @@
-Jb Evain <jbevain@novell.com>
diff --git a/src/linker/Directory.Build.props b/src/linker/Directory.Build.props
index 1fad0962e..8d29a55dc 100644
--- a/src/linker/Directory.Build.props
+++ b/src/linker/Directory.Build.props
@@ -7,7 +7,7 @@
<LangVersion>latest</LangVersion>
</PropertyGroup>
- <PropertyGroup Condition="'$(MonoBuild)' == ''">
+ <PropertyGroup>
<AssemblyName>illink</AssemblyName>
<Description>IL Linker</Description>
<PackageId>Microsoft.NET.ILLink</PackageId>
diff --git a/src/linker/Linker.Steps/DynamicDependencyLookupStep.cs b/src/linker/Linker.Steps/DynamicDependencyLookupStep.cs
index 61d072373..f2a7adef1 100644
--- a/src/linker/Linker.Steps/DynamicDependencyLookupStep.cs
+++ b/src/linker/Linker.Steps/DynamicDependencyLookupStep.cs
@@ -62,9 +62,9 @@ namespace Mono.Linker.Steps
foreach (var ca in member.CustomAttributes) {
if (!IsPreserveDependencyAttribute (ca.AttributeType))
continue;
-#if FEATURE_ILLINK
+
Context.LogWarning ($"'PreserveDependencyAttribute' is deprecated. Use 'DynamicDependencyAttribute' instead.", 2033, member);
-#endif
+
if (ca.ConstructorArguments.Count != 3)
continue;
diff --git a/src/linker/Linker.Steps/LoadI18nAssemblies.cs b/src/linker/Linker.Steps/LoadI18nAssemblies.cs
deleted file mode 100644
index 03b0763b9..000000000
--- a/src/linker/Linker.Steps/LoadI18nAssemblies.cs
+++ /dev/null
@@ -1,105 +0,0 @@
-//
-// LoadI18nAssemblies.cs
-//
-// Author:
-// Jb Evain (jbevain@novell.com)
-//
-// (C) 2007 Novell, Inc.
-//
-// 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.
-//
-
-using System;
-using System.Linq;
-using Mono.Cecil;
-
-namespace Mono.Linker.Steps
-{
-
- public class LoadI18nAssemblies : BaseStep
- {
-
- static readonly byte[] _pktoken = new byte[] { 0x07, 0x38, 0xeb, 0x9f, 0x13, 0x2e, 0xd7, 0x56 };
-
- I18nAssemblies _assemblies;
-
- public LoadI18nAssemblies (I18nAssemblies assemblies)
- {
- _assemblies = assemblies;
- }
-
- protected override bool ConditionToProcess ()
- {
- return _assemblies != I18nAssemblies.None &&
- Context.GetAssemblies ().FirstOrDefault (a => a.Name.Name == "mscorlib")?.MainModule.GetType ("System.MonoType") != null;
- }
-
- protected override void Process ()
- {
- LoadAssembly (GetAssemblyName (I18nAssemblies.Base));
-
- LoadI18nAssembly (I18nAssemblies.CJK);
- LoadI18nAssembly (I18nAssemblies.MidEast);
- LoadI18nAssembly (I18nAssemblies.Other);
- LoadI18nAssembly (I18nAssemblies.Rare);
- LoadI18nAssembly (I18nAssemblies.West);
- }
-
- bool ShouldCopyAssembly (I18nAssemblies current)
- {
- return (current & _assemblies) != 0;
- }
-
- void LoadI18nAssembly (I18nAssemblies asm)
- {
- if (!ShouldCopyAssembly (asm))
- return;
-
- AssemblyNameReference name = GetAssemblyName (asm);
- LoadAssembly (name);
- }
-
- void LoadAssembly (AssemblyNameReference name)
- {
- AssemblyDefinition assembly = Context.Resolve (name);
- Context.Annotations.SetAction (assembly, AssemblyAction.Copy);
- ResolveFromAssemblyStep.ProcessLibrary (Context, assembly, ResolveFromAssemblyStep.RootVisibility.Any);
- }
-
- AssemblyNameReference GetAssemblyName (I18nAssemblies assembly)
- {
- AssemblyNameReference name = new AssemblyNameReference ("I18N", GetCorlibVersion ());
- if (assembly != I18nAssemblies.Base)
- name.Name += "." + assembly;
-
- name.PublicKeyToken = _pktoken;
- return name;
- }
-
- Version GetCorlibVersion ()
- {
- foreach (AssemblyDefinition assembly in Context.GetAssemblies ())
- if (assembly.Name.Name == "mscorlib")
- return assembly.Name.Version;
-
- return new Version ();
- }
- }
-}
diff --git a/src/linker/Linker.Steps/MarkStep.cs b/src/linker/Linker.Steps/MarkStep.cs
index 1c1de17af..047550e5c 100644
--- a/src/linker/Linker.Steps/MarkStep.cs
+++ b/src/linker/Linker.Steps/MarkStep.cs
@@ -60,9 +60,6 @@ namespace Mono.Linker.Steps
static readonly DependencyKind[] _entireTypeReasons = new DependencyKind[] {
DependencyKind.Unspecified,
DependencyKind.NestedType,
-#if !FEATURE_ILLINK
- DependencyKind.PreservedDependency,
-#endif
DependencyKind.DynamicDependency,
DependencyKind.TypeInAssembly,
DependencyKind.AccessedViaReflection,
@@ -81,9 +78,6 @@ namespace Mono.Linker.Steps
DependencyKind.InteropMethodDependency,
DependencyKind.Ldtoken,
DependencyKind.MemberOfType,
-#if !FEATURE_ILLINK
- DependencyKind.PreservedDependency,
-#endif
DependencyKind.DynamicDependency,
DependencyKind.ReferencedBySpecialAttribute,
DependencyKind.TypePreserve,
@@ -150,9 +144,6 @@ namespace Mono.Linker.Steps
DependencyKind.Newobj,
DependencyKind.Override,
DependencyKind.OverrideOnInstantiatedType,
-#if !FEATURE_ILLINK
- DependencyKind.PreservedDependency,
-#endif
DependencyKind.DynamicDependency,
DependencyKind.PreservedMethod,
DependencyKind.ReferencedBySpecialAttribute,
@@ -1381,20 +1372,13 @@ namespace Mono.Linker.Steps
protected virtual void MarkSerializable (TypeDefinition type)
{
-#if !FEATURE_ILLINK
- // Keep default ctor for XmlSerializer support. See https://github.com/mono/linker/issues/957
- MarkDefaultConstructor (type, new DependencyInfo (DependencyKind.SerializationMethodForType, type), type);
-
- if (_context.IsFeatureExcluded ("deserialization"))
- return;
-#else
// TODO: move after the check once SPC is correctly annotated
MarkDefaultConstructor (type, new DependencyInfo (DependencyKind.SerializationMethodForType, type), type);
// TODO: blocked for now by libraries build issue explained at https://github.com/mono/linker/issues/1603
//if (_context.GetTargetRuntimeVersion () > TargetRuntimeVersion.NET5)
// return;
-#endif
+
MarkMethodsIf (type.Methods, IsSpecialSerializationConstructor, new DependencyInfo (DependencyKind.SerializationMethodForType, type), type);
}
@@ -1497,12 +1481,7 @@ namespace Mono.Linker.Steps
// TODO: This needs work to ensure we handle EventSource appropriately.
// This marks static fields of KeyWords/OpCodes/Tasks subclasses of an EventSource type.
- if (
-#if !FEATURE_ILLINK
- !_context.IsFeatureExcluded ("etw") &&
-#endif
- BCL.EventTracingForWindows.IsEventSourceImplementation (type, _context)
- ) {
+ if (BCL.EventTracingForWindows.IsEventSourceImplementation (type, _context)) {
MarkEventSourceProviders (type);
}
@@ -1545,14 +1524,7 @@ namespace Mono.Linker.Steps
if (ShouldMarkTypeStaticConstructor (type) && reason.Kind != DependencyKind.TriggersCctorForCalledMethod)
MarkStaticConstructor (type, new DependencyInfo (DependencyKind.CctorForType, type), type);
-#if !FEATURE_ILLINK
- if (_context.IsFeatureExcluded ("deserialization")) {
- MarkMethodsIf (type.Methods, HasOnSerializeAttribute, new DependencyInfo (DependencyKind.SerializationMethodForType, type), type);
- } else
-#endif
- {
- MarkMethodsIf (type.Methods, HasOnSerializeOrDeserializeAttribute, new DependencyInfo (DependencyKind.SerializationMethodForType, type), type);
- }
+ MarkMethodsIf (type.Methods, HasOnSerializeOrDeserializeAttribute, new DependencyInfo (DependencyKind.SerializationMethodForType, type), type);
}
DoAdditionalTypeProcessing (type);
@@ -2077,25 +2049,6 @@ namespace Mono.Linker.Steps
return method.Body.Instructions[0].OpCode.Code != Code.Ret;
}
-#if !FEATURE_ILLINK
- static bool HasOnSerializeAttribute (MethodDefinition method)
- {
- if (!method.HasCustomAttributes)
- return false;
- foreach (var ca in method.CustomAttributes) {
- var cat = ca.AttributeType;
- if (cat.Namespace != "System.Runtime.Serialization")
- continue;
- switch (cat.Name) {
- case "OnSerializedAttribute":
- case "OnSerializingAttribute":
- return true;
- }
- }
- return false;
- }
-#endif
-
static bool HasOnSerializeOrDeserializeAttribute (MethodDefinition method)
{
if (!method.HasCustomAttributes)
diff --git a/src/linker/Linker.Steps/PreserveCalendarsStep.cs b/src/linker/Linker.Steps/PreserveCalendarsStep.cs
deleted file mode 100644
index 329429def..000000000
--- a/src/linker/Linker.Steps/PreserveCalendarsStep.cs
+++ /dev/null
@@ -1,74 +0,0 @@
-using Mono.Cecil;
-
-namespace Mono.Linker.Steps
-{
- public class PreserveCalendarsStep : IStep
- {
- readonly I18nAssemblies I18n;
- LinkContext context;
-
- public PreserveCalendarsStep (I18nAssemblies i18n)
- {
- I18n = i18n;
- }
-
- public virtual void Process (LinkContext context)
- {
- //
- // This step is mscorlib specific. We could convert this to complex
- // PreserveDependencyAttribute controlled by I18n but it's not worth it at this point
- //
- AssemblyDefinition mscorlib;
- if (!context.Resolver.AssemblyCache.TryGetValue ("mscorlib", out mscorlib))
- return;
-
- if (context.Annotations.GetAction (mscorlib) != AssemblyAction.Link)
- return;
-
- this.context = context;
-
- if (I18n.HasFlag (I18nAssemblies.MidEast)) {
- PreserveCalendar ("UmAlQuraCalendar", mscorlib);
- PreserveCalendar ("HijriCalendar", mscorlib);
- PreserveCalendar ("PersianCalendar", mscorlib);
- }
-
- if (I18n.HasFlag (I18nAssemblies.Other)) {
- PreserveCalendar ("ThaiBuddhistCalendar", mscorlib);
- }
-
- if (I18n.HasFlag (I18nAssemblies.CJK)) {
- PreserveCalendar ("ChineseLunisolarCalendar", mscorlib);
- PreserveCalendar ("JapaneseCalendar", mscorlib);
- PreserveCalendar ("JapaneseLunisolarCalendar", mscorlib);
- PreserveCalendar ("KoreanCalendar", mscorlib);
- PreserveCalendar ("KoreanLunisolarCalendar", mscorlib);
- PreserveCalendar ("TaiwanCalendar", mscorlib);
- PreserveCalendar ("TaiwanLunisolarCalendar", mscorlib);
- }
-
- if (I18n.HasFlag (I18nAssemblies.Rare)) {
- PreserveCalendar ("JulianCalendar", mscorlib);
- }
- }
-
- void PreserveCalendar (string name, AssemblyDefinition mscorlib)
- {
- var calendar = mscorlib.MainModule.GetType ("System.Globalization", name);
- if (calendar == null || !calendar.HasMethods)
- return;
-
- // we just preserve the default .ctor so Activation.Create will work,
- // the normal linker logic will do the rest
- foreach (MethodDefinition ctor in calendar.Methods) {
- if (ctor.IsConstructor && !ctor.IsStatic && !ctor.HasParameters) {
- context.Annotations.AddPreservedMethod (calendar, ctor);
- // we need to mark the type or the above won't be processed
- context.Annotations.Mark (calendar);
- context.Annotations.MarkIndirectlyCalledMethod (ctor);
- return;
- }
- }
- }
- }
-}
diff --git a/src/linker/Linker.Steps/RemoveFeaturesStep.cs b/src/linker/Linker.Steps/RemoveFeaturesStep.cs
deleted file mode 100644
index 0f3d57295..000000000
--- a/src/linker/Linker.Steps/RemoveFeaturesStep.cs
+++ /dev/null
@@ -1,362 +0,0 @@
-using System.Linq;
-using Mono.Cecil;
-
-namespace Mono.Linker.Steps
-{
- public class RemoveFeaturesStep : BaseStep
- {
- //
- // When any of the features bellow is set, the linker will remove the code and change
- // the behaviour of the program but it should not cause it to crash
- //
-
- public bool FeatureCOM { get; set; }
- public bool FeatureETW { get; set; }
- public bool FeatureSRE { get; set; }
-
- //
- // Manually overrides System.Globalization.Invariant mode
- // https://github.com/dotnet/corefx/blob/master/Documentation/architecture/globalization-invariant-mode.md
- //
- public bool FeatureGlobalization { get; set; }
-
- readonly static string[] MonoCollationResources = new[] {
- "collation.cjkCHS.bin",
- "collation.cjkCHT.bin",
- "collation.cjkJA.bin",
- "collation.cjkKO.bin",
- "collation.cjkKOlv2.bin",
- "collation.core.bin",
- "collation.tailoring.bin"
- };
-
- protected override void ProcessAssembly (AssemblyDefinition assembly)
- {
- if (Annotations.GetAction (assembly) != AssemblyAction.Link)
- return;
-
- foreach (var type in assembly.MainModule.Types)
- ProcessType (type);
-
- if (FeatureGlobalization) {
- foreach (var res in MonoCollationResources) {
- var resource = assembly.FindEmbeddedResource (res);
- if (resource == null)
- continue;
- Context.Annotations.AddResourceToRemove (assembly, resource);
- }
- }
- }
-
- void ProcessType (TypeDefinition type)
- {
- if (FeatureETW) {
- //
- // The pattern here is that EventSource has IsEnabled method(s) which are
- // always called before accessing any other members. We stub them which should
- // make all other members unreachable
- //
- if (BCL.EventTracingForWindows.IsEventSourceType (type))
- ExcludeEventSource (type);
- else if (BCL.EventTracingForWindows.IsEventSourceImplementation (type))
- ExcludeEventSourceImplementation (type);
- }
-
- if (FeatureSRE) {
- if (type.Namespace == "System" && type.Name == "RuntimeType") {
- foreach (var method in type.Methods) {
- if (method.Name == "MakeTypeBuilderInstantiation") {
- Annotations.SetAction (method, MethodAction.ConvertToThrow);
- break;
- }
- }
- }
- if (type.Namespace == "System.Reflection.Emit") {
- foreach (var method in type.Methods)
- Annotations.SetAction (method, MethodAction.ConvertToThrow);
- }
- }
-
- if (FeatureGlobalization)
- ExcludeGlobalization (type);
-
- if (RemoveCustomAttributes (type)) {
- if (FeatureCOM && type.IsImport) {
- type.IsImport = false;
- }
- }
-
- if (FeatureGlobalization)
- ExcludeMonoCollation (type);
-
- foreach (var field in type.Fields)
- RemoveCustomAttributes (field);
-
- foreach (var method in type.Methods)
- RemoveCustomAttributes (method);
-
- foreach (var nested in type.NestedTypes)
- ProcessType (nested);
- }
-
- void ExcludeGlobalization (TypeDefinition type)
- {
- switch (type.Namespace) {
- case "System.Globalization":
- switch (type.Name) {
- case "CalendarData":
- foreach (var method in type.Methods) {
- switch (method.Name) {
- case "GetJapaneseEraNames":
- case "GetJapaneseEnglishEraNames":
- Annotations.SetAction (method, MethodAction.ConvertToThrow);
- break;
- }
- }
- break;
- case "DateTimeFormatInfo":
- foreach (var method in type.Methods) {
- switch (method.Name) {
- case "PopulateSpecialTokenHashTable":
- case "GetJapaneseCalendarDTFI":
- case "GetTaiwanCalendarDTFI":
- case "IsJapaneseCalendar":
- case "TryParseHebrewNumber":
- Annotations.SetAction (method, MethodAction.ConvertToThrow);
- break;
- }
- }
- break;
- }
- break;
- case "System":
- switch (type.Name) {
- case "DateTimeFormat":
- foreach (var method in type.Methods) {
- switch (method.Name) {
- case "HebrewFormatDigits":
- case "FormatHebrewMonthName":
- Annotations.SetAction (method, MethodAction.ConvertToThrow);
- break;
- }
- }
- break;
- case "DateTimeParse":
- foreach (var method in type.Methods) {
- switch (method.Name) {
- case "GetJapaneseCalendarDefaultInstance":
- case "GetTaiwanCalendarDefaultInstance":
- case "ProcessHebrewTerminalState":
- case "GetHebrewDayOfNM":
- case "MatchHebrewDigits":
- Annotations.SetAction (method, MethodAction.ConvertToThrow);
- break;
- }
- }
- break;
- }
- break;
- }
- }
-
- void ExcludeEventSource (TypeDefinition type)
- {
- var annotations = Context.Annotations;
-
- foreach (var method in type.Methods) {
- if (annotations.GetAction (method) != MethodAction.Nothing)
- continue;
-
- if (method.IsStatic)
- continue;
-
- if (method.HasCustomAttributes)
- method.CustomAttributes.Clear ();
-
- if (method.IsDefaultConstructor ()) {
- SetSafestActionForETWMethod (annotations, method, MethodAction.ConvertToStub);
- continue;
- }
-
- if (method.Name == "IsEnabled" || BCL.IsIDisposableImplementation (method) || method.IsFinalizer ()) {
- SetSafestActionForETWMethod (annotations, method, MethodAction.ConvertToStub);
- continue;
- }
-
- SetSafestActionForETWMethod (annotations, method, MethodAction.ConvertToThrow);
- }
- }
-
- void ExcludeEventSourceImplementation (TypeDefinition type)
- {
- var annotations = Context.Annotations;
-
- foreach (var method in type.Methods) {
- if (annotations.GetAction (method) != MethodAction.Nothing)
- continue;
-
- if (method.IsStatic)
- continue;
-
- bool skip = false;
- if (method.HasCustomAttributes) {
- if (!method.IsPrivate) {
- foreach (var attr in method.CustomAttributes) {
- //
- // [NonEvent] attribute is commonly used to mark code which calls
- // IsEnabled we could check for that as well to be more aggressive
- // but for now I haven't seen such code in wild
- //
- if (BCL.EventTracingForWindows.IsNonEventAtribute (attr.AttributeType)) {
- skip = true;
- break;
- }
- }
- }
-
- method.CustomAttributes.Clear ();
- }
-
- if (method.IsFinalizer ()) {
- SetSafestActionForETWMethod (annotations, method, MethodAction.ConvertToStub);
- continue;
- }
-
- if (method.IsConstructor) {
- //
- // Skip when it cannot be easily stubbed
- //
- if (type.BaseType.HasDefaultConstructor ())
- SetSafestActionForETWMethod (annotations, method, MethodAction.ConvertToStub);
-
- continue;
- }
-
- if (!skip)
- SetSafestActionForETWMethod (annotations, method, MethodAction.ConvertToThrow);
- }
- }
-
- void SetSafestActionForETWMethod (AnnotationStore annotations, MethodDefinition method, MethodAction desiredAction)
- {
- if (desiredAction == MethodAction.ConvertToThrow) {
- // If the desired action is a throw but the method has a void return let's just clear the body.
- // If the method does not have a void return, let's still insert a throw just in case. stubbing the body could result in
- // an unexpected value being returned from the method which may lead to a more confusing error down the road
- if (method.ReturnType.MetadataType == MetadataType.Void) {
- annotations.SetAction (method, MethodAction.ConvertToStub);
- return;
- }
-
- if (!MethodBodyScanner.IsWorthConvertingToThrow (method.Body))
- return;
- }
-
- annotations.SetAction (method, desiredAction);
- }
-
- void ExcludeMonoCollation (TypeDefinition type)
- {
- var annotations = Context.Annotations;
-
-
- switch (type.Name) {
- case "SimpleCollator":
- if (type.Namespace == "Mono.Globalization.Unicode") {
- foreach (var method in type.Methods) {
- if (MethodBodyScanner.IsWorthConvertingToThrow (method.Body))
- annotations.SetAction (method, MethodAction.ConvertToThrow);
- }
- }
-
- break;
- case "CompareInfo":
- if (type.Namespace == "System.Globalization") {
- foreach (var method in type.Methods) {
- if (method.Name == "get_UseManagedCollation") {
- annotations.SetAction (method, MethodAction.ConvertToStub);
- break;
- }
- }
- }
-
- break;
- }
- }
-
- bool RemoveCustomAttributes (ICustomAttributeProvider provider)
- {
- if (!provider.HasCustomAttributes)
- return false;
-
- var attrsToRemove = provider.CustomAttributes.Where (IsCustomAttributeExcluded).ToArray ();
- foreach (var remove in attrsToRemove)
- provider.CustomAttributes.Remove (remove);
-
- return attrsToRemove.Length > 0;
- }
-
- bool IsCustomAttributeExcluded (CustomAttribute attr)
- {
- var type = attr.AttributeType;
-
- switch (type.Name) {
- default:
- return false;
-
- case "ComDefaultInterfaceAttribute":
- case "ComVisibleAttribute":
- case "ClassInterfaceAttribute":
- case "InterfaceTypeAttribute":
- case "DispIdAttribute":
- case "TypeLibImportClassAttribute":
- case "ComRegisterFunctionAttribute":
- case "ComUnregisterFunctionAttribute":
- case "ProgIdAttribute":
- case "ImportedFromTypeLibAttribute":
- case "IDispatchImplAttribute":
- case "ComSourceInterfacesAttribute":
- case "ComConversionLossAttribute":
- case "TypeLibTypeAttribute":
- case "TypeLibFuncAttribute":
- case "TypeLibVarAttribute":
- case "ComImportAttribute":
- case "GuidAttribute":
- case "ComAliasNameAttribute":
- case "AutomationProxyAttribute":
- case "PrimaryInteropAssemblyAttribute":
- case "CoClassAttribute":
- case "ComEventInterfaceAttribute":
- case "TypeLibVersionAttribute":
- case "ComCompatibleVersionAttribute":
- case "SetWin32ContextInIDispatchAttribute":
- case "ManagedToNativeComInteropStubAttribute":
- if (!FeatureCOM || type.Namespace != "System.Runtime.InteropServices")
- return false;
-
- break;
-
- case "EventSourceAttribute":
- case "EventAttribute":
- case "EventDataAttribute":
- case "EventFieldAttribute":
- case "EventIgnoreAttribute":
- case "NonEventAttribute":
- if (!FeatureETW || type.Namespace != "System.Diagnostics.Tracing")
- return false;
-
- break;
- }
-
- var definition = type.Resolve ();
- if (!Annotations.IsPreserved (definition))
- return true;
-
- //
- // We allow xml descriptor to override feature attributes which should be
- // removed
- //
- return !Annotations.TryGetPreserve (definition, out var p) || p != TypePreserve.All;
- }
- }
-}
diff --git a/src/linker/Linker.Steps/ResolveFromAssemblyStep.cs b/src/linker/Linker.Steps/ResolveFromAssemblyStep.cs
deleted file mode 100644
index a3bc7e897..000000000
--- a/src/linker/Linker.Steps/ResolveFromAssemblyStep.cs
+++ /dev/null
@@ -1,216 +0,0 @@
-//
-// ResolveFromAssemblyStep.cs
-//
-// Author:
-// Jb Evain (jbevain@gmail.com)
-//
-// (C) 2006 Jb Evain
-//
-// 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.
-//
-
-using Mono.Cecil;
-using Mono.Collections.Generic;
-
-namespace Mono.Linker.Steps
-{
-
- public class ResolveFromAssemblyStep : BaseStep
- {
-
- readonly AssemblyDefinition _assembly;
- readonly string _file;
- RootVisibility _rootVisibility;
-
- public enum RootVisibility
- {
- Any = 0,
- PublicAndFamily = 1,
- PublicAndFamilyAndAssembly = 2
- }
-
-
- public ResolveFromAssemblyStep (string assembly, RootVisibility rootVisibility = RootVisibility.Any)
- {
- _file = assembly;
- _rootVisibility = rootVisibility;
- }
-
- public ResolveFromAssemblyStep (AssemblyDefinition assembly)
- {
- _assembly = assembly;
- }
-
- protected override void Process ()
- {
- if (_assembly != null)
- Context.Resolver.CacheAssembly (_assembly);
-
- var ignoreUnresolved = Context.Resolver.IgnoreUnresolved;
- Context.Resolver.IgnoreUnresolved = false;
- AssemblyDefinition assembly = _assembly ?? Context.Resolve (_file);
- Context.Resolver.IgnoreUnresolved = ignoreUnresolved;
-
- if (_rootVisibility != RootVisibility.Any && HasInternalsVisibleTo (assembly))
- _rootVisibility = RootVisibility.PublicAndFamilyAndAssembly;
-
- switch (assembly.MainModule.Kind) {
- case ModuleKind.Dll:
- ProcessLibrary (assembly);
- break;
- default:
- ProcessExecutable (assembly);
- break;
- }
- }
-
- protected virtual void ProcessLibrary (AssemblyDefinition assembly)
- {
- ProcessLibrary (Context, assembly, _rootVisibility);
- }
-
- public static void ProcessLibrary (LinkContext context, AssemblyDefinition assembly, RootVisibility rootVisibility = RootVisibility.Any)
- {
- var action = rootVisibility == RootVisibility.Any ? AssemblyAction.Copy : AssemblyAction.Link;
- context.SetAction (assembly, action);
-
- foreach (TypeDefinition type in assembly.MainModule.Types)
- MarkType (context, type, rootVisibility);
-
- if (assembly.MainModule.HasExportedTypes) {
- foreach (var exported in assembly.MainModule.ExportedTypes) {
- bool isForwarder = exported.IsForwarder;
- var declaringType = exported.DeclaringType;
- while (!isForwarder && (declaringType != null)) {
- isForwarder = declaringType.IsForwarder;
- declaringType = declaringType.DeclaringType;
- }
-
- if (!isForwarder)
- continue;
- TypeDefinition resolvedExportedType = exported.Resolve ();
-
- if (resolvedExportedType == null) {
- //
- // It's quite common for assemblies to have broken exported types
- //
- // One source of them is from native csc which added all nested types of
- // type-forwarded types automatically including private ones.
- //
- // Next source of broken type-forwarders is from custom metadata writers which
- // simply write bogus information.
- //
- // Both cases are bugs not on our end but we still want to link all assemblies
- // especially when such types cannot be used anyway
- //
- context.LogMessage ($"Cannot find declaration of exported type '{exported}' from the assembly '{assembly}'");
-
- continue;
- }
-
- context.Resolve (resolvedExportedType.Scope);
- MarkType (context, resolvedExportedType, rootVisibility);
- context.MarkingHelpers.MarkExportedType (exported, assembly.MainModule, new DependencyInfo (DependencyKind.ExportedType, resolvedExportedType));
- }
- }
- }
-
- static void MarkType (LinkContext context, TypeDefinition type, RootVisibility rootVisibility)
- {
- bool markType = rootVisibility switch
- {
- RootVisibility.PublicAndFamilyAndAssembly => !type.IsNestedPrivate,
- RootVisibility.PublicAndFamily => type.IsPublic || type.IsNestedPublic || type.IsNestedFamily || type.IsNestedFamilyOrAssembly,
- _ => true
- };
-
- if (!markType) {
- return;
- }
-
- context.Annotations.Mark (type, new DependencyInfo (DependencyKind.RootAssembly, type.Module.Assembly));
- if (type.HasFields)
- MarkFields (context, type.Fields, rootVisibility);
- if (type.HasMethods)
- MarkMethods (context, type.Methods, rootVisibility);
- if (type.HasNestedTypes)
- foreach (var nested in type.NestedTypes)
- MarkType (context, nested, rootVisibility);
- }
-
- void ProcessExecutable (AssemblyDefinition assembly)
- {
- Context.SetAction (assembly, AssemblyAction.Link);
-
- MethodDefinition entryPoint = assembly.EntryPoint;
- TypeDefinition declaringType = entryPoint.DeclaringType;
- Annotations.Mark (declaringType, new DependencyInfo (DependencyKind.RootAssembly, declaringType.Module.Assembly));
-
- MarkMethod (Context, entryPoint, MethodAction.Parse, RootVisibility.Any);
- }
-
- static void MarkFields (LinkContext context, Collection<FieldDefinition> fields, RootVisibility rootVisibility)
- {
- foreach (FieldDefinition field in fields) {
- bool markField = rootVisibility switch
- {
- RootVisibility.PublicAndFamily => field.IsPublic || field.IsFamily || field.IsFamilyOrAssembly,
- RootVisibility.PublicAndFamilyAndAssembly => field.IsPublic || field.IsFamily || field.IsFamilyOrAssembly || field.IsAssembly || field.IsFamilyAndAssembly,
- _ => true
- };
- if (markField) {
- context.Annotations.Mark (field, new DependencyInfo (DependencyKind.RootAssembly, field.Module.Assembly));
- }
- }
- }
-
- static void MarkMethods (LinkContext context, Collection<MethodDefinition> methods, RootVisibility rootVisibility)
- {
- foreach (MethodDefinition method in methods)
- MarkMethod (context, method, MethodAction.ForceParse, rootVisibility);
- }
-
- static void MarkMethod (LinkContext context, MethodDefinition method, MethodAction action, RootVisibility rootVisibility)
- {
- bool markMethod = rootVisibility switch
- {
- RootVisibility.PublicAndFamily => method.IsPublic || method.IsFamily || method.IsFamilyOrAssembly,
- RootVisibility.PublicAndFamilyAndAssembly => method.IsPublic || method.IsFamily || method.IsFamilyOrAssembly || method.IsAssembly || method.IsFamilyAndAssembly,
- _ => true
- };
-
- if (markMethod) {
- context.Annotations.Mark (method, new DependencyInfo (DependencyKind.RootAssembly, method.Module.Assembly));
- context.Annotations.SetAction (method, action);
- }
- }
-
- static bool HasInternalsVisibleTo (AssemblyDefinition assembly)
- {
- foreach (CustomAttribute attribute in assembly.CustomAttributes) {
- if (attribute.Constructor.DeclaringType.FullName ==
- "System.Runtime.CompilerServices.InternalsVisibleToAttribute")
- return true;
- }
-
- return false;
- }
- }
-}
diff --git a/src/linker/Linker.Steps/ResolveFromXApiStep.cs b/src/linker/Linker.Steps/ResolveFromXApiStep.cs
deleted file mode 100644
index f850f2f36..000000000
--- a/src/linker/Linker.Steps/ResolveFromXApiStep.cs
+++ /dev/null
@@ -1,140 +0,0 @@
-//
-// ResolveFromXApiStep.cs
-//
-// Author:
-// Jb Evain (jbevain@novell.com)
-//
-// (C) 2007 Novell, Inc.
-//
-// 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.
-//
-
-using System.Xml.XPath;
-
-using Mono.Cecil;
-
-namespace Mono.Linker.Steps
-{
-
- public class ResolveFromXApiStep : BaseStep, IXApiVisitor
- {
-
- static readonly string _name = "name";
- static readonly string _ns = string.Empty;
-
- XPathDocument _document;
-
- public ResolveFromXApiStep (XPathDocument document)
- {
- _document = document;
- }
-
- protected override void Process ()
- {
- XApiReader reader = new XApiReader (_document, this);
- reader.Process (Context);
- }
-
- public void OnAssembly (XPathNavigator nav, AssemblyDefinition assembly)
- {
- }
-
- public void OnAttribute (XPathNavigator nav)
- {
- string name = GetName (nav);
-
- TypeDefinition type = Context.GetType (name);
- if (type != null)
- MarkType (type);
- }
-
- public void OnClass (XPathNavigator nav, TypeDefinition type)
- {
- MarkType (type);
- }
-
- public void OnInterface (XPathNavigator nav, TypeDefinition type)
- {
- MarkType (type);
- }
-
- public void OnField (XPathNavigator nav, FieldDefinition field)
- {
- MarkField (field);
- }
-
- public void OnMethod (XPathNavigator nav, MethodDefinition method)
- {
- MarkMethod (method);
- }
-
- public void OnConstructor (XPathNavigator nav, MethodDefinition method)
- {
- MarkMethod (method);
- }
-
- public void OnProperty (XPathNavigator nav, PropertyDefinition property)
- {
- }
-
- public void OnEvent (XPathNavigator nav, EventDefinition evt)
- {
- if (evt.AddMethod != null)
- MarkMethod (evt.AddMethod);
- if (evt.InvokeMethod != null)
- MarkMethod (evt.InvokeMethod);
- if (evt.RemoveMethod != null)
- MarkMethod (evt.RemoveMethod);
- }
-
- static string GetName (XPathNavigator nav)
- {
- return GetAttribute (nav, _name);
- }
-
- static string GetAttribute (XPathNavigator nav, string attribute)
- {
- return nav.GetAttribute (attribute, _ns);
- }
-
- void MarkType (TypeDefinition type)
- {
- InternalMark (type);
- }
-
- void MarkField (FieldDefinition field)
- {
- InternalMark (field);
- }
-
- void InternalMark (IMetadataTokenProvider provider)
- {
- Annotations.Mark (provider);
- Annotations.SetPublic (provider);
- }
-
- void MarkMethod (MethodDefinition method)
- {
- InternalMark (method);
- Annotations.MarkIndirectlyCalledMethod (method);
- Annotations.SetAction (method, MethodAction.Parse);
- }
- }
-}
diff --git a/src/linker/Linker.Steps/ResolveFromXmlStep.cs b/src/linker/Linker.Steps/ResolveFromXmlStep.cs
index ff8ab4378..4d66a3534 100644
--- a/src/linker/Linker.Steps/ResolveFromXmlStep.cs
+++ b/src/linker/Linker.Steps/ResolveFromXmlStep.cs
@@ -58,10 +58,6 @@ namespace Mono.Linker.Steps
{
}
-#if !FEATURE_ILLINK
- protected override bool ShouldProcessElement (XPathNavigator nav) => true;
-#endif
-
protected override void Process ()
{
ProcessXml (Context.StripDescriptors, Context.IgnoreDescriptors);
@@ -71,11 +67,6 @@ namespace Mono.Linker.Steps
protected override void ProcessAssembly (AssemblyDefinition assembly, XPathNavigator nav, bool warnOnUnresolvedTypes)
{
-#if !FEATURE_ILLINK
- if (IsExcluded (nav))
- return;
-#endif
-
if (GetTypePreserve (nav) == TypePreserve.All) {
foreach (var type in assembly.MainModule.Types)
MarkAndPreserveAll (type);
@@ -130,11 +121,6 @@ namespace Mono.Linker.Steps
{
Debug.Assert (ShouldProcessElement (nav));
-#if !FEATURE_ILLINK
- if (IsExcluded (nav))
- return;
-#endif
-
TypePreserve preserve = GetTypePreserve (nav);
if (preserve != TypePreserve.Nothing)
Annotations.SetPreserve (type, preserve);
@@ -145,10 +131,6 @@ namespace Mono.Linker.Steps
if (!required)
return;
- if (Annotations.IsMarked (type)) {
- var duplicateLevel = preserve != TypePreserve.Nothing ? preserve : nav.HasChildren ? TypePreserve.Nothing : TypePreserve.All;
- }
-
Annotations.Mark (type, new DependencyInfo (DependencyKind.XmlDescriptor, _xmlDocumentLocation));
if (type.IsNested) {
@@ -172,16 +154,6 @@ namespace Mono.Linker.Steps
return TypePreserve.Nothing;
}
-#if !FEATURE_ILLINK
- protected override void ProcessField (TypeDefinition type, XPathNavigator nav)
- {
- if (IsExcluded (nav))
- return;
-
- base.ProcessField (type, nav);
- }
-#endif
-
protected override void ProcessField (TypeDefinition type, FieldDefinition field, XPathNavigator nav)
{
if (Annotations.IsMarked (field))
@@ -190,16 +162,6 @@ namespace Mono.Linker.Steps
Context.Annotations.Mark (field, new DependencyInfo (DependencyKind.XmlDescriptor, _xmlDocumentLocation));
}
-#if !FEATURE_ILLINK
- protected override void ProcessMethod (TypeDefinition type, XPathNavigator nav, object customData)
- {
- if (IsExcluded (nav))
- return;
-
- base.ProcessMethod (type, nav, customData);
- }
-#endif
-
protected override void ProcessMethod (TypeDefinition type, MethodDefinition method, XPathNavigator nav, object customData)
{
if (Annotations.IsMarked (method))
@@ -255,16 +217,6 @@ namespace Mono.Linker.Steps
return sb.ToString ();
}
-#if !FEATURE_ILLINK
- protected override void ProcessEvent (TypeDefinition type, XPathNavigator nav, object customData)
- {
- if (IsExcluded (nav))
- return;
-
- base.ProcessEvent (type, nav, customData);
- }
-#endif
-
protected override void ProcessEvent (TypeDefinition type, EventDefinition @event, XPathNavigator nav, object customData)
{
if (Annotations.IsMarked (@event))
@@ -277,16 +229,6 @@ namespace Mono.Linker.Steps
ProcessMethodIfNotNull (type, @event.InvokeMethod, customData);
}
-#if !FEATURE_ILLINK
- protected override void ProcessProperty (TypeDefinition type, XPathNavigator nav, object customData)
- {
- if (IsExcluded (nav))
- return;
-
- base.ProcessProperty (type, nav, customData);
- }
-#endif
-
protected override void ProcessProperty (TypeDefinition type, PropertyDefinition property, XPathNavigator nav, object customData, bool fromSignature)
{
string[] accessors = fromSignature ? GetAccessors (nav) : _accessorsAll;
@@ -353,16 +295,5 @@ namespace Mono.Linker.Steps
}
return _accessorsAll;
}
-
-#if !FEATURE_ILLINK
- protected virtual bool IsExcluded (XPathNavigator nav)
- {
- var value = GetAttribute (nav, "feature");
- if (string.IsNullOrEmpty (value))
- return false;
-
- return Context.IsFeatureExcluded (value);
- }
-#endif
}
}
diff --git a/src/linker/Linker.Steps/SweepStep.cs b/src/linker/Linker.Steps/SweepStep.cs
index 4bf6a60da..0b26ecd84 100644
--- a/src/linker/Linker.Steps/SweepStep.cs
+++ b/src/linker/Linker.Steps/SweepStep.cs
@@ -862,13 +862,8 @@ namespace Mono.Linker.Steps
case TypeSpecification ts:
UpdateScopeOfTypeReference (ts.ElementType);
return;
-#if FEATURE_ILLINK
case TypeDefinition:
case GenericParameter:
-#else
- case TypeDefinition _:
- case GenericParameter _:
-#endif
// Nothing to update
return;
}
diff --git a/src/linker/Linker/AssemblyResolver.cs b/src/linker/Linker/AssemblyResolver.cs
index 20c4bac4e..f29ca9cf5 100644
--- a/src/linker/Linker/AssemblyResolver.cs
+++ b/src/linker/Linker/AssemblyResolver.cs
@@ -35,12 +35,8 @@ using Mono.Collections.Generic;
namespace Mono.Linker
{
-#if FEATURE_ILLINK
- public class AssemblyResolver : DirectoryAssemblyResolver {
-#else
- public class AssemblyResolver : BaseAssemblyResolver
+ public class AssemblyResolver : DirectoryAssemblyResolver
{
-#endif
readonly Dictionary<string, AssemblyDefinition> _assemblies;
HashSet<string> _unresolvedAssemblies;
@@ -74,29 +70,14 @@ namespace Mono.Linker
set { _context = value; }
}
-#if !FEATURE_ILLINK
- // The base class's definition of GetAssembly is visible when using DirectoryAssemblyResolver.
- AssemblyDefinition GetAssembly (string file, ReaderParameters parameters)
- {
- if (parameters.AssemblyResolver == null)
- parameters.AssemblyResolver = this;
-
- return ModuleDefinition.ReadModule (file, parameters).Assembly;
- }
-#endif
-
public string GetAssemblyFileName (AssemblyDefinition assembly)
{
-#if FEATURE_ILLINK
- if (assemblyToPath.TryGetValue(assembly, out string path)) {
+ if (assemblyToPath.TryGetValue (assembly, out string path)) {
return path;
}
- else
-#endif
- {
- // Must be an assembly that we didn't open through the resolver
- return assembly.MainModule.FileName;
- }
+
+ // Must be an assembly that we didn't open through the resolver
+ return assembly.MainModule.FileName;
}
AssemblyDefinition ResolveFromReferences (AssemblyNameReference name, Collection<string> references, ReaderParameters parameters)
diff --git a/src/linker/Linker/DirectoryAssemblyResolver.cs b/src/linker/Linker/DirectoryAssemblyResolver.cs
index 915bdaf02..aef20f831 100644
--- a/src/linker/Linker/DirectoryAssemblyResolver.cs
+++ b/src/linker/Linker/DirectoryAssemblyResolver.cs
@@ -9,10 +9,11 @@ using System.IO.MemoryMappedFiles;
using Mono.Cecil;
using Mono.Collections.Generic;
-#if FEATURE_ILLINK
-namespace Mono.Linker {
+namespace Mono.Linker
+{
- public abstract class DirectoryAssemblyResolver : IAssemblyResolver {
+ public abstract class DirectoryAssemblyResolver : IAssemblyResolver
+ {
readonly Collection<string> directories;
@@ -84,7 +85,7 @@ namespace Mono.Linker {
AssemblyDefinition SearchDirectory (AssemblyNameReference name, IEnumerable<string> directories, ReaderParameters parameters)
{
- var extensions = new [] { ".dll", ".exe" };
+ var extensions = new[] { ".dll", ".exe" };
foreach (var directory in directories) {
foreach (var extension in extensions) {
string file = Path.Combine (directory, name.Name + extension);
@@ -119,4 +120,3 @@ namespace Mono.Linker {
}
}
}
-#endif
diff --git a/src/linker/Linker/Driver.cs b/src/linker/Linker/Driver.cs
index 997232826..c76987097 100644
--- a/src/linker/Linker/Driver.cs
+++ b/src/linker/Linker/Driver.cs
@@ -40,14 +40,8 @@ namespace Mono.Linker
public partial class Driver : IDisposable
{
-
-#if FEATURE_ILLINK
const string resolvers = "-a|-x";
const string _linker = "IL Linker";
-#else
- const string resolvers = "-a|-i|-r|-x";
- const string _linker = "Mono IL Linker";
-#endif
public static int Main (string[] args)
{
@@ -166,14 +160,6 @@ namespace Mono.Linker
Pipeline p = GetStandardPipeline ();
context = GetDefaultContext (p, customLogger);
-#if !FEATURE_ILLINK
- I18nAssemblies assemblies = I18nAssemblies.All;
- var excluded_features = new HashSet<string> (StringComparer.Ordinal);
- var resolve_from_xapi_steps = new Stack<string> ();
- bool resolver = false;
- var resolve_from_assembly_steps = new Stack<(string, ResolveFromAssemblyStep.RootVisibility)> ();
- var resolve_from_xml_steps = new Stack<string> ();
-#endif
var body_substituter_steps = new Stack<string> ();
var xml_custom_attribute_steps = new Stack<string> ();
var custom_steps = new Stack<string> ();
@@ -268,23 +254,6 @@ namespace Mono.Linker
return -1;
continue;
-#if !FEATURE_ILLINK
- case "--exclude-feature":
- if (arguments.Count < 1) {
- ErrorMissingArgument (token);
- return -1;
- }
-
- if (!GetStringParam (token, l => {
- foreach (var feature in l.Split (',')) {
- if (!excluded_features.Contains (feature))
- excluded_features.Add (feature);
- }
- }))
- return -1;
-
- continue;
-#endif
case "--explicit-reflection":
if (!GetBoolParam (token, l => context.AddReflectionAnnotations = l))
return -1;
@@ -561,7 +530,6 @@ namespace Mono.Linker
case "t":
context.KeepTypeForwarderOnlyAssemblies = true;
continue;
-#if FEATURE_ILLINK
case "x": {
string xmlFile = null;
if (!GetStringParam (token, l => xmlFile = l))
@@ -598,50 +566,6 @@ namespace Mono.Linker
inputs.Add (new RootAssemblyInput (assemblyFile, rmode));
continue;
}
-#else
- case "x":
- if (!GetStringParam (token, l => {
- foreach (string file in GetFiles (l))
- resolve_from_xml_steps.Push (file);
- }))
- return -1;
-
- resolver = true;
- continue;
- case "r":
- case "a":
- if (!GetStringParam (token, l => {
-
- var rootVisibility = (token[1] == 'r')
- ? ResolveFromAssemblyStep.RootVisibility.PublicAndFamily
- : ResolveFromAssemblyStep.RootVisibility.Any;
- foreach (string file in GetFiles (l))
- resolve_from_assembly_steps.Push ((file, rootVisibility));
- }))
- return -1;
-
- resolver = true;
- continue;
- case "i":
- if (!GetStringParam (token, l => {
- foreach (string file in GetFiles (l))
- resolve_from_xapi_steps.Push (file);
- }))
- return -1;
-
- resolver = true;
- continue;
- case "l":
- if (!GetStringParam (token, l => assemblies = ParseI18n (l)))
- return -1;
-
- continue;
- case "v":
- if (!GetBoolParam (token, l => context.KeepMembersForDebugger = l))
- return -1;
-
- continue;
-#endif
case "b":
if (!GetBoolParam (token, l => context.LinkSymbols = l))
return -1;
@@ -675,11 +599,7 @@ namespace Mono.Linker
return -1;
}
-#if FEATURE_ILLINK
if (inputs.Count == 0) {
-#else
- if (!resolver) {
-#endif
context.LogError ($"No input files were specified. Use one of '{resolvers}' options", 1020);
return -1;
}
@@ -711,24 +631,12 @@ namespace Mono.Linker
// Modify the default pipeline
//
-#if FEATURE_ILLINK
for (int i = inputs.Count; i != 0; --i)
p.PrependStep (inputs[i - 1]);
-#else
- foreach (var file in resolve_from_xapi_steps)
- p.PrependStep (new ResolveFromXApiStep (new XPathDocument (file)));
-#endif
+
foreach (var file in xml_custom_attribute_steps)
AddLinkAttributesStep (p, file);
-#if !FEATURE_ILLINK
- foreach (var file in resolve_from_xml_steps)
- AddResolveFromXmlStep (p, file);
-
- foreach (var (file, rootVisibility) in resolve_from_assembly_steps)
- p.PrependStep (new ResolveFromAssemblyStep (file, rootVisibility));
-#endif
-
foreach (var file in body_substituter_steps)
AddBodySubstituterStep (p, file);
@@ -738,34 +646,12 @@ namespace Mono.Linker
if (context.AddReflectionAnnotations)
p.AddStepAfter (typeof (MarkStep), new ReflectionBlockedStep ());
-#if !FEATURE_ILLINK
- p.AddStepAfter (typeof (LoadReferencesStep), new LoadI18nAssemblies (assemblies));
-
- if (assemblies != I18nAssemblies.None)
- p.AddStepAfter (typeof (DynamicDependencyLookupStep), new PreserveCalendarsStep (assemblies));
-#endif
-
if (_needAddBypassNGenStep)
p.AddStepAfter (typeof (SweepStep), new AddBypassNGenStep ());
if (removeCAS)
p.AddStepBefore (typeof (MarkStep), new RemoveSecurityStep ());
-#if !FEATURE_ILLINK
- if (excluded_features.Count > 0) {
- p.AddStepBefore (typeof (MarkStep), new RemoveFeaturesStep () {
- FeatureCOM = excluded_features.Contains ("com"),
- FeatureETW = excluded_features.Contains ("etw"),
- FeatureSRE = excluded_features.Contains ("sre"),
- FeatureGlobalization = excluded_features.Contains ("globalization")
- });
-
- var excluded = new string[excluded_features.Count];
- excluded_features.CopyTo (excluded);
- context.ExcludedFeatures = excluded;
- }
-#endif
-
p.AddStepBefore (typeof (MarkStep), new RemoveUnreachableBlocksStep ());
p.AddStepBefore (typeof (OutputStep), new SealerStep ());
@@ -773,11 +659,7 @@ namespace Mono.Linker
// Pipeline setup with all steps enabled
//
// RootAssemblyInputStep or ResolveFromXmlStep [at least one of them]
- // [mono only] ResolveFromAssemblyStep [optional, possibly many]
- // ResolveFromXmlStep [optional, possibly many]
- // [mono only] ResolveFromXApiStep [optional, possibly many]
// LoadReferencesStep
- // [mono only] LoadI18nAssemblies
// BlacklistStep
// dynamically adds steps:
// ResolveFromXmlStep [optional, possibly many]
@@ -785,10 +667,8 @@ namespace Mono.Linker
// LinkAttributesStep [optional, possibly many]
// LinkAttributesStep [optional, possibly many]
// DynamicDependencyLookupStep
- // [mono only] PreserveCalendarsStep [optional]
// BodySubstituterStep [optional]
// RemoveSecurityStep [optional]
- // [mono only] RemoveFeaturesStep [optional]
// RemoveUnreachableBlocksStep [optional]
// MarkStep
// ReflectionBlockedStep [optional]
@@ -1007,18 +887,6 @@ namespace Mono.Linker
return lines.ToArray ();
}
-#if !FEATURE_ILLINK
- protected static I18nAssemblies ParseI18n (string str)
- {
- I18nAssemblies assemblies = I18nAssemblies.None;
- string[] parts = str.Split (',');
- foreach (string part in parts)
- assemblies |= (I18nAssemblies) Enum.Parse (typeof (I18nAssemblies), part.Trim (), true);
-
- return assemblies;
- }
-#endif
-
AssemblyAction? ParseAssemblyAction (string s)
{
switch (s.ToLowerInvariant ()) {
@@ -1177,11 +1045,7 @@ namespace Mono.Linker
protected virtual LinkContext GetDefaultContext (Pipeline pipeline, ILogger logger)
{
return new LinkContext (pipeline, logger ?? new ConsoleLogger ()) {
-#if FEATURE_ILLINK
CoreAction = AssemblyAction.Link,
-#else
- CoreAction = AssemblyAction.Skip,
-#endif
UserAction = AssemblyAction.Link,
OutputDirectory = "output",
};
@@ -1201,7 +1065,6 @@ namespace Mono.Linker
{
Console.WriteLine (_linker);
-#if FEATURE_ILLINK
Console.WriteLine ($"illink [options] {resolvers}");
Console.WriteLine (" -a FILE [MODE] Assembly file used as root assembly with optional MODE value to alter default root mode");
Console.WriteLine (" Mode can be one of the following values");
@@ -1209,36 +1072,20 @@ namespace Mono.Linker
Console.WriteLine (" default: Use entry point for applications and all members for libraries");
Console.WriteLine (" entrypoint: Use assembly entry point as only root in the assembly");
Console.WriteLine (" visible: Keep all members and types visible outside of root assembly");
-
Console.WriteLine (" -x FILE XML descriptor file with members to be kept");
-#else
- Console.WriteLine ($"monolinker [options] {resolvers} file");
- Console.WriteLine (" -a Link from a list of assemblies");
- Console.WriteLine (" -i Link from an mono-api-info descriptor");
- Console.WriteLine (" -r Link from a list of assemblies using roots visible outside of the assembly");
- Console.WriteLine (" -x Link from XML descriptor");
-#endif
+
Console.WriteLine ();
Console.WriteLine ("Options");
Console.WriteLine (" -d PATH Specify additional directory to search in for assembly references");
Console.WriteLine (" -reference FILE Specify additional file location used to resolve assembly references");
Console.WriteLine (" -b Update debug symbols for all modified files. Defaults to false");
-#if !FEATURE_ILLINK
- Console.WriteLine (" -v Keep members and types used by debugger. Defaults to false");
- Console.WriteLine (" -l <name>,<name> List of i18n assemblies to copy to the output directory. Defaults to 'all'");
- Console.WriteLine (" Valid names are 'none', 'all', 'cjk', 'mideast', 'other', 'rare', 'west'");
-#endif
Console.WriteLine (" -out PATH Specify the output directory. Defaults to 'output'");
Console.WriteLine (" -h Lists all {0} options", _linker);
Console.WriteLine (" @FILE Read response file for more options");
Console.WriteLine ();
Console.WriteLine ("Actions");
-#if FEATURE_ILLINK
Console.WriteLine (" -c ACTION Sets action for all framework assemblies. Defaults to 'link'");
-#else
- Console.WriteLine (" -c ACTION Sets action for all framework assemblies. Defaults to 'skip'");
-#endif
Console.WriteLine (" copy: Analyze whole assembly and save it to the output");
Console.WriteLine (" copyused: Same as copy but only for assemblies which are needed");
Console.WriteLine (" link: Remove any unused IL or metadata and optimizes the assembly");
@@ -1281,14 +1128,6 @@ namespace Mono.Linker
Console.WriteLine (" unusedtypechecks: Inlines never successful type checks");
Console.WriteLine (" --enable-opt NAME [ASM] Enable one of the additional optimizations globaly or for a specific assembly name");
Console.WriteLine (" sealer: Any method or type which does not have override is marked as sealed");
-#if !FEATURE_ILLINK
- Console.WriteLine (" --exclude-feature NAME Any code which has a feature <name> in linked assemblies will be removed");
- Console.WriteLine (" com: Support for COM Interop");
- Console.WriteLine (" etw: Event Tracing for Windows");
- Console.WriteLine (" remoting: .NET Remoting dependencies");
- Console.WriteLine (" sre: System.Reflection.Emit namespace");
- Console.WriteLine (" globalization: Globalization data and globalization behavior");
-#endif
Console.WriteLine (" --explicit-reflection Adds to members never used through reflection DisablePrivateReflection attribute. Defaults to false");
Console.WriteLine (" --keep-dep-attributes Keep attributes used for manual dependency tracking. Defaults to false");
Console.WriteLine (" --feature FEATURE VALUE Apply any optimizations defined when this feature setting is a constant known at link time");
@@ -1321,7 +1160,7 @@ namespace Mono.Linker
static void About ()
{
Console.WriteLine ("For more information, visit the project Web site");
- Console.WriteLine (" http://www.mono-project.com/");
+ Console.WriteLine (" https://github.com/mono/linker");
}
static Pipeline GetStandardPipeline ()
diff --git a/src/linker/Linker/I18nAssemblies.cs b/src/linker/Linker/I18nAssemblies.cs
deleted file mode 100644
index 8c79d5a86..000000000
--- a/src/linker/Linker/I18nAssemblies.cs
+++ /dev/null
@@ -1,49 +0,0 @@
-//
-// I18nAssemblies.cs
-//
-// Author:
-// Jb Evain (jbevain@novell.com)
-//
-// (C) 2007 Novell, Inc.
-//
-// 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.
-//
-
-using System;
-
-namespace Mono.Linker
-{
-
- [Flags]
- public enum I18nAssemblies
- {
-
- None = 0,
-
- CJK = 1,
- MidEast = 2,
- Other = 4,
- Rare = 8,
- West = 16,
-
- All = CJK | MidEast | Other | Rare | West,
- Base
- }
-}
diff --git a/src/linker/Linker/LinkContext.cs b/src/linker/Linker/LinkContext.cs
index 5a0b493d0..a56070718 100644
--- a/src/linker/Linker/LinkContext.cs
+++ b/src/linker/Linker/LinkContext.cs
@@ -117,11 +117,7 @@ namespace Mono.Linker
set { _keepTypeForwarderOnlyAssemblies = value; }
}
-#if FEATURE_ILLINK
public readonly bool KeepMembersForDebugger = true;
-#else
- public bool KeepMembersForDebugger { get; set; }
-#endif
public bool IgnoreUnresolved {
get { return _ignoreUnresolved; }
@@ -198,9 +194,6 @@ namespace Mono.Linker
public IReflectionPatternRecorder ReflectionPatternRecorder { get; set; }
-#if !FEATURE_ILLINK
- public string[] ExcludedFeatures { get; set; }
-#endif
public CodeOptimizationsSettings Optimizations { get; set; }
public bool AddReflectionAnnotations { get; set; }
@@ -483,13 +476,6 @@ namespace Mono.Linker
_resolver.Dispose ();
}
-#if !FEATURE_ILLINK
- public bool IsFeatureExcluded (string featureName)
- {
- return ExcludedFeatures != null && Array.IndexOf (ExcludedFeatures, featureName) >= 0;
- }
-#endif
-
public bool IsOptimizationEnabled (CodeOptimizations optimization, MemberReference context)
{
return Optimizations.IsEnabled (optimization, context?.Module.Assembly);
diff --git a/src/linker/Linker/MethodDefinitionExtensions.cs b/src/linker/Linker/MethodDefinitionExtensions.cs
index 50163d113..caae82ed8 100644
--- a/src/linker/Linker/MethodDefinitionExtensions.cs
+++ b/src/linker/Linker/MethodDefinitionExtensions.cs
@@ -71,21 +71,6 @@ namespace Mono.Linker
return method.IsConstructor && method.IsStatic;
}
-#if !FEATURE_ILLINK
- // This implementation is wrong. It should return true if this is a virtual override
- // of System.Object::Finalize, but that's not what this is doing. Do not use.
- public static bool IsFinalizer (this MethodDefinition method)
- {
- if (method.Name != "Finalize" || method.ReturnType.MetadataType != MetadataType.Void)
- return false;
-
- if (method.HasParameters || method.HasGenericParameters || method.IsStatic)
- return false;
-
- return true;
- }
-#endif
-
public static void ClearDebugInformation (this MethodDefinition method)
{
// TODO: This always allocates, update when Cecil catches up
diff --git a/src/linker/Linker/XApiReader.cs b/src/linker/Linker/XApiReader.cs
deleted file mode 100644
index 382294a63..000000000
--- a/src/linker/Linker/XApiReader.cs
+++ /dev/null
@@ -1,386 +0,0 @@
-//
-// XApiReader.cs
-//
-// Author:
-// Jb Evain (jbevain@novell.com)
-//
-// (C) 2007 Novell, Inc.
-//
-// 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.
-//
-
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Xml.XPath;
-
-using Mono.Cecil;
-using Mono.Collections.Generic;
-
-namespace Mono.Linker
-{
-
- public class XApiReader
- {
-
- static readonly string _name = "name";
- static readonly string _ns = string.Empty;
-
- LinkContext _context;
- XPathDocument _document;
- IXApiVisitor _visitor;
-
- AssemblyDefinition _assembly;
- string _namespace;
- Stack<TypeDefinition> _types = new Stack<TypeDefinition> ();
- StringBuilder _signature;
-
- public XApiReader (XPathDocument document, IXApiVisitor visitor)
- {
- _document = document;
- _visitor = visitor;
- }
-
- public void Process (LinkContext context)
- {
- _context = context;
- ProcessAssemblies (_document.CreateNavigator ());
- }
-
- void OnAssembly (XPathNavigator nav)
- {
- _assembly = GetAssembly (nav);
-
- _visitor.OnAssembly (nav, _assembly);
-
- ProcessAttributes (nav);
- ProcessNamespaces (nav);
- }
-
- AssemblyDefinition GetAssembly (XPathNavigator nav)
- {
- AssemblyNameReference name = new AssemblyNameReference (
- GetName (nav),
- new Version (GetAttribute (nav, "version")));
-
- AssemblyDefinition assembly = _context.Resolve (name);
- ProcessReferences (assembly);
- return assembly;
- }
-
- void ProcessReferences (AssemblyDefinition assembly)
- {
- foreach (AssemblyNameReference name in assembly.MainModule.AssemblyReferences)
- _context.Resolve (name);
- }
-
- void OnAttribute (XPathNavigator nav)
- {
- _visitor.OnAttribute (nav);
- }
-
- void PushType (TypeDefinition type)
- {
- _types.Push (type);
- }
-
- TypeDefinition PeekType ()
- {
- return _types.Peek ();
- }
-
- TypeDefinition PopType ()
- {
- return _types.Pop ();
- }
-
- void OnNamespace (XPathNavigator nav)
- {
- _namespace = GetName (nav);
-
- ProcessClasses (nav);
- }
-
- void OnClass (XPathNavigator nav)
- {
- string name = GetClassName (nav);
-
- TypeDefinition type = _assembly.MainModule.GetType (name);
- if (type == null)
- return;
-
- _visitor.OnClass (nav, type);
-
- PushType (type);
-
- ProcessAttributes (nav);
- ProcessInterfaces (nav);
- ProcessFields (nav);
- ProcessMethods (nav);
- ProcessConstructors (nav);
- ProcessProperties (nav);
- ProcessEvents (nav);
- ProcessClasses (nav);
-
- PopType ();
- }
-
- string GetClassName (XPathNavigator nav)
- {
- if (IsNestedClass ())
- return PeekType ().FullName + "/" + GetName (nav);
-
- return _namespace + "." + GetName (nav);
- }
-
- bool IsNestedClass ()
- {
- return _types.Count > 0;
- }
-
- void OnField (XPathNavigator nav)
- {
- TypeDefinition declaring = PeekType ();
-
- FieldDefinition field = declaring.Fields.FirstOrDefault (f => f.Name == GetName (nav));
- if (field != null)
- _visitor.OnField (nav, field);
-
- ProcessAttributes (nav);
- }
-
- void OnInterface (XPathNavigator nav)
- {
- string name = GetName (nav);
-
- TypeDefinition type = _context.GetType (GetTypeName (name));
- if (type != null)
- _visitor.OnInterface (nav, type);
- }
-
- void OnMethod (XPathNavigator nav)
- {
- InitMethodSignature (nav);
-
- ProcessParameters (nav);
-
- string signature = GetMethodSignature ();
-
- MethodDefinition method = GetMethod (signature);
- if (method != null)
- _visitor.OnMethod (nav, method);
-
- ProcessAttributes (nav);
- }
-
- MethodDefinition GetMethod (string signature)
- {
- return GetMethod (PeekType ().Methods, signature);
- }
-
- static MethodDefinition GetMethod (Collection<MethodDefinition> methods, string signature)
- {
- foreach (MethodDefinition method in methods)
- if (signature == GetSignature (method))
- return method;
-
- return null;
- }
-
- static string GetSignature (MethodDefinition method)
- {
- return method.ToString ().Replace ("<", "[").Replace (">", "]");
- }
-
- string GetMethodSignature ()
- {
- _signature.Append (")");
- return _signature.ToString ();
- }
-
- void InitMethodSignature (XPathNavigator nav)
- {
- _signature = new StringBuilder ();
-
- string returntype = GetAttribute (nav, "returntype");
- if (returntype == null || returntype.Length == 0)
- returntype = "System.Void";
-
- _signature.Append (NormalizeTypeName (returntype));
- _signature.Append (" ");
- _signature.Append (PeekType ().FullName);
- _signature.Append ("::");
-
- string name = GetName (nav);
- _signature.Append (GetMethodName (name));
-
- _signature.Append ("(");
- }
-
- static string GetMethodName (string name)
- {
- return GetStringBefore (name, "(");
- }
-
- static string NormalizeTypeName (string name)
- {
- return name.Replace ("+", "/").Replace ("<", "[").Replace (">", "]");
- }
-
- static string GetTypeName (string name)
- {
- return GetStringBefore (NormalizeTypeName (name), "[");
- }
-
- static string GetStringBefore (string str, string marker)
- {
- int pos = str.IndexOf (marker);
- if (pos == -1)
- return str;
-
- return str.Substring (0, pos);
- }
-
- void OnParameter (XPathNavigator nav)
- {
- string type = GetAttribute (nav, "type");
- int pos = int.Parse (GetAttribute (nav, "position"));
-
- if (pos > 0)
- _signature.Append (",");
- _signature.Append (NormalizeTypeName (type));
- }
-
- void OnConstructor (XPathNavigator nav)
- {
- InitMethodSignature (nav);
-
- ProcessParameters (nav);
-
- string signature = GetMethodSignature ();
-
- MethodDefinition ctor = GetMethod (signature);
- if (ctor != null)
- _visitor.OnConstructor (nav, ctor);
-
- ProcessAttributes (nav);
- }
-
- void OnProperty (XPathNavigator nav)
- {
- string name = GetName (nav);
- TypeDefinition type = PeekType ();
-
- var property = type.Properties.FirstOrDefault (p => p.Name == name);
- if (property != null)
- _visitor.OnProperty (nav, property);
-
- ProcessAttributes (nav);
- ProcessMethods (nav);
- }
-
- void OnEvent (XPathNavigator nav)
- {
- string name = GetName (nav);
- TypeDefinition type = PeekType ();
-
- EventDefinition evt = type.Events.FirstOrDefault (e => e.Name == name);
- if (evt != null)
- _visitor.OnEvent (nav, evt);
-
- ProcessAttributes (nav);
- }
-
- void ProcessAssemblies (XPathNavigator nav)
- {
- ProcessChildren (nav, "assemblies//assembly", new OnChildren (OnAssembly));
- }
-
- void ProcessAttributes (XPathNavigator nav)
- {
- ProcessChildren (nav, "attributes//attribute", new OnChildren (OnAttribute));
- }
-
- void ProcessNamespaces (XPathNavigator nav)
- {
- ProcessChildren (nav, "namespaces//namespace", new OnChildren (OnNamespace));
- }
-
- void ProcessClasses (XPathNavigator nav)
- {
- ProcessChildren (nav, "classes//class", new OnChildren (OnClass));
- }
-
- void ProcessInterfaces (XPathNavigator nav)
- {
- ProcessChildren (nav, "interfaces//interface", new OnChildren (OnInterface));
- }
-
- void ProcessFields (XPathNavigator nav)
- {
- ProcessChildren (nav, "fields//field", new OnChildren (OnField));
- }
-
- void ProcessMethods (XPathNavigator nav)
- {
- ProcessChildren (nav, "methods//method", new OnChildren (OnMethod));
- }
-
- void ProcessConstructors (XPathNavigator nav)
- {
- ProcessChildren (nav, "constructors//constructor", new OnChildren (OnConstructor));
- }
-
- void ProcessParameters (XPathNavigator nav)
- {
- ProcessChildren (nav, "parameters//parameter", new OnChildren (OnParameter));
- }
-
- void ProcessProperties (XPathNavigator nav)
- {
- ProcessChildren (nav, "properties//property", new OnChildren (OnProperty));
- }
-
- void ProcessEvents (XPathNavigator nav)
- {
- ProcessChildren (nav, "events//event", new OnChildren (OnEvent));
- }
-
- static void ProcessChildren (XPathNavigator nav, string children, OnChildren action)
- {
- XPathNodeIterator iterator = nav.Select (children);
- while (iterator.MoveNext ())
- action (iterator.Current);
- }
-
- delegate void OnChildren (XPathNavigator nav);
-
- static string GetName (XPathNavigator nav)
- {
- return GetAttribute (nav, _name);
- }
-
- static string GetAttribute (XPathNavigator nav, string attribute)
- {
- return nav.GetAttribute (attribute, _ns);
- }
- }
-}
diff --git a/src/linker/MIT.X11 b/src/linker/MIT.X11
deleted file mode 100644
index d2d78eedb..000000000
--- a/src/linker/MIT.X11
+++ /dev/null
@@ -1,21 +0,0 @@
-Copyright (c) 2007 Novell, Inc and the individuals listed on the
-ChangeLog entries.
-
-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.
diff --git a/src/linker/Mono.Linker.csproj b/src/linker/Mono.Linker.csproj
index 1d5405b48..cc0f02a27 100644
--- a/src/linker/Mono.Linker.csproj
+++ b/src/linker/Mono.Linker.csproj
@@ -6,51 +6,25 @@
<RunAnalyzers>true</RunAnalyzers>
</PropertyGroup>
- <PropertyGroup Condition="'$(MonoBuild)' == ''">
+ <PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
- <DefineConstants>$(DefineConstants);FEATURE_ILLINK</DefineConstants>
<IsPackable>true</IsPackable>
<!-- Nuget issues a warning about missing <reference> items in the generated nuspec,
used for packages.config which we do not support. -->
<NoWarn>$(NoWarn);NU5131</NoWarn>
</PropertyGroup>
- <PropertyGroup Condition="'$(MonoBuild)' != ''">
- <AssemblyName>monolinker</AssemblyName>
- <AssemblyTitle>Mono.Linker</AssemblyTitle>
- <Description>Mono CIL Linker</Description>
- <Copyright>(C) 2006, Jb Evain</Copyright>
- <TargetFramework>net471</TargetFramework>
- </PropertyGroup>
-
<ItemGroup>
<Compile Remove="ref\**\*.cs" />
<Compile Include="..\..\external\corert\**\*.cs" />
</ItemGroup>
- <ItemGroup Condition="'$(MonoBuild)' == ''">
- <Compile Remove="Linker\I18nAssemblies.cs" />
- <Compile Remove="Linker\XApiReader.cs" />
- <Compile Remove="Linker.Steps\LoadI18nAssemblies.cs" />
- <Compile Remove="Linker.Steps\PreserveCalendarsStep.cs" />
- <Compile Remove="Linker.Steps\RemoveFeaturesStep.cs" />
- <Compile Remove="Linker.Steps\ResolveFromXApiStep.cs" />
- <Compile Remove="Linker.Steps\ResolveFromAssemblyStep.cs" />
- <Compile Remove="System.Diagnostics.CodeAnalysis\*.cs" />
- </ItemGroup>
-
<ItemGroup>
<PackageReference Condition="'$(UseCecilPackage)' == 'true'" Include="Mono.Cecil" Version="$(MonoCecilVersion)" />
<ProjectReference Condition="'$(UseCecilPackage)' != 'true'" Include="..\..\external\cecil\Mono.Cecil.csproj" />
<ProjectReference Condition="'$(UseCecilPackage)' != 'true'" Include="..\..\external\cecil\symbols\pdb\Mono.Cecil.Pdb.csproj" PrivateAssets="all" />
</ItemGroup>
- <ItemGroup Condition="'$(MonoBuild)' != ''">
- <Compile Remove="Linker.Steps\RootAssemblyInputStep.cs" />
- <ProjectReference Condition="'$(UseCecilPackage)' != 'true'" Include="..\..\external\cecil\symbols\mdb\Mono.Cecil.Mdb.csproj" />
- <PackageReference Include="Microsoft.Bcl.HashCode" Version="1.1.0" />
- </ItemGroup>
-
<ItemGroup>
<Compile Update="Resources\Strings.Designer.cs">
<DesignTime>True</DesignTime>
diff --git a/src/linker/System.Diagnostics.CodeAnalysis/DynamicDependencyAttribute.cs b/src/linker/System.Diagnostics.CodeAnalysis/DynamicDependencyAttribute.cs
deleted file mode 100644
index b029c6cc9..000000000
--- a/src/linker/System.Diagnostics.CodeAnalysis/DynamicDependencyAttribute.cs
+++ /dev/null
@@ -1,14 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-
-#nullable enable
-
-namespace System.Diagnostics.CodeAnalysis
-{
- /// This is an internal version of the attribute in the framework at https://github.com/dotnet/runtime/blob/master/src/libraries/System.Private.CoreLib/src/System/Diagnostics/CodeAnalysis/DynamicDependencyAttribute.cs
- /// We currently only use the type as a generic parameter, so the implementation isn't copied.
- internal sealed class DynamicDependencyAttribute : Attribute
- {
- }
-}
diff --git a/src/linker/System.Diagnostics.CodeAnalysis/DynamicallyAccessedMemberTypes.cs b/src/linker/System.Diagnostics.CodeAnalysis/DynamicallyAccessedMemberTypes.cs
deleted file mode 100644
index 003872ce4..000000000
--- a/src/linker/System.Diagnostics.CodeAnalysis/DynamicallyAccessedMemberTypes.cs
+++ /dev/null
@@ -1,94 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-
-namespace System.Diagnostics.CodeAnalysis
-{
- /// <summary>
- /// Specifies the types of members that are dynamically accessed.
- ///
- /// This enumeration has a <see cref="FlagsAttribute"/> attribute that allows a
- /// bitwise combination of its member values.
- /// </summary>
- /// <remarks>
- /// This is a copy of the enum definition in the framework at https://github.com/dotnet/runtime/blob/master/src/libraries/System.Private.CoreLib/src/System/Diagnostics/CodeAnalysis/DynamicallyAccessedMemberTypes.cs
- /// </remarks>
- [Flags]
- internal enum DynamicallyAccessedMemberTypes
- {
- /// <summary>
- /// Specifies no members.
- /// </summary>
- None = 0,
-
- /// <summary>
- /// Specifies the default, parameterless public constructor.
- /// </summary>
- PublicParameterlessConstructor = 0x0001,
-
- /// <summary>
- /// Specifies all public constructors.
- /// </summary>
- PublicConstructors = 0x0002 | PublicParameterlessConstructor,
-
- /// <summary>
- /// Specifies all non-public constructors.
- /// </summary>
- NonPublicConstructors = 0x0004,
-
- /// <summary>
- /// Specifies all public methods.
- /// </summary>
- PublicMethods = 0x0008,
-
- /// <summary>
- /// Specifies all non-public methods.
- /// </summary>
- NonPublicMethods = 0x0010,
-
- /// <summary>
- /// Specifies all public fields.
- /// </summary>
- PublicFields = 0x0020,
-
- /// <summary>
- /// Specifies all non-public fields.
- /// </summary>
- NonPublicFields = 0x0040,
-
- /// <summary>
- /// Specifies all public nested types.
- /// </summary>
- PublicNestedTypes = 0x0080,
-
- /// <summary>
- /// Specifies all non-public nested types.
- /// </summary>
- NonPublicNestedTypes = 0x0100,
-
- /// <summary>
- /// Specifies all public properties.
- /// </summary>
- PublicProperties = 0x0200,
-
- /// <summary>
- /// Specifies all non-public properties.
- /// </summary>
- NonPublicProperties = 0x0400,
-
- /// <summary>
- /// Specifies all public events.
- /// </summary>
- PublicEvents = 0x0800,
-
- /// <summary>
- /// Specifies all non-public events.
- /// </summary>
- NonPublicEvents = 0x1000,
-
- /// <summary>
- /// Specifies all members.
- /// </summary>
- All = ~None
- }
-}
diff --git a/src/linker/System.Diagnostics.CodeAnalysis/RequiresUnreferencedCodeAttribute.cs b/src/linker/System.Diagnostics.CodeAnalysis/RequiresUnreferencedCodeAttribute.cs
deleted file mode 100644
index 8eb07a135..000000000
--- a/src/linker/System.Diagnostics.CodeAnalysis/RequiresUnreferencedCodeAttribute.cs
+++ /dev/null
@@ -1,43 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-
-namespace System.Diagnostics.CodeAnalysis
-{
- /// <summary>
- /// Indicates that the specified method requires dynamic access to code that is not referenced
- /// statically, for example through <see cref="System.Reflection"/>.
- /// </summary>
- /// <remarks>
- /// This allows tools to understand which methods are unsafe to call when removing unreferenced
- /// code from an application.
- ///
- /// This is a copy of the attribute from dotnet/runtime repo - once linker runs on .NET 5 this should be removed.
- /// </remarks>
- [AttributeUsage (AttributeTargets.Method | AttributeTargets.Constructor, Inherited = false)]
- internal sealed class RequiresUnreferencedCodeAttribute : Attribute
- {
- /// <summary>
- /// Initializes a new instance of the <see cref="RequiresUnreferencedCodeAttribute"/> class
- /// with the specified message.
- /// </summary>
- /// <param name="message">
- /// A message that contains information about the usage of unreferenced code.
- /// </param>
- public RequiresUnreferencedCodeAttribute (string message)
- {
- Message = message;
- }
-
- /// <summary>
- /// Gets a message that contains information about the usage of unreferenced code.
- /// </summary>
- public string Message { get; }
-
- /// <summary>
- /// Gets or sets an optional URL that contains more information about the method,
- /// why it requries unreferenced code, and what options a consumer has to deal with it.
- /// </summary>
- public string Url { get; set; }
- }
-} \ No newline at end of file
diff --git a/src/linker/profiler/Makefile b/src/linker/profiler/Makefile
deleted file mode 100644
index 6a9702bda..000000000
--- a/src/linker/profiler/Makefile
+++ /dev/null
@@ -1,8 +0,0 @@
-SRC = link.c
-OBJ = libmono-profiler-link.so
-
-all:
- gcc -g -Wall -shared -o $(OBJ) $(SRC) `pkg-config --cflags --libs mono`
-
-clean:
- rm -f $(OBJ)
diff --git a/src/linker/profiler/link.c b/src/linker/profiler/link.c
deleted file mode 100644
index f81e251be..000000000
--- a/src/linker/profiler/link.c
+++ /dev/null
@@ -1,362 +0,0 @@
-/*
- * link.c: a profiler to help the static linker
- *
- * Authors:
- * Jb Evain (jbevain@novell.com)
- *
- * (C) 2007 Novell, Inc. http://www.novell.com
- *
- */
-#include <glib.h>
-#include <string.h>
-#include <mono/metadata/assembly.h>
-#include <mono/metadata/class.h>
-#include <mono/metadata/image.h>
-#include <mono/metadata/metadata.h>
-#include <mono/metadata/profiler.h>
-
-struct _MonoProfiler {
- const char *output_file;
- GHashTable *images;
-};
-
-typedef struct _LinkedImage {
- MonoImage *image;
- GHashTable *types;
-} LinkedImage;
-
-typedef struct _LinkedType {
- MonoClass *klass;
- GHashTable *methods;
-} LinkedType;
-
-typedef struct _LinkedMethod {
- MonoMethod *method;
-} LinkedMethod;
-
-static void
-link_append_class_name (GString *res, MonoClass *klass, gboolean include_namespace)
-{
- if (!klass) {
- g_string_append (res, "**unknown**");
- return;
- }
-
- if (mono_class_get_nesting_type (klass)) {
- link_append_class_name (res, mono_class_get_nesting_type (klass), include_namespace);
- g_string_append_c (res, '/');
- }
-
- if (include_namespace && *(mono_class_get_namespace (klass)))
- g_string_sprintfa (res, "%s.", mono_class_get_namespace (klass));
-
- g_string_sprintfa (res, "%s", mono_class_get_name (klass));
-}
-
-static MonoType *
-link_get_element_type (MonoType *type)
-{
- return mono_class_get_type (mono_class_get_element_class (mono_class_from_mono_type (type)));
-}
-
-static void
-link_type_get_desc (GString *res, MonoType *type, gboolean include_namespace) {
- switch (mono_type_get_type (type)) {
- case MONO_TYPE_VOID:
- g_string_append (res, "System.Void"); break;
- case MONO_TYPE_CHAR:
- g_string_append (res, "System.Char"); break;
- case MONO_TYPE_BOOLEAN:
- g_string_append (res, "System.Boolean"); break;
- case MONO_TYPE_U1:
- g_string_append (res, "System.Byte"); break;
- case MONO_TYPE_I1:
- g_string_append (res, "System.SByte"); break;
- case MONO_TYPE_U2:
- g_string_append (res, "System.UInt16"); break;
- case MONO_TYPE_I2:
- g_string_append (res, "System.Int16"); break;
- case MONO_TYPE_U4:
- g_string_append (res, "System.UInt32"); break;
- case MONO_TYPE_I4:
- g_string_append (res, "System.Int32"); break;
- case MONO_TYPE_U8:
- g_string_append (res, "System.UInt64"); break;
- case MONO_TYPE_I8:
- g_string_append (res, "System.Int64"); break;
- case MONO_TYPE_FNPTR:
- g_string_append (res, "*()"); break;
- case MONO_TYPE_U:
- g_string_append (res, "System.UIntPtr"); break;
- case MONO_TYPE_I:
- g_string_append (res, "System.IntPtr"); break;
- case MONO_TYPE_R4:
- g_string_append (res, "System.Single"); break;
- case MONO_TYPE_R8:
- g_string_append (res, "System.Double"); break;
- case MONO_TYPE_STRING:
- g_string_append (res, "System.String"); break;
- case MONO_TYPE_OBJECT:
- g_string_append (res, "System.Object"); break;
- case MONO_TYPE_PTR:
- link_type_get_desc (res, mono_type_get_ptr_type (type), include_namespace);
- g_string_append_c (res, '*');
- break;
- case MONO_TYPE_ARRAY: {
- MonoClass *eklass = mono_class_get_element_class (mono_class_from_mono_type (type));
- link_type_get_desc (res, mono_class_get_type (eklass), include_namespace);
- g_string_sprintfa (res, "[%d]", mono_class_get_rank (eklass));
- break;
- }
- case MONO_TYPE_SZARRAY:
- link_type_get_desc (res, link_get_element_type (type), include_namespace);
- g_string_append (res, "[]");
- break;
- case MONO_TYPE_CLASS:
- case MONO_TYPE_VALUETYPE:
- link_append_class_name (res, mono_type_get_class (type), include_namespace);
- break;
- case MONO_TYPE_GENERICINST:
- //link_type_get_desc (res, &type->data.generic_class->container_class->byval_arg, include_namespace); /* ? */
- break;
- case MONO_TYPE_VAR:
- case MONO_TYPE_MVAR:
- //g_string_append (res, type->data.generic_param->name); /* ? */
- break;
- default:
- break;
- }
- if (mono_type_is_byref (type))
- g_string_append (res, "&amp;");
-}
-
-static char *
-link_type_full_name (MonoType *type)
-{
- GString *str;
- char *res;
-
- str = g_string_new ("");
- link_type_get_desc (str, type, TRUE);
-
- res = g_strdup (str->str);
- g_string_free (str, TRUE);
- return res;
-}
-
-static char *
-link_class_full_name (MonoClass *klass)
-{
- return link_type_full_name (mono_class_get_type (klass));
-}
-
-static char *
-link_signature_get_desc (MonoMethodSignature *sig, gboolean include_namespace)
-{
- int i;
- char *result;
- GString *res = g_string_new ("");
-
- for (i = 0; i < sig->param_count; ++i) {
- if (i > 0)
- g_string_append_c (res, ',');
- link_type_get_desc (res, sig->params [i], include_namespace);
- }
- result = res->str;
- g_string_free (res, FALSE);
- return result;
-}
-
-static char *
-link_method_signature (MonoMethod *method)
-{
- MonoMethodSignature *sig;
- char *res;
-
- sig = mono_method_signature (method);
- char *tmpsig = link_signature_get_desc (sig, TRUE);
- res = g_strdup_printf ("%s %s(%s)",
- link_type_full_name (mono_signature_get_return_type (sig)),
- mono_method_get_name (method), tmpsig);
- g_free (tmpsig);
-
- return res;
-}
-
-static char *
-link_image_fullname (MonoImage *image)
-{
- MonoAssemblyName *name;
- char *res;
-
- name = g_new0 (MonoAssemblyName, 1);
- mono_assembly_fill_assembly_name (image, name);
- res = mono_stringify_assembly_name (name);
- g_free (name);
- return res;
-}
-
-static LinkedType *
-link_get_linked_type (LinkedImage *limage, MonoClass *klass)
-{
- LinkedType *ltype;
-
- ltype = (LinkedType *) g_hash_table_lookup (limage->types, klass);
-
- if (ltype)
- return ltype;
-
- ltype = g_new0 (LinkedType, 1);
- ltype->klass = klass;
- ltype->methods = g_hash_table_new (NULL, NULL);
- g_hash_table_insert (limage->types, klass, ltype);
- return ltype;
-}
-
-static LinkedImage *
-link_get_linked_image (MonoProfiler *prof, MonoImage *image)
-{
- LinkedImage *limage;
-
- limage = (LinkedImage *) g_hash_table_lookup (prof->images, image);
-
- if (limage)
- return limage;
-
- limage = g_new0 (LinkedImage, 1);
- limage->image = image;
- limage->types = g_hash_table_new (NULL, NULL);
- g_hash_table_insert (prof->images, image, limage);
- return limage;
-}
-
-static void
-link_method_leave (MonoProfiler *prof, MonoMethod *method)
-{
- MonoClass *klass;
- MonoImage *image;
-
- LinkedType *ltype;
- LinkedImage *limage;
- LinkedMethod *lmethod;
-
- klass = mono_method_get_class (method);
- image = mono_class_get_image (klass);
-
- limage = link_get_linked_image (prof, image);
- ltype = link_get_linked_type (limage, klass);
-
- lmethod = (LinkedMethod *) g_hash_table_lookup (ltype->methods, method);
- if (lmethod)
- return;
-
- lmethod = g_new0 (LinkedMethod, 1);
- lmethod->method = method;
- g_hash_table_insert (ltype->methods, method, lmethod);
-}
-
-static void
-link_free_member (gpointer key, gpointer value, gpointer data)
-{
- g_free (value);
-}
-
-static void
-link_free_type (gpointer key, gpointer value, gpointer data)
-{
- LinkedType *type = (LinkedType *) value;
-
- g_hash_table_foreach (type->methods, link_free_member, NULL);
- g_free (type);
-}
-
-static void
-link_free_image (gpointer key, gpointer value, gpointer data)
-{
- LinkedImage *image = (LinkedImage *) value;
-
- g_hash_table_foreach (image->types, link_free_type, NULL);
- g_free (image);
-}
-
-static void
-link_print_method (gpointer key, gpointer value, gpointer data)
-{
- LinkedMethod *lmethod = (LinkedMethod *) value;
- FILE *output = (FILE *) data;
- char *signature;
-
- signature = link_method_signature (lmethod->method);
- fprintf (output, "\t\t\t<method signature=\"%s\" />\n", signature);
- g_free (signature);
-}
-
-static void
-link_print_type (gpointer key, gpointer value, gpointer data)
-{
- LinkedType *ltype = (LinkedType *) value;
- FILE *output = (FILE *) data;
- char *fullname;
-
- fullname = link_class_full_name (ltype->klass);
- fprintf (output, "\t\t<type fullname=\"%s\">\n", fullname);
- g_free (fullname);
-
- g_hash_table_foreach (ltype->methods, link_print_method, output);
- fprintf (output, "\t\t</type>\n");
-}
-
-static void
-link_print_image (gpointer key, gpointer value, gpointer data)
-{
- LinkedImage *limage = (LinkedImage *) value;
- FILE *output = (FILE *) data;
- char *fullname;
-
- fullname = link_image_fullname (limage->image);
- fprintf (output, "\t<assembly fullname=\"%s\">\n", fullname);
- g_free (fullname);
- g_hash_table_foreach (limage->types, link_print_type, output);
- fprintf (output, "\t</assembly>\n");
-}
-
-static void
-link_print_tree (MonoProfiler *prof)
-{
- FILE *output;
-
- output = fopen (prof->output_file, "w");
- fprintf (output, "<linker>\n");
- g_hash_table_foreach (prof->images, link_print_image, output);
- fprintf (output, "</linker>\n");
- fclose (output);
-}
-
-static void
-link_shutdown (MonoProfiler *prof)
-{
- link_print_tree (prof);
- g_hash_table_foreach (prof->images, link_free_image, NULL);
- g_free (prof);
-}
-
-void
-mono_profiler_startup (const char *desc)
-{
- MonoProfiler *prof;
-
- prof = g_new0 (MonoProfiler, 1);
-
- if (strncmp ("link:", desc, 5) == 0 && desc [5])
- prof->output_file = g_strdup (desc + 5);
- else
- prof->output_file = "link.xml";
-
- prof->images = g_hash_table_new (NULL, NULL);
-
- mono_profiler_install (prof, link_shutdown);
-
- mono_profiler_install_enter_leave (NULL, link_method_leave);
-
- mono_profiler_set_events (MONO_PROFILE_ENTER_LEAVE);
-}
diff --git a/src/tuner/Mono.Tuner.csproj b/src/tuner/Mono.Tuner.csproj
deleted file mode 100644
index f35a14ade..000000000
--- a/src/tuner/Mono.Tuner.csproj
+++ /dev/null
@@ -1,71 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <PropertyGroup>
- <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
- <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
- <ProductVersion>8.0.50727</ProductVersion>
- <SchemaVersion>2.0</SchemaVersion>
- <ProjectGuid>{E97429BA-279A-4C1D-AE8A-8BD878C661D1}</ProjectGuid>
- <OutputType>Library</OutputType>
- <AppDesignerFolder>Properties</AppDesignerFolder>
- <RootNamespace>Mono.Tuner</RootNamespace>
- <AssemblyName>Mono.Tuner</AssemblyName>
- </PropertyGroup>
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
- <DebugSymbols>True</DebugSymbols>
- <DebugType>full</DebugType>
- <Optimize>False</Optimize>
- <OutputPath>bin\Debug\</OutputPath>
- <DefineConstants>DEBUG;TRACE</DefineConstants>
- <ErrorReport>prompt</ErrorReport>
- <WarningLevel>4</WarningLevel>
- </PropertyGroup>
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
- <DebugType>pdbonly</DebugType>
- <Optimize>True</Optimize>
- <OutputPath>bin\Release\</OutputPath>
- <DefineConstants>TRACE</DefineConstants>
- <ErrorReport>prompt</ErrorReport>
- <WarningLevel>4</WarningLevel>
- </PropertyGroup>
- <ItemGroup>
- <Reference Include="System" />
- <Reference Include="System.Xml" />
- </ItemGroup>
- <ItemGroup>
- <Compile Include="Mono.Tuner\AdjustVisibility.cs" />
- <Compile Include="Mono.Tuner\CheckVisibility.cs" />
- <Compile Include="Mono.Tuner\PrintStatus.cs" />
- <Compile Include="Mono.Tuner\RemoveSerialization.cs" />
- <Compile Include="Mono.Tuner\TunerAnnotations.cs" />
- <Compile Include="Mono.Tuner\InjectSecurityAttributes.cs" />
- <Compile Include="Mono.Tuner\MoonlightAssemblyStep.cs" />
- <Compile Include="Mono.Tuner\FilterAttributes.cs" />
- <Compile Include="Mono.Tuner\MoonlightA11yProcessor.cs" />
- <Compile Include="Mono.Tuner\MoonlightA11yAssemblyStep.cs" />
- <Compile Include="Mono.Tuner\MoonlightA11yUsageInspectionStep.cs" />
- <Compile Include="Mono.Tuner\MoonlightA11yDescriptorGenerator.cs" />
- <Compile Include="Mono.Tuner\MoonlightA11yApiMarker.cs" />
- </ItemGroup>
- <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
- <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
- Other similar extension points exist, see Microsoft.Common.targets.
- <Target Name="BeforeBuild">
- </Target>
- <Target Name="AfterBuild">
- </Target>
- -->
- <ItemGroup>
- <None Include="Makefile" />
- </ItemGroup>
- <ItemGroup>
- <ProjectReference Include="..\linker\Mono.Linker.csproj">
- <Project>{DD28E2B1-057B-4B4D-A04D-B2EBD9E76E46}</Project>
- <Name>Mono.Linker</Name>
- </ProjectReference>
- <ProjectReference Include="..\..\external\cecil\Mono.Cecil.csproj">
- <Project>{D68133BD-1E63-496E-9EDE-4FBDBF77B486}</Project>
- <Name>Mono.Cecil</Name>
- </ProjectReference>
- </ItemGroup>
-</Project> \ No newline at end of file
diff --git a/src/tuner/Mono.Tuner/AdjustVisibility.cs b/src/tuner/Mono.Tuner/AdjustVisibility.cs
deleted file mode 100644
index 6b684b606..000000000
--- a/src/tuner/Mono.Tuner/AdjustVisibility.cs
+++ /dev/null
@@ -1,164 +0,0 @@
-//
-// AdjustVisibilityStep.cs
-//
-// Author:
-// Jb Evain (jbevain@novell.com)
-//
-// (C) 2007 Novell, Inc.
-//
-// 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.
-//
-
-using System;
-using System.Collections;
-using System.Collections.Generic;
-
-using Mono.Linker;
-using Mono.Linker.Steps;
-
-using Mono.Cecil;
-
-namespace Mono.Tuner {
-
- public class AdjustVisibility : BaseStep {
- protected override void ProcessAssembly (AssemblyDefinition assembly)
- {
- if (Annotations.GetAction (assembly) != AssemblyAction.Link)
- return;
-
- ProcessTypes (assembly.MainModule.Types);
- }
-
- void ProcessTypes (ICollection types)
- {
- foreach (TypeDefinition type in types)
- ProcessType (type);
- }
-
- void ProcessType (TypeDefinition type)
- {
- if (!IsPublic (type))
- return;
-
- if (!IsMarkedAsPublic (type)) {
- SetInternalVisibility (type);
- return;
- }
-
- if (type.IsEnum)
- return;
-
- ProcessFields (type.Fields);
- ProcessMethods (type.Methods);
- }
-
- static bool IsPublic (TypeDefinition type)
- {
- return type.DeclaringType == null ? type.IsPublic : type.IsNestedPublic;
- }
-
- void SetInternalVisibility (TypeDefinition type)
- {
- type.Attributes &= ~TypeAttributes.VisibilityMask;
- if (type.DeclaringType == null)
- type.Attributes |= TypeAttributes.NotPublic;
- else
- type.Attributes |= TypeAttributes.NestedAssembly;
-
- MarkInternalized (type);
- }
-
- void ProcessMethods (ICollection methods)
- {
- foreach (MethodDefinition method in methods)
- ProcessMethod (method);
- }
-
- void ProcessMethod (MethodDefinition method)
- {
- if (IsMarkedAsPublic (method))
- return;
-
- if (method.IsPublic)
- SetInternalVisibility (method);
- else if (method.IsFamily || method.IsFamilyOrAssembly)
- SetProtectedAndInternalVisibility (method);
- }
-
- void SetInternalVisibility (MethodDefinition method)
- {
- method.Attributes &= ~MethodAttributes.MemberAccessMask;
- method.Attributes |= MethodAttributes.Assembly;
-
- MarkInternalized (method);
- }
-
- void SetProtectedAndInternalVisibility (MethodDefinition method)
- {
- method.Attributes &= ~MethodAttributes.MemberAccessMask;
- method.Attributes |= MethodAttributes.FamANDAssem;
-
- MarkInternalized (method);
- }
-
- bool IsMarkedAsPublic (IMetadataTokenProvider provider)
- {
- return Annotations.IsPublic (provider);
- }
-
- void ProcessFields (IEnumerable<FieldDefinition> fields)
- {
- foreach (FieldDefinition field in fields)
- ProcessField (field);
- }
-
- void ProcessField (FieldDefinition field)
- {
- if (IsMarkedAsPublic (field))
- return;
-
- if (field.IsPublic)
- SetInternalVisibility (field);
- else if (field.IsFamily || field.IsFamilyOrAssembly)
- SetProtectedAndInternalVisibility (field);
- }
-
- void SetInternalVisibility (FieldDefinition field)
- {
- field.Attributes &= ~FieldAttributes.FieldAccessMask;
- field.Attributes |= FieldAttributes.Assembly;
-
- MarkInternalized (field);
- }
-
- void SetProtectedAndInternalVisibility (FieldDefinition field)
- {
- field.Attributes &= ~FieldAttributes.FieldAccessMask;
- field.Attributes |= FieldAttributes.FamANDAssem;
-
- MarkInternalized (field);
- }
-
- void MarkInternalized (IMetadataTokenProvider provider)
- {
- TunerAnnotations.Internalized (Context, provider);
- }
- }
-}
diff --git a/src/tuner/Mono.Tuner/ApplyPreserveAttributeBase.cs b/src/tuner/Mono.Tuner/ApplyPreserveAttributeBase.cs
deleted file mode 100644
index 6a910a9d9..000000000
--- a/src/tuner/Mono.Tuner/ApplyPreserveAttributeBase.cs
+++ /dev/null
@@ -1,164 +0,0 @@
-using System;
-using System.Collections;
-using System.Collections.Generic;
-using System.Linq;
-
-using Mono.Linker;
-using Mono.Linker.Steps;
-
-using Mono.Cecil;
-
-namespace Mono.Tuner {
-
- public abstract class ApplyPreserveAttributeBase : BaseSubStep {
-
- // set 'removeAttribute' to true if you want the preserved attribute to be removed from the final assembly
- protected abstract bool IsPreservedAttribute (ICustomAttributeProvider provider, CustomAttribute attribute, out bool removeAttribute);
-
- public override SubStepTargets Targets {
- get {
- return SubStepTargets.Type
- | SubStepTargets.Field
- | SubStepTargets.Method
- | SubStepTargets.Property
- | SubStepTargets.Event;
- }
- }
-
- public override bool IsActiveFor (AssemblyDefinition assembly)
- {
- return !Profile.IsSdkAssembly (assembly) && Annotations.GetAction (assembly) == AssemblyAction.Link;
- }
-
- public override void ProcessType (TypeDefinition type)
- {
- TryApplyPreserveAttribute (type);
- }
-
- public override void ProcessField (FieldDefinition field)
- {
- foreach (var attribute in GetPreserveAttributes (field))
- Mark (field, attribute);
- }
-
- public override void ProcessMethod (MethodDefinition method)
- {
- MarkMethodIfPreserved (method);
- }
-
- public override void ProcessProperty (PropertyDefinition property)
- {
- foreach (var attribute in GetPreserveAttributes (property)) {
- MarkMethod (property.GetMethod, attribute);
- MarkMethod (property.SetMethod, attribute);
- }
- }
-
- public override void ProcessEvent (EventDefinition @event)
- {
- foreach (var attribute in GetPreserveAttributes (@event)) {
- MarkMethod (@event.AddMethod, attribute);
- MarkMethod (@event.InvokeMethod, attribute);
- MarkMethod (@event.RemoveMethod, attribute);
- }
- }
-
- void MarkMethodIfPreserved (MethodDefinition method)
- {
- foreach (var attribute in GetPreserveAttributes (method))
- MarkMethod (method, attribute);
- }
-
- void MarkMethod (MethodDefinition method, CustomAttribute preserve_attribute)
- {
- if (method == null)
- return;
-
- Mark (method, preserve_attribute);
- Annotations.SetAction (method, MethodAction.Parse);
- }
-
- void Mark (IMetadataTokenProvider provider, CustomAttribute preserve_attribute)
- {
- if (IsConditionalAttribute (preserve_attribute)) {
- PreserveConditional (provider);
- return;
- }
-
- PreserveUnconditional (provider);
- }
-
- void PreserveConditional (IMetadataTokenProvider provider)
- {
- var method = provider as MethodDefinition;
- if (method == null) {
- // workaround to support (uncommon but valid) conditional fields form [Preserve]
- PreserveUnconditional (provider);
- return;
- }
-
- Annotations.AddPreservedMethod (method.DeclaringType, method);
- }
-
- static bool IsConditionalAttribute (CustomAttribute attribute)
- {
- if (attribute == null)
- return false;
-
- foreach (var named_argument in attribute.Fields)
- if (named_argument.Name == "Conditional")
- return (bool) named_argument.Argument.Value;
-
- return false;
- }
-
- void PreserveUnconditional (IMetadataTokenProvider provider)
- {
- Annotations.Mark (provider);
-
- var member = provider as IMemberDefinition;
- if (member == null || member.DeclaringType == null)
- return;
-
- Mark (member.DeclaringType, null);
- }
-
- void TryApplyPreserveAttribute (TypeDefinition type)
- {
- foreach (var attribute in GetPreserveAttributes (type)) {
- Annotations.Mark (type);
-
- if (!attribute.HasFields)
- continue;
-
- foreach (var named_argument in attribute.Fields)
- if (named_argument.Name == "AllMembers" && (bool)named_argument.Argument.Value)
- Annotations.SetPreserve (type, TypePreserve.All);
- }
- }
-
- List<CustomAttribute> GetPreserveAttributes (ICustomAttributeProvider provider)
- {
- List<CustomAttribute> attrs = new List<CustomAttribute> ();
-
- if (!provider.HasCustomAttributes)
- return attrs;
-
- var attributes = provider.CustomAttributes;
-
- for (int i = attributes.Count - 1; i >= 0; i--) {
- var attribute = attributes [i];
-
- bool remote_attribute;
- if (!IsPreservedAttribute (provider, attribute, out remote_attribute))
- continue;
-
- attrs.Add (attribute);
- if (remote_attribute)
- attributes.RemoveAt (i);
- }
-
- return attrs;
- }
- }
-}
diff --git a/src/tuner/Mono.Tuner/CecilRocks.cs b/src/tuner/Mono.Tuner/CecilRocks.cs
deleted file mode 100644
index 69958598d..000000000
--- a/src/tuner/Mono.Tuner/CecilRocks.cs
+++ /dev/null
@@ -1,519 +0,0 @@
-//
-// MethodBodyRocks.cs
-//
-// Author:
-// Jb Evain (jbevain@gmail.com)
-//
-// Copyright (c) 2008 - 2011 Jb Evain
-//
-// 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.
-//
-
-using System;
-using System.Collections.Generic;
-using System.Linq;
-
-using Mono.Cecil;
-using Mono.Cecil.Cil;
-
-namespace Mono.Tuner {
-
- public static class MethodBodyRocks {
-
- public static IEnumerable<TypeDefinition> GetAllTypes (this ModuleDefinition self)
- {
- return self.Types.SelectMany (t => t.GetAllTypes ());
- }
-
- static IEnumerable<TypeDefinition> GetAllTypes (this TypeDefinition self)
- {
- yield return self;
-
- if (!self.HasNestedTypes)
- yield break;
-
- foreach (var type in self.NestedTypes.SelectMany (t => t.GetAllTypes ()))
- yield return type;
- }
-
- public static IEnumerable<MethodDefinition> GetMethods (this TypeDefinition self)
- {
- return self.Methods.Where (m => !m.IsConstructor);
- }
-
- public static IEnumerable<MethodDefinition> GetConstructors (this TypeDefinition self)
- {
- return self.Methods.Where (m => m.IsConstructor);
- }
-
- public static MethodDefinition GetTypeConstructor (this TypeDefinition self)
- {
- return self.GetConstructors ().FirstOrDefault (c => c.IsStatic);
- }
-
- public static void SimplifyMacros (this MethodBody self)
- {
- if (self == null)
- throw new ArgumentNullException ("self");
-
- foreach (var instruction in self.Instructions) {
- if (instruction.OpCode.OpCodeType != OpCodeType.Macro)
- continue;
-
- switch (instruction.OpCode.Code) {
- case Code.Ldarg_0:
- ExpandMacro (instruction, OpCodes.Ldarg, self.GetParameter (0));
- break;
- case Code.Ldarg_1:
- ExpandMacro (instruction, OpCodes.Ldarg, self.GetParameter (1));
- break;
- case Code.Ldarg_2:
- ExpandMacro (instruction, OpCodes.Ldarg, self.GetParameter (2));
- break;
- case Code.Ldarg_3:
- ExpandMacro (instruction, OpCodes.Ldarg, self.GetParameter (3));
- break;
- case Code.Ldloc_0:
- ExpandMacro (instruction, OpCodes.Ldloc, self.Variables [0]);
- break;
- case Code.Ldloc_1:
- ExpandMacro (instruction, OpCodes.Ldloc, self.Variables [1]);
- break;
- case Code.Ldloc_2:
- ExpandMacro (instruction, OpCodes.Ldloc, self.Variables [2]);
- break;
- case Code.Ldloc_3:
- ExpandMacro (instruction, OpCodes.Ldloc, self.Variables [3]);
- break;
- case Code.Stloc_0:
- ExpandMacro (instruction, OpCodes.Stloc, self.Variables [0]);
- break;
- case Code.Stloc_1:
- ExpandMacro (instruction, OpCodes.Stloc, self.Variables [1]);
- break;
- case Code.Stloc_2:
- ExpandMacro (instruction, OpCodes.Stloc, self.Variables [2]);
- break;
- case Code.Stloc_3:
- ExpandMacro (instruction, OpCodes.Stloc, self.Variables [3]);
- break;
- case Code.Ldarg_S:
- instruction.OpCode = OpCodes.Ldarg;
- break;
- case Code.Ldarga_S:
- instruction.OpCode = OpCodes.Ldarga;
- break;
- case Code.Starg_S:
- instruction.OpCode = OpCodes.Starg;
- break;
- case Code.Ldloc_S:
- instruction.OpCode = OpCodes.Ldloc;
- break;
- case Code.Ldloca_S:
- instruction.OpCode = OpCodes.Ldloca;
- break;
- case Code.Stloc_S:
- instruction.OpCode = OpCodes.Stloc;
- break;
- case Code.Ldc_I4_M1:
- ExpandMacro (instruction, OpCodes.Ldc_I4, -1);
- break;
- case Code.Ldc_I4_0:
- ExpandMacro (instruction, OpCodes.Ldc_I4, 0);
- break;
- case Code.Ldc_I4_1:
- ExpandMacro (instruction, OpCodes.Ldc_I4, 1);
- break;
- case Code.Ldc_I4_2:
- ExpandMacro (instruction, OpCodes.Ldc_I4, 2);
- break;
- case Code.Ldc_I4_3:
- ExpandMacro (instruction, OpCodes.Ldc_I4, 3);
- break;
- case Code.Ldc_I4_4:
- ExpandMacro (instruction, OpCodes.Ldc_I4, 4);
- break;
- case Code.Ldc_I4_5:
- ExpandMacro (instruction, OpCodes.Ldc_I4, 5);
- break;
- case Code.Ldc_I4_6:
- ExpandMacro (instruction, OpCodes.Ldc_I4, 6);
- break;
- case Code.Ldc_I4_7:
- ExpandMacro (instruction, OpCodes.Ldc_I4, 7);
- break;
- case Code.Ldc_I4_8:
- ExpandMacro (instruction, OpCodes.Ldc_I4, 8);
- break;
- case Code.Ldc_I4_S:
- ExpandMacro (instruction, OpCodes.Ldc_I4, (int) (sbyte) instruction.Operand);
- break;
- case Code.Br_S:
- instruction.OpCode = OpCodes.Br;
- break;
- case Code.Brfalse_S:
- instruction.OpCode = OpCodes.Brfalse;
- break;
- case Code.Brtrue_S:
- instruction.OpCode = OpCodes.Brtrue;
- break;
- case Code.Beq_S:
- instruction.OpCode = OpCodes.Beq;
- break;
- case Code.Bge_S:
- instruction.OpCode = OpCodes.Bge;
- break;
- case Code.Bgt_S:
- instruction.OpCode = OpCodes.Bgt;
- break;
- case Code.Ble_S:
- instruction.OpCode = OpCodes.Ble;
- break;
- case Code.Blt_S:
- instruction.OpCode = OpCodes.Blt;
- break;
- case Code.Bne_Un_S:
- instruction.OpCode = OpCodes.Bne_Un;
- break;
- case Code.Bge_Un_S:
- instruction.OpCode = OpCodes.Bge_Un;
- break;
- case Code.Bgt_Un_S:
- instruction.OpCode = OpCodes.Bgt_Un;
- break;
- case Code.Ble_Un_S:
- instruction.OpCode = OpCodes.Ble_Un;
- break;
- case Code.Blt_Un_S:
- instruction.OpCode = OpCodes.Blt_Un;
- break;
- case Code.Leave_S:
- instruction.OpCode = OpCodes.Leave;
- break;
- }
- }
- }
-
- static void ExpandMacro (Instruction instruction, OpCode opcode, object operand)
- {
- instruction.OpCode = opcode;
- instruction.Operand = operand;
- }
-
- static void MakeMacro (Instruction instruction, OpCode opcode)
- {
- instruction.OpCode = opcode;
- instruction.Operand = null;
- }
-
- public static void OptimizeMacros (this MethodBody self)
- {
- if (self == null)
- throw new ArgumentNullException ("self");
-
- var method = self.Method;
-
- foreach (var instruction in self.Instructions) {
- int index;
- switch (instruction.OpCode.Code) {
- case Code.Ldarg:
- index = ((ParameterDefinition) instruction.Operand).Index;
- if (index == -1 && instruction.Operand == self.ThisParameter)
- index = 0;
- else if (method.HasThis)
- index++;
-
- switch (index) {
- case 0:
- MakeMacro (instruction, OpCodes.Ldarg_0);
- break;
- case 1:
- MakeMacro (instruction, OpCodes.Ldarg_1);
- break;
- case 2:
- MakeMacro (instruction, OpCodes.Ldarg_2);
- break;
- case 3:
- MakeMacro (instruction, OpCodes.Ldarg_3);
- break;
- default:
- if (index < 256)
- ExpandMacro (instruction, OpCodes.Ldarg_S, instruction.Operand);
- break;
- }
- break;
- case Code.Ldloc:
- index = ((VariableDefinition) instruction.Operand).Index;
- switch (index) {
- case 0:
- MakeMacro (instruction, OpCodes.Ldloc_0);
- break;
- case 1:
- MakeMacro (instruction, OpCodes.Ldloc_1);
- break;
- case 2:
- MakeMacro (instruction, OpCodes.Ldloc_2);
- break;
- case 3:
- MakeMacro (instruction, OpCodes.Ldloc_3);
- break;
- default:
- if (index < 256)
- ExpandMacro (instruction, OpCodes.Ldloc_S, instruction.Operand);
- break;
- }
- break;
- case Code.Stloc:
- index = ((VariableDefinition) instruction.Operand).Index;
- switch (index) {
- case 0:
- MakeMacro (instruction, OpCodes.Stloc_0);
- break;
- case 1:
- MakeMacro (instruction, OpCodes.Stloc_1);
- break;
- case 2:
- MakeMacro (instruction, OpCodes.Stloc_2);
- break;
- case 3:
- MakeMacro (instruction, OpCodes.Stloc_3);
- break;
- default:
- if (index < 256)
- ExpandMacro (instruction, OpCodes.Stloc_S, instruction.Operand);
- break;
- }
- break;
- case Code.Ldarga:
- index = ((ParameterDefinition) instruction.Operand).Index;
- if (index == -1 && instruction.Operand == self.ThisParameter)
- index = 0;
- else if (method.HasThis)
- index++;
- if (index < 256)
- ExpandMacro (instruction, OpCodes.Ldarga_S, instruction.Operand);
- break;
- case Code.Ldloca:
- if (((VariableDefinition) instruction.Operand).Index < 256)
- ExpandMacro (instruction, OpCodes.Ldloca_S, instruction.Operand);
- break;
- case Code.Ldc_I4:
- int i = (int) instruction.Operand;
- switch (i) {
- case -1:
- MakeMacro (instruction, OpCodes.Ldc_I4_M1);
- break;
- case 0:
- MakeMacro (instruction, OpCodes.Ldc_I4_0);
- break;
- case 1:
- MakeMacro (instruction, OpCodes.Ldc_I4_1);
- break;
- case 2:
- MakeMacro (instruction, OpCodes.Ldc_I4_2);
- break;
- case 3:
- MakeMacro (instruction, OpCodes.Ldc_I4_3);
- break;
- case 4:
- MakeMacro (instruction, OpCodes.Ldc_I4_4);
- break;
- case 5:
- MakeMacro (instruction, OpCodes.Ldc_I4_5);
- break;
- case 6:
- MakeMacro (instruction, OpCodes.Ldc_I4_6);
- break;
- case 7:
- MakeMacro (instruction, OpCodes.Ldc_I4_7);
- break;
- case 8:
- MakeMacro (instruction, OpCodes.Ldc_I4_8);
- break;
- default:
- if (i >= -128 && i < 128)
- ExpandMacro (instruction, OpCodes.Ldc_I4_S, (sbyte) i);
- break;
- }
- break;
- }
- }
-
- OptimizeBranches (self);
- }
-
- static void OptimizeBranches (MethodBody body)
- {
- ComputeOffsets (body);
-
- foreach (var instruction in body.Instructions) {
- if (instruction.OpCode.OperandType != OperandType.InlineBrTarget)
- continue;
-
- if (OptimizeBranch (instruction))
- ComputeOffsets (body);
- }
- }
-
- static bool OptimizeBranch (Instruction instruction)
- {
- var offset = ((Instruction) instruction.Operand).Offset - (instruction.Offset + instruction.OpCode.Size + 4);
- if (!(offset >= -128 && offset <= 127))
- return false;
-
- switch (instruction.OpCode.Code) {
- case Code.Br:
- instruction.OpCode = OpCodes.Br_S;
- break;
- case Code.Brfalse:
- instruction.OpCode = OpCodes.Brfalse_S;
- break;
- case Code.Brtrue:
- instruction.OpCode = OpCodes.Brtrue_S;
- break;
- case Code.Beq:
- instruction.OpCode = OpCodes.Beq_S;
- break;
- case Code.Bge:
- instruction.OpCode = OpCodes.Bge_S;
- break;
- case Code.Bgt:
- instruction.OpCode = OpCodes.Bgt_S;
- break;
- case Code.Ble:
- instruction.OpCode = OpCodes.Ble_S;
- break;
- case Code.Blt:
- instruction.OpCode = OpCodes.Blt_S;
- break;
- case Code.Bne_Un:
- instruction.OpCode = OpCodes.Bne_Un_S;
- break;
- case Code.Bge_Un:
- instruction.OpCode = OpCodes.Bge_Un_S;
- break;
- case Code.Bgt_Un:
- instruction.OpCode = OpCodes.Bgt_Un_S;
- break;
- case Code.Ble_Un:
- instruction.OpCode = OpCodes.Ble_Un_S;
- break;
- case Code.Blt_Un:
- instruction.OpCode = OpCodes.Blt_Un_S;
- break;
- case Code.Leave:
- instruction.OpCode = OpCodes.Leave_S;
- break;
- }
-
- return true;
- }
-
- static void ComputeOffsets (MethodBody body)
- {
- var offset = 0;
- foreach (var instruction in body.Instructions) {
- instruction.Offset = offset;
- offset += instruction.GetSize ();
- }
- }
-
- public static ParameterDefinition GetParameter (this MethodBody self, int index)
- {
- var method = self.Method;
-
- if (method.HasThis) {
- if (index == 0)
- return self.ThisParameter;
-
- index--;
- }
-
- var parameters = method.Parameters;
-
- if (index < 0 || index >= parameters.Count)
- return null;
-
- return parameters [index];
- }
-
- public static bool Implements (this TypeReference self, string interfaceName)
- {
- if (interfaceName == null)
- throw new ArgumentNullException ("interfaceName");
- if (self == null)
- return false;
-
- TypeDefinition type = self.Resolve ();
- if (type == null)
- return false; // not enough information available
-
- // special case, check if we implement ourselves
- if (type.IsInterface && (type.FullName == interfaceName))
- return true;
-
- return Implements (type, interfaceName, (interfaceName.IndexOf ('`') >= 0));
- }
-
- public static bool Implements (TypeDefinition type, string interfaceName, bool generic)
- {
- while (type != null) {
- // does the type implements it itself
- if (type.HasInterfaces) {
- foreach (var iface in type.Interfaces) {
- string fullname = (generic) ? iface.InterfaceType.GetElementType ().FullName : iface.InterfaceType.FullName;
- if (fullname == interfaceName)
- return true;
- //if not, then maybe one of its parent interfaces does
- if (Implements (iface.InterfaceType.Resolve (), interfaceName, generic))
- return true;
- }
- }
-
- type = type.BaseType != null ? type.BaseType.Resolve () : null;
- }
- return false;
- }
-
- public static bool Inherits (this TypeReference self, string @namespace, string name)
- {
- if (@namespace == null)
- throw new ArgumentNullException ("namespace");
- if (name == null)
- throw new ArgumentNullException ("name");
- if (self == null)
- return false;
-
- TypeReference current = self.Resolve ();
- while (current != null) {
- if (current.Is (@namespace, name))
- return true;
- if (current.Is ("System", "Object"))
- return false;
-
- TypeDefinition td = current.Resolve ();
- if (td == null)
- return false; // could not resolve type
- current = td.BaseType;
- }
- return false;
- }
- }
-}
diff --git a/src/tuner/Mono.Tuner/CheckVisibility.cs b/src/tuner/Mono.Tuner/CheckVisibility.cs
deleted file mode 100644
index df553db5a..000000000
--- a/src/tuner/Mono.Tuner/CheckVisibility.cs
+++ /dev/null
@@ -1,375 +0,0 @@
-//
-// CheckVisibility.cs
-//
-// Author:
-// Jb Evain (jbevain@novell.com)
-//
-// (C) 2007 Novell, Inc.
-//
-// 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.
-//
-
-using System;
-using System.Collections;
-using System.Text;
-
-using Mono.Linker;
-using Mono.Linker.Steps;
-
-using Mono.Cecil;
-using Mono.Cecil.Cil;
-
-namespace Mono.Tuner {
-
- public class CheckVisibility : BaseStep {
-
- bool throw_on_error;
-
- protected override void Process ()
- {
- throw_on_error = GetThrowOnVisibilityErrorParameter ();
- }
-
- bool GetThrowOnVisibilityErrorParameter ()
- {
- try {
- return bool.Parse (Context.GetParameter ("throw_on_visibility_error"));
- } catch {
- return false;
- }
- }
-
- protected override void ProcessAssembly (AssemblyDefinition assembly)
- {
- if (assembly.Name.Name == "mscorlib" || assembly.Name.Name == "smcs")
- return;
-
- if (Annotations.GetAction (assembly) != AssemblyAction.Link)
- return;
-
- Report ("in assembly {0}", assembly.Name);
-
- foreach (ModuleDefinition module in assembly.Modules)
- foreach (TypeDefinition type in module.Types)
- CheckType (type);
- }
-
- void CheckType (TypeDefinition type)
- {
- if (!IsVisibleFrom (type, type.BaseType)) {
- ReportError ("Base type `{0}` of type `{1}` is not visible",
- type.BaseType, type);
- }
-
- CheckInterfaces (type);
-
- CheckFields (type);
- CheckMethods (type);
- }
-
- void CheckInterfaces (TypeDefinition type)
- {
- foreach (var iface in type.Interfaces) {
- if (!IsVisibleFrom (type, iface.InterfaceType)) {
- ReportError ("Interface `{0}` implemented by `{1}` is not visible",
- iface, type);
- }
- }
- }
-
- static bool IsPublic (TypeDefinition type)
- {
- return (type.DeclaringType == null && type.IsPublic) || type.IsNestedPublic;
- }
-
- static bool AreInDifferentAssemblies (TypeDefinition type, TypeDefinition target)
- {
- if (type.Module.Assembly.Name.FullName == target.Module.Assembly.Name.FullName)
- return false;
-
- return !IsInternalVisibleTo (target.Module.Assembly, type.Module.Assembly);
- }
-
- static bool IsInternalVisibleTo (AssemblyDefinition assembly, AssemblyDefinition candidate)
- {
- foreach (CustomAttribute attribute in assembly.CustomAttributes) {
- if (!IsInternalsVisibleToAttribute (attribute))
- continue;
-
- if (attribute.ConstructorArguments.Count == 0)
- continue;
-
- string signature = (string) attribute.ConstructorArguments [0].Value;
-
- if (InternalsVisibleToSignatureMatch (signature, candidate.Name))
- return true;
- }
-
- return false;
- }
-
- static bool InternalsVisibleToSignatureMatch (string signature, AssemblyNameReference reference)
- {
- int pos = signature.IndexOf (",");
- if (pos == -1)
- return signature == reference.Name;
-
- string assembly_name = signature.Substring (0, pos);
-
- pos = signature.IndexOf ("=");
- if (pos == -1)
- throw new ArgumentException ();
-
- string public_key = signature.Substring (pos + 1).ToLower ();
-
- return assembly_name == reference.Name && public_key == ToPublicKeyString (reference.PublicKey);
- }
-
- static string ToPublicKeyString (byte [] public_key)
- {
- StringBuilder signature = new StringBuilder (public_key.Length);
- for (int i = 0; i < public_key.Length; i++)
- signature.Append (public_key [i].ToString ("x2"));
-
- return signature.ToString ();
- }
-
- static bool IsInternalsVisibleToAttribute (CustomAttribute attribute)
- {
- return attribute.Constructor.DeclaringType.FullName == "System.Runtime.CompilerServices.InternalsVisibleToAttribute";
- }
-
- bool IsVisibleFrom (TypeDefinition type, TypeReference reference)
- {
- if (reference == null)
- return true;
-
- if (reference is GenericParameter || reference.GetElementType () is GenericParameter)
- return true;
-
- TypeDefinition other = reference.Resolve ();
- if (other == null)
- return true;
-
- if (!AreInDifferentAssemblies (type, other))
- return true;
-
- if (IsPublic (other))
- return true;
-
- return false;
- }
-
- bool IsVisibleFrom (TypeDefinition type, MethodReference reference)
- {
- if (reference == null)
- return true;
-
- MethodDefinition meth = reference.Resolve ();
- if (meth == null)
- return true;
-
- TypeDefinition dec = (TypeDefinition) meth.DeclaringType;
- if (!IsVisibleFrom (type, dec))
- return false;
-
- if (meth.IsPublic)
- return true;
-
- if (type == dec || IsNestedIn (type, dec))
- return true;
-
- if (meth.IsFamily && InHierarchy (type, dec))
- return true;
-
- if (meth.IsFamilyOrAssembly && (!AreInDifferentAssemblies (type, dec) || InHierarchy (type, dec)))
- return true;
-
- if (meth.IsFamilyAndAssembly && (!AreInDifferentAssemblies (type, dec) && InHierarchy (type, dec)))
- return true;
-
- if (!AreInDifferentAssemblies (type, dec) && meth.IsAssembly)
- return true;
-
- return false;
- }
-
- bool IsVisibleFrom (TypeDefinition type, FieldReference reference)
- {
- if (reference == null)
- return true;
-
- FieldDefinition field = reference.Resolve ();
- if (field == null)
- return true;
-
- TypeDefinition dec = (TypeDefinition) field.DeclaringType;
- if (!IsVisibleFrom (type, dec))
- return false;
-
- if (field.IsPublic)
- return true;
-
- if (type == dec || IsNestedIn (type, dec))
- return true;
-
- if (field.IsFamily && InHierarchy (type, dec))
- return true;
-
- if (field.IsFamilyOrAssembly && (!AreInDifferentAssemblies (type, dec) || InHierarchy (type, dec)))
- return true;
-
- if (field.IsFamilyAndAssembly && (!AreInDifferentAssemblies (type, dec) && InHierarchy (type, dec)))
- return true;
-
- if (!AreInDifferentAssemblies (type, dec) && field.IsAssembly)
- return true;
-
- return false;
- }
-
- static bool IsNestedIn (TypeDefinition type, TypeDefinition other)
- {
- TypeDefinition declaring = type.DeclaringType;
-
- if (declaring == null)
- return false;
-
- if (declaring == other)
- return true;
-
- if (declaring.DeclaringType == null)
- return false;
-
- return IsNestedIn (declaring, other);
- }
-
- static bool InHierarchy (TypeDefinition type, TypeDefinition other)
- {
- if (type.BaseType == null)
- return false;
-
- TypeDefinition baseType = type.BaseType.Resolve ();
-
- if (baseType == other)
- return true;
-
- return InHierarchy (baseType, other);
- }
-
- static void Report (string pattern, params object [] parameters)
- {
- Console.WriteLine ("[check] " + pattern, parameters);
- }
-
- void ReportError (string pattern, params object [] parameters)
- {
- Report (pattern, parameters);
-
- if (throw_on_error)
- throw new VisibilityErrorException (string.Format (pattern, parameters));
- }
-
- void CheckFields (TypeDefinition type)
- {
- foreach (FieldDefinition field in type.Fields) {
- if (!IsVisibleFrom (type, field.FieldType)) {
- ReportError ("Field `{0}` of type `{1}` is not visible from `{2}`",
- field.Name, field.FieldType, type);
- }
- }
- }
-
- void CheckMethods (TypeDefinition type)
- {
- CheckMethods (type, type.Methods);
- }
-
- void CheckMethods (TypeDefinition type, ICollection methods)
- {
- foreach (MethodDefinition method in methods) {
- if (!IsVisibleFrom (type, method.ReturnType)) {
- ReportError ("Method return type `{0}` in method `{1}` is not visible",
- method.ReturnType, method);
- }
-
- foreach (ParameterDefinition parameter in method.Parameters) {
- if (!IsVisibleFrom (type, parameter.ParameterType)) {
- ReportError ("Parameter `{0}` of type `{1}` in method `{2}` is not visible.",
- parameter.Index, parameter.ParameterType, method);
- }
- }
-
- if (method.HasBody)
- CheckBody (method);
- }
- }
-
- void CheckBody (MethodDefinition method)
- {
- TypeDefinition type = (TypeDefinition) method.DeclaringType;
-
- foreach (VariableDefinition variable in method.Body.Variables) {
- if (!IsVisibleFrom ((TypeDefinition) method.DeclaringType, variable.VariableType)) {
- ReportError ("Variable `{0}` of type `{1}` from method `{2}` is not visible",
- variable.Index, variable.VariableType, method);
- }
- }
-
- foreach (Instruction instr in method.Body.Instructions) {
- switch (instr.OpCode.OperandType) {
- case OperandType.InlineType:
- case OperandType.InlineMethod:
- case OperandType.InlineField:
- case OperandType.InlineTok:
- bool error = false;
- TypeReference type_ref = instr.Operand as TypeReference;
- if (type_ref != null)
- error = !IsVisibleFrom (type, type_ref);
-
- MethodReference meth_ref = instr.Operand as MethodReference;
- if (meth_ref != null)
- error = !IsVisibleFrom (type, meth_ref);
-
- FieldReference field_ref = instr.Operand as FieldReference;
- if (field_ref != null)
- error = !IsVisibleFrom (type, field_ref);
-
- if (error) {
- ReportError ("Operand `{0}` of type {1} at offset 0x{2} in method `{3}` is not visible",
- instr.Operand, instr.OpCode.OperandType, instr.Offset.ToString ("x4"), method);
- }
-
- break;
- default:
- continue;
- }
- }
- }
-
- class VisibilityErrorException : Exception {
-
- public VisibilityErrorException (string message)
- : base (message)
- {
- }
- }
- }
-}
diff --git a/src/tuner/Mono.Tuner/CustomizeActions.cs b/src/tuner/Mono.Tuner/CustomizeActions.cs
deleted file mode 100644
index 1bb6d6fb0..000000000
--- a/src/tuner/Mono.Tuner/CustomizeActions.cs
+++ /dev/null
@@ -1,93 +0,0 @@
-using System;
-using System.Collections;
-using System.Collections.Generic;
-using System.IO;
-using System.Linq;
-
-using Mono.Linker;
-using Mono.Linker.Steps;
-
-using Mono.Cecil;
-using Mono.Cecil.Cil;
-
-namespace Mono.Tuner {
-
- public class CustomizeActions : BaseStep {
-
- readonly bool link_sdk_only;
- readonly HashSet<string> skipped_assemblies;
-
- public CustomizeActions (bool link_sdk_only, IEnumerable<string> skipped_assemblies)
- {
- this.link_sdk_only = link_sdk_only;
- this.skipped_assemblies = new HashSet<string> (skipped_assemblies);
- }
-
- protected override void ProcessAssembly (AssemblyDefinition assembly)
- {
- if (!IsSkipped (assembly) && IsLinked (assembly)) {
- if (!Annotations.HasAction (assembly)) // stray assembly not picked up when resolving references
- Annotations.SetAction (assembly, AssemblyAction.Link);
- return;
- }
- ProcessUserAssembly (assembly);
- }
-
- protected virtual bool IsPreservedAttribute (CustomAttribute attribute)
- {
- // [assembly: Preserve (type)] does not preserve all the code in the assembly, in fact it might
- // not preserve anything in _this_ assembly, but something in a separate assembly (reference)
- if (attribute.HasConstructorArguments)
- return false;
- return (attribute.AttributeType.Name == "PreserveAttribute");
- }
-
- protected virtual bool IsLinkerSafeAttribute (CustomAttribute attribute)
- {
- return (attribute.AttributeType.Name == "LinkerSafeAttribute");
- }
-
- const ModuleAttributes Supported = ModuleAttributes.ILOnly | ModuleAttributes.Required32Bit |
- ModuleAttributes.Preferred32Bit | ModuleAttributes.StrongNameSigned;
-
- protected virtual bool IsSkipped (AssemblyDefinition assembly)
- {
- // Cecil can't save back mixed-mode assemblies - so we can't link them
- if ((assembly.MainModule.Attributes & ~Supported) != 0)
- return true;
-
- if (assembly.HasCustomAttributes) {
- foreach (var ca in assembly.CustomAttributes) {
- if (IsPreservedAttribute (ca))
- return true;
- }
- }
- return skipped_assemblies.Contains (assembly.Name.Name);
- }
-
- protected virtual bool IsLinked (AssemblyDefinition assembly)
- {
- // LinkAll
- if (!link_sdk_only)
- return true;
- // Link SDK : applies to BCL/SDK and product assembly (e.g. monotouch.dll)
- if (Profile.IsSdkAssembly (assembly))
- return true;
- if (Profile.IsProductAssembly (assembly))
- return true;
- // the assembly can be marked with [LinkAssembly]
- if (assembly.HasCustomAttributes) {
- foreach (var ca in assembly.CustomAttributes) {
- if (IsLinkerSafeAttribute (ca))
- return true;
- }
- }
- return false;
- }
-
- protected void ProcessUserAssembly (AssemblyDefinition assembly)
- {
- ResolveFromAssemblyStep.ProcessLibrary (Context, assembly);
- }
- }
-}
diff --git a/src/tuner/Mono.Tuner/Dispatcher.cs b/src/tuner/Mono.Tuner/Dispatcher.cs
deleted file mode 100644
index be1674044..000000000
--- a/src/tuner/Mono.Tuner/Dispatcher.cs
+++ /dev/null
@@ -1,310 +0,0 @@
-using System;
-using System.Collections;
-using System.Collections.Generic;
-
-using Mono.Linker;
-using Mono.Linker.Steps;
-
-using Mono.Cecil;
-
-namespace Mono.Tuner {
-
- [Flags]
- public enum SubStepTargets {
- None = 0,
-
- Assembly = 1,
- Type = 2,
- Field = 4,
- Method = 8,
- Property = 16,
- Event = 32,
- }
-
- public interface ISubStep {
-
- SubStepTargets Targets { get; }
-
- void Initialize (LinkContext context);
- bool IsActiveFor (AssemblyDefinition assembly);
-
- void ProcessAssembly (AssemblyDefinition assembly);
- void ProcessType (TypeDefinition type);
- void ProcessField (FieldDefinition field);
- void ProcessMethod (MethodDefinition method);
- void ProcessProperty (PropertyDefinition property);
- void ProcessEvent (EventDefinition @event);
- }
-
- public abstract class BaseSubStep : ISubStep {
-
- protected LinkContext context;
-
- public AnnotationStore Annotations {
- get { return context.Annotations; }
- }
-
- public abstract SubStepTargets Targets { get; }
-
- public virtual void Initialize (LinkContext context)
- {
- this.context = context;
- }
-
- public virtual bool IsActiveFor (AssemblyDefinition assembly)
- {
- return true;
- }
-
- public virtual void ProcessAssembly (AssemblyDefinition assembly)
- {
- }
-
- public virtual void ProcessType (TypeDefinition type)
- {
- }
-
- public virtual void ProcessField (FieldDefinition field)
- {
- }
-
- public virtual void ProcessMethod (MethodDefinition method)
- {
- }
-
- public virtual void ProcessProperty (PropertyDefinition property)
- {
- }
-
- public virtual void ProcessEvent (EventDefinition @event)
- {
- }
- }
-
- public class SubStepDispatcher : IStep, IEnumerable<ISubStep> {
-
- List<ISubStep> substeps = new List<ISubStep> ();
-
- List<ISubStep> on_assemblies;
- List<ISubStep> on_types;
- List<ISubStep> on_fields;
- List<ISubStep> on_methods;
- List<ISubStep> on_properties;
- List<ISubStep> on_events;
-
- Tracer tracer;
-
- public void Add (ISubStep substep)
- {
- substeps.Add (substep);
- }
-
- public void Process (LinkContext context)
- {
- tracer = context.Tracer;
-
- InitializeSubSteps (context);
-
- BrowseAssemblies (context.GetAssemblies ());
- }
-
- void Push (ISubStep subStep)
- {
- if (tracer != null)
- tracer.Push (subStep);
- }
-
- void Pop ()
- {
- if (tracer != null)
- tracer.Pop ();
- }
-
- static bool HasSubSteps (List<ISubStep> substeps)
- {
- return substeps != null && substeps.Count > 0;
- }
-
- void BrowseAssemblies (IEnumerable<AssemblyDefinition> assemblies)
- {
- foreach (var assembly in assemblies) {
- CategorizeSubSteps (assembly);
-
- if (HasSubSteps (on_assemblies))
- DispatchAssembly (assembly);
-
- if (!ShouldDispatchTypes ())
- continue;
-
- BrowseTypes (assembly.MainModule.Types);
- }
- }
-
- bool ShouldDispatchTypes ()
- {
- return HasSubSteps (on_types)
- || HasSubSteps (on_fields)
- || HasSubSteps (on_methods)
- || HasSubSteps (on_properties)
- || HasSubSteps (on_events);
- }
-
- void BrowseTypes (ICollection types)
- {
- foreach (TypeDefinition type in types) {
- DispatchType (type);
-
- if (type.HasFields && HasSubSteps (on_fields))
- BrowseFields (type.Fields);
-
- if (type.HasMethods && HasSubSteps (on_methods))
- BrowseMethods (type.Methods);
-
- if (type.HasProperties && HasSubSteps (on_properties))
- BrowseProperties (type.Properties);
-
- if (type.HasEvents && HasSubSteps (on_events))
- BrowseEvents (type.Events);
-
- if (type.HasNestedTypes)
- BrowseTypes (type.NestedTypes);
- }
- }
-
- void BrowseFields (ICollection fields)
- {
- foreach (FieldDefinition field in fields)
- DispatchField (field);
- }
-
- void BrowseMethods (ICollection methods)
- {
- foreach (MethodDefinition method in methods)
- DispatchMethod (method);
- }
-
- void BrowseProperties (ICollection properties)
- {
- foreach (PropertyDefinition property in properties)
- DispatchProperty (property);
- }
-
- void BrowseEvents (ICollection events)
- {
- foreach (EventDefinition @event in events)
- DispatchEvent (@event);
- }
-
- void DispatchAssembly (AssemblyDefinition assembly)
- {
- foreach (var substep in on_assemblies) {
- Push (substep);
- substep.ProcessAssembly (assembly);
- Pop ();
- }
- }
-
- void DispatchType (TypeDefinition type)
- {
- foreach (var substep in on_types) {
- Push (substep);
- substep.ProcessType (type);
- Pop ();
- }
- }
-
- void DispatchField (FieldDefinition field)
- {
- foreach (var substep in on_fields) {
- Push (substep);
- substep.ProcessField (field);
- Pop ();
- }
- }
-
- void DispatchMethod (MethodDefinition method)
- {
- foreach (var substep in on_methods) {
- Push (substep);
- substep.ProcessMethod (method);
- Pop ();
- }
- }
-
- void DispatchProperty (PropertyDefinition property)
- {
- foreach (var substep in on_properties) {
- Push (substep);
- substep.ProcessProperty (property);
- Pop ();
- }
- }
-
- void DispatchEvent (EventDefinition @event)
- {
- foreach (var substep in on_events) {
- Push (substep);
- substep.ProcessEvent (@event);
- Pop ();
- }
- }
-
- void InitializeSubSteps (LinkContext context)
- {
- foreach (var substep in substeps)
- substep.Initialize (context);
- }
-
- void CategorizeSubSteps (AssemblyDefinition assembly)
- {
- on_assemblies = null;
- on_types = null;
- on_fields = null;
- on_methods = null;
- on_properties = null;
- on_events = null;
-
- foreach (var substep in substeps)
- CategorizeSubStep (substep, assembly);
- }
-
- void CategorizeSubStep (ISubStep substep, AssemblyDefinition assembly)
- {
- if (!substep.IsActiveFor (assembly))
- return;
-
- CategorizeTarget (substep, SubStepTargets.Assembly, ref on_assemblies);
- CategorizeTarget (substep, SubStepTargets.Type, ref on_types);
- CategorizeTarget (substep, SubStepTargets.Field, ref on_fields);
- CategorizeTarget (substep, SubStepTargets.Method, ref on_methods);
- CategorizeTarget (substep, SubStepTargets.Property, ref on_properties);
- CategorizeTarget (substep, SubStepTargets.Event, ref on_events);
- }
-
- static void CategorizeTarget (ISubStep substep, SubStepTargets target, ref List<ISubStep> list)
- {
- if (!Targets (substep, target))
- return;
-
- if (list == null)
- list = new List<ISubStep> ();
-
- list.Add (substep);
- }
-
- static bool Targets (ISubStep substep, SubStepTargets target)
- {
- return (substep.Targets & target) == target;
- }
-
- IEnumerator IEnumerable.GetEnumerator ()
- {
- return GetEnumerator ();
- }
-
- public IEnumerator<ISubStep> GetEnumerator ()
- {
- return substeps.GetEnumerator ();
- }
- }
-}
diff --git a/src/tuner/Mono.Tuner/Extensions.cs b/src/tuner/Mono.Tuner/Extensions.cs
deleted file mode 100644
index 3e3b31213..000000000
--- a/src/tuner/Mono.Tuner/Extensions.cs
+++ /dev/null
@@ -1,36 +0,0 @@
-using System;
-using System.Collections.Generic;
-
-using Mono.Cecil;
-
-using Mono.Linker;
-
-namespace Mono.Tuner {
-
- public static partial class Extensions {
-
- public static bool TryGetLinkedAssembly (this LinkContext context, string name, out AssemblyDefinition assembly)
- {
- assembly = GetAssembly (context, name);
- if (assembly == null)
- return false;
-
- return context.Annotations.GetAction (assembly) == AssemblyAction.Link;
- }
-
- public static AssemblyDefinition GetAssembly (this LinkContext context, string assembly_name)
- {
- foreach (var assembly in context.GetAssemblies ())
- if (assembly.Name.Name == assembly_name)
- return assembly;
-
- return null;
- }
-
- // note: direct check, no inheritance
- public static bool Is (this TypeReference type, string @namespace, string name)
- {
- return ((type != null) && (type.Name == name) && (type.Namespace == @namespace));
- }
- }
-}
diff --git a/src/tuner/Mono.Tuner/FilterAttributes.cs b/src/tuner/Mono.Tuner/FilterAttributes.cs
deleted file mode 100644
index 19a334a5c..000000000
--- a/src/tuner/Mono.Tuner/FilterAttributes.cs
+++ /dev/null
@@ -1,157 +0,0 @@
-//
-// FilterAttributes.cs
-//
-// Author:
-// Jb Evain (jbevain@novell.com)
-//
-// (C) 2009 Novell, Inc.
-//
-// 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.
-//
-
-using System;
-using System.Collections;
-
-using Mono.Linker;
-using Mono.Linker.Steps;
-
-using Mono.Cecil;
-
-namespace Mono.Tuner {
-
- public class FilterAttributes : BaseStep {
-
- static Hashtable attributes = new Hashtable ();
-
- static FilterAttributes ()
- {
- FilterAttribute ("System.Runtime.InteropServices.ComVisibleAttribute");
- }
-
- static void FilterAttribute (string fullname)
- {
- attributes.Add (fullname, null);
- }
-
- protected override void ProcessAssembly (AssemblyDefinition assembly)
- {
- if (Annotations.GetAction (assembly) != AssemblyAction.Link)
- return;
-
- Filter (assembly);
-
- foreach (ModuleDefinition module in assembly.Modules)
- ProcessModule (module);
- }
-
- static void ProcessModule (ModuleDefinition module)
- {
- Filter (module);
-
- foreach (TypeDefinition type in module.Types)
- ProcessType (type);
- }
-
- static void ProcessType (TypeDefinition type)
- {
- if (type.HasFields)
- ProcessFields (type.Fields);
-
- if (type.HasMethods)
- ProcessMethods (type.Methods);
-
- if (type.HasEvents)
- ProcessEvents (type.Events);
-
- if (type.HasProperties)
- ProcessProperties (type.Properties);
-
- ProcessGenericParameters (type);
- }
-
- static void ProcessFields (ICollection fields)
- {
- foreach (FieldDefinition field in fields)
- Filter (field);
- }
-
- static void ProcessMethods (ICollection methods)
- {
- foreach (MethodDefinition method in methods)
- ProcessMethod (method);
- }
-
- static void ProcessMethod (MethodDefinition method)
- {
- ProcessGenericParameters (method);
-
- Filter (method.MethodReturnType);
-
- if (method.HasParameters)
- ProcessParameters (method.Parameters);
- }
-
- static void ProcessParameters (ICollection parameters)
- {
- foreach (ParameterDefinition parameter in parameters)
- Filter (parameter);
- }
-
- static void ProcessGenericParameters (IGenericParameterProvider provider)
- {
- if (!provider.HasGenericParameters)
- return;
-
- foreach (GenericParameter parameter in provider.GenericParameters)
- Filter (parameter);
- }
-
- static void ProcessEvents (ICollection events)
- {
- foreach (EventDefinition @event in events)
- Filter (@event);
- }
-
- static void ProcessProperties (ICollection properties)
- {
- foreach (PropertyDefinition property in properties)
- Filter (property);
- }
-
- static void Filter (ICustomAttributeProvider provider)
- {
- if (!provider.HasCustomAttributes)
- return;
-
- for (int i = 0; i < provider.CustomAttributes.Count; i++) {
- CustomAttribute attribute = provider.CustomAttributes [i];
- if (!IsFilteredAttribute (attribute))
- continue;
-
- provider.CustomAttributes.RemoveAt (i--);
- }
- }
-
- static bool IsFilteredAttribute (CustomAttribute attribute)
- {
- return attributes.Contains (attribute.Constructor.DeclaringType.FullName);
- }
- }
-}
diff --git a/src/tuner/Mono.Tuner/FixModuleFlags.cs b/src/tuner/Mono.Tuner/FixModuleFlags.cs
deleted file mode 100644
index 2bb01ab9b..000000000
--- a/src/tuner/Mono.Tuner/FixModuleFlags.cs
+++ /dev/null
@@ -1,20 +0,0 @@
-using System;
-
-using Mono.Linker;
-using Mono.Linker.Steps;
-
-using Mono.Cecil;
-
-namespace Mono.Tuner {
-
- public class FixModuleFlags : BaseStep {
-
- protected override void ProcessAssembly (AssemblyDefinition assembly)
- {
- if (Annotations.GetAction (assembly) != AssemblyAction.Link)
- return;
-
- assembly.MainModule.Attributes = ModuleAttributes.ILOnly;
- }
- }
-}
diff --git a/src/tuner/Mono.Tuner/InjectSecurityAttributes.cs b/src/tuner/Mono.Tuner/InjectSecurityAttributes.cs
deleted file mode 100644
index 9489876ae..000000000
--- a/src/tuner/Mono.Tuner/InjectSecurityAttributes.cs
+++ /dev/null
@@ -1,500 +0,0 @@
-//
-// InjectSecurityAttributes.cs
-//
-// Author:
-// Jb Evain (jbevain@novell.com)
-//
-// (C) 2009 Novell, Inc.
-//
-// 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.
-//
-
-using System;
-using System.Collections;
-using System.IO;
-using System.Linq;
-using System.Text;
-
-using Mono.Linker;
-using Mono.Linker.Steps;
-
-using Mono.Cecil;
-using Mono.Cecil.Cil;
-
-namespace Mono.Tuner {
-
- public class InjectSecurityAttributes : BaseStep {
-
- enum TargetKind {
- Type,
- Method,
- }
-
- protected enum AttributeType {
- Critical,
- SafeCritical,
- }
-
- const string _safe_critical = "System.Security.SecuritySafeCriticalAttribute";
- const string _critical = "System.Security.SecurityCriticalAttribute";
- const string _system_void = "System.Void";
-
- const string sec_attr_folder = "secattrs";
-
- protected AssemblyDefinition _assembly;
-
- MethodDefinition _safe_critical_ctor;
- MethodDefinition _critical_ctor;
- TypeDefinition _void_type;
-
- string data_folder;
-
- protected override bool ConditionToProcess ()
- {
- if (!Context.HasParameter (sec_attr_folder)) {
- Console.Error.WriteLine ("Warning: no secattrs folder specified.");
- return false;
- }
-
- data_folder = Context.GetParameter (sec_attr_folder);
- return true;
- }
-
- protected override void ProcessAssembly (AssemblyDefinition assembly)
- {
- if (Annotations.GetAction (assembly) != AssemblyAction.Link)
- return;
-
- string secattr_file = Path.Combine (
- data_folder,
- assembly.Name.Name + ".secattr");
-
- if (!File.Exists (secattr_file)) {
- Console.Error.WriteLine ("Warning: file '{0}' not found, skipping.", secattr_file);
- return;
- }
-
- _assembly = assembly;
-
- // remove existing [SecurityCritical] and [SecuritySafeCritical]
- RemoveSecurityAttributes ();
-
- // add [SecurityCritical] and [SecuritySafeCritical] from the data file
- ProcessSecurityAttributeFile (secattr_file);
- }
-
- protected void RemoveSecurityAttributes ()
- {
- foreach (TypeDefinition type in _assembly.MainModule.Types) {
- if (RemoveSecurityAttributes (type))
- type.HasSecurity = false;
-
- if (type.HasMethods) {
- foreach (MethodDefinition method in type.Methods) {
- if (RemoveSecurityAttributes (method))
- method.HasSecurity = false;
- }
- }
- }
- }
-
- static bool RemoveSecurityDeclarations (ISecurityDeclarationProvider provider)
- {
- // also remove already existing CAS security declarations
-
- if (provider == null)
- return false;
-
- if (!provider.HasSecurityDeclarations)
- return false;
-
- provider.SecurityDeclarations.Clear ();
- return true;
- }
-
- static bool RemoveSecurityAttributes (ICustomAttributeProvider provider)
- {
- bool result = RemoveSecurityDeclarations (provider as ISecurityDeclarationProvider);
-
- if (!provider.HasCustomAttributes)
- return result;
-
- var attributes = provider.CustomAttributes;
- for (int i = 0; i < attributes.Count; i++) {
- CustomAttribute attribute = attributes [i];
- switch (attribute.Constructor.DeclaringType.FullName) {
- case _safe_critical:
- case _critical:
- attributes.RemoveAt (i--);
- break;
- }
- }
- return result;
- }
-
- void ProcessSecurityAttributeFile (string file)
- {
- using (StreamReader reader = File.OpenText (file)) {
- string line;
- while ((line = reader.ReadLine ()) != null)
- ProcessLine (line);
- }
- }
-
- void ProcessLine (string line)
- {
- if (line == null || line.Length < 6 || line [0] == '#')
- return;
-
- int sep = line.IndexOf (": ");
- if (sep == -1)
- return;
-
- string marker = line.Substring (0, sep);
- string target = line.Substring (sep + 2);
-
- ProcessSecurityAttributeEntry (
- DecomposeAttributeType (marker),
- DecomposeTargetKind (marker),
- target);
- }
-
- static AttributeType DecomposeAttributeType (string marker)
- {
- if (marker.StartsWith ("SC"))
- return AttributeType.Critical;
- else if (marker.StartsWith ("SSC"))
- return AttributeType.SafeCritical;
- else
- throw new ArgumentException ();
- }
-
- static TargetKind DecomposeTargetKind (string marker)
- {
- switch (marker [marker.Length - 1]) {
- case 'T':
- return TargetKind.Type;
- case 'M':
- return TargetKind.Method;
- default:
- throw new ArgumentException ();
- }
- }
-
- public static bool NeedsDefaultConstructor (TypeDefinition type)
- {
- if (type.IsInterface)
- return false;
-
- TypeReference base_type = type.BaseType;
- if ((base_type == null) || (base_type.Namespace != "System"))
- return true;
-
- return ((base_type.Name != "Delegate") && (base_type.Name != "MulticastDelegate"));
- }
-
- void ProcessSecurityAttributeEntry (AttributeType type, TargetKind kind, string target)
- {
- ICustomAttributeProvider provider = GetTarget (kind, target);
- if (provider == null) {
- Console.Error.WriteLine ("Warning: entry '{0}' could not be found", target);
- return;
- }
-
- // we need to be smarter when applying the attributes (mostly SC) to types
- if (kind == TargetKind.Type) {
- TypeDefinition td = (provider as TypeDefinition);
- // ensure [SecurityCritical] types (well most) have a default constructor
- if ((type == AttributeType.Critical) && NeedsDefaultConstructor (td)) {
- if (GetDefaultConstructor (td) == null) {
- // Console.Error.WriteLine ("Info: adding default ctor for '{0}'", td);
- td.Methods.Add (CreateDefaultConstructor ());
- }
- }
-
- // it's easier for some tools (e.g. less false positives in fxcop)
- // and also quicker for the runtime (one less lookup) if all methods gets decorated
- foreach (MethodDefinition method in td.Methods) {
- bool skip = false;
-
- AttributeType mtype = type;
- // there are cases where an SC cannot be applied to some methods
- switch (method.Name) {
- // e.g. everything we override from System.Object (which is transparent)
- case "Equals":
- skip = method.Parameters.Count == 1 && method.Parameters [0].ParameterType.FullName == "System.Object";
- break;
- case "Finalize":
- case "GetHashCode":
- case "ToString":
- skip = !method.HasParameters;
- break;
- // e.g. some transparent interfaces, like IDisposable (implicit or explicit)
- // downgrade some SC into SSC to respect the override/inheritance rules
- case "System.IDisposable.Dispose":
- case "Dispose":
- skip = !method.HasParameters;
- break;
- }
-
- if (skip)
- continue;
-
- switch (mtype) {
- case AttributeType.Critical:
- AddCriticalAttribute (method);
- break;
- case AttributeType.SafeCritical:
- AddSafeCriticalAttribute (method);
- break;
- }
- }
- }
-
- switch (type) {
- case AttributeType.Critical:
- AddCriticalAttribute (provider);
- break;
- case AttributeType.SafeCritical:
- AddSafeCriticalAttribute (provider);
- break;
- }
- }
-
- protected void AddCriticalAttribute (ICustomAttributeProvider provider)
- {
- // a [SecurityCritical] replaces a [SecuritySafeCritical]
- if (HasSecurityAttribute (provider, AttributeType.SafeCritical))
- RemoveSecurityAttributes (provider);
-
- AddSecurityAttribute (provider, AttributeType.Critical);
- }
-
- void AddSafeCriticalAttribute (ICustomAttributeProvider provider)
- {
- // a [SecuritySafeCritical] is ignored if a [SecurityCritical] is present
- if (HasSecurityAttribute (provider, AttributeType.Critical))
- return;
-
- AddSecurityAttribute (provider, AttributeType.SafeCritical);
- }
-
- void AddSecurityAttribute (ICustomAttributeProvider provider, AttributeType type)
- {
- if (HasSecurityAttribute (provider, type))
- return;
-
- var attributes = provider.CustomAttributes;
- switch (type) {
- case AttributeType.Critical:
- attributes.Add (CreateCriticalAttribute ());
- break;
- case AttributeType.SafeCritical:
- attributes.Add (CreateSafeCriticalAttribute ());
- break;
- }
- }
-
- protected static bool HasSecurityAttribute (ICustomAttributeProvider provider, AttributeType type)
- {
- if (!provider.HasCustomAttributes)
- return false;
-
- foreach (CustomAttribute attribute in provider.CustomAttributes) {
- switch (attribute.Constructor.DeclaringType.Name) {
- case _critical:
- if (type == AttributeType.Critical)
- return true;
-
- break;
- case _safe_critical:
- if (type == AttributeType.SafeCritical)
- return true;
-
- break;
- }
- }
-
- return false;
- }
-
- ICustomAttributeProvider GetTarget (TargetKind kind, string target)
- {
- switch (kind) {
- case TargetKind.Type:
- return GetType (target);
- case TargetKind.Method:
- return GetMethod (target);
- default:
- throw new ArgumentException ();
- }
- }
-
- TypeDefinition GetType (string fullname)
- {
- return _assembly.MainModule.GetType (fullname);
- }
-
- MethodDefinition GetMethod (string signature)
- {
- int pos = signature.IndexOf (" ");
- if (pos == -1)
- throw new ArgumentException ();
-
- string tmp = signature.Substring (pos + 1);
-
- pos = tmp.IndexOf ("::");
- if (pos == -1)
- throw new ArgumentException ();
-
- string type_name = tmp.Substring (0, pos);
-
- int parpos = tmp.IndexOf ("(");
- if (parpos == -1)
- throw new ArgumentException ();
-
- string method_name = tmp.Substring (pos + 2, parpos - pos - 2);
-
- TypeDefinition type = GetType (type_name);
- if (type == null)
- return null;
-
- return GetMethod (type.Methods, signature);
- }
-
- static MethodDefinition GetMethod (IEnumerable methods, string signature)
- {
- foreach (MethodDefinition method in methods)
- if (GetFullName (method) == signature)
- return method;
-
- return null;
- }
-
- static string GetFullName (MethodReference method)
- {
- var sentinel = method.Parameters.FirstOrDefault (p => p.ParameterType.IsSentinel);
- var sentinel_pos = -1;
- if (sentinel != null)
- sentinel_pos = method.Parameters.IndexOf (sentinel);
-
- StringBuilder sb = new StringBuilder ();
- sb.Append (method.ReturnType.FullName);
- sb.Append (" ");
- sb.Append (method.DeclaringType.FullName);
- sb.Append ("::");
- sb.Append (method.Name);
- if (method.HasGenericParameters) {
- sb.Append ("<");
- for (int i = 0; i < method.GenericParameters.Count; i++ ) {
- if (i > 0)
- sb.Append (",");
- sb.Append (method.GenericParameters [i].Name);
- }
- sb.Append (">");
- }
- sb.Append ("(");
- if (method.HasParameters) {
- for (int i = 0; i < method.Parameters.Count; i++) {
- if (i > 0)
- sb.Append (",");
-
- if (i == sentinel_pos)
- sb.Append ("...,");
-
- sb.Append (method.Parameters [i].ParameterType.FullName);
- }
- }
- sb.Append (")");
- return sb.ToString ();
- }
-
- static MethodDefinition GetDefaultConstructor (TypeDefinition type)
- {
- foreach (MethodDefinition ctor in type.Methods.Where (m => m.IsConstructor))
- if (!ctor.IsStatic && !ctor.HasParameters)
- return ctor;
-
- return null;
- }
-
- MethodDefinition GetSafeCriticalCtor ()
- {
- if (_safe_critical_ctor != null)
- return _safe_critical_ctor;
-
- TypeDefinition safe_critical_type = Context.GetType (_safe_critical);
- if (safe_critical_type == null)
- throw new InvalidOperationException (String.Format ("{0} type not found", _safe_critical));
-
- _safe_critical_ctor = GetDefaultConstructor (safe_critical_type);
- return _safe_critical_ctor;
- }
-
- MethodDefinition GetCriticalCtor ()
- {
- if (_critical_ctor != null)
- return _critical_ctor;
-
- TypeDefinition critical_type = Context.GetType (_critical);
- if (critical_type == null)
- throw new InvalidOperationException (String.Format ("{0} type not found", _critical));
-
- _critical_ctor = GetDefaultConstructor (critical_type);
- return _critical_ctor;
- }
-
- TypeDefinition GetSystemVoid ()
- {
- if (_void_type != null)
- return _void_type;
-
- _void_type = Context.GetType (_system_void);
- if (_void_type == null)
- throw new InvalidOperationException (String.Format ("{0} type not found", _system_void));
-
- return _void_type;
- }
-
- MethodReference Import (MethodDefinition method)
- {
- return _assembly.MainModule.Import (method);
- }
-
- CustomAttribute CreateSafeCriticalAttribute ()
- {
- return new CustomAttribute (Import (GetSafeCriticalCtor ()));
- }
-
- CustomAttribute CreateCriticalAttribute ()
- {
- return new CustomAttribute (Import (GetCriticalCtor ()));
- }
-
- MethodDefinition CreateDefaultConstructor ()
- {
- MethodDefinition method = new MethodDefinition (".ctor",
- MethodAttributes.HideBySig | MethodAttributes.SpecialName | MethodAttributes.RTSpecialName,
- GetSystemVoid ());
- method.Body.Instructions.Add (Instruction.Create (OpCodes.Ret));
- return method;
- }
- }
-}
diff --git a/src/tuner/Mono.Tuner/MarkNSObjectsBase.cs b/src/tuner/Mono.Tuner/MarkNSObjectsBase.cs
deleted file mode 100644
index 9d65be1de..000000000
--- a/src/tuner/Mono.Tuner/MarkNSObjectsBase.cs
+++ /dev/null
@@ -1,149 +0,0 @@
-//
-// MarkNSObjectsBase.cs
-//
-// Authors:
-// Jb Evain (jbevain@novell.com)
-// Sebastien Pouliot <sebastien@xamarin.com>
-//
-// (C) 2009 Novell, Inc.
-// Copyright (C) 2011 Xamarin, Inc.
-//
-// 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.
-//
-
-using System;
-using System.Collections;
-using System.Collections.Generic;
-using System.Linq;
-
-using Mono.Linker;
-using Mono.Linker.Steps;
-
-using Mono.Tuner;
-
-using Mono.Cecil;
-
-namespace Mono.Tuner {
-
- public abstract class MarkNSObjectsBase : BaseSubStep {
-
- protected abstract string ExportAttribute { get; }
-
- public override SubStepTargets Targets {
- get { return SubStepTargets.Type; }
- }
-
- public override void ProcessType (TypeDefinition type)
- {
- if (!IsProductType (type)) {
- Annotations.Mark (type);
- Annotations.SetPreserve (type, TypePreserve.All);
- } else
- PreserveProductType (type);
- }
-
- void PreserveProductType (TypeDefinition type)
- {
- PreserveIntPtrConstructor (type);
- PreserveExportedMethods (type);
- }
-
- void PreserveExportedMethods (TypeDefinition type)
- {
- if (!type.HasMethods)
- return;
-
- foreach (var method in type.GetMethods ()) {
- if (!IsExportedMethod (method))
- continue;
-
- if (!IsOverridenInUserCode (method))
- continue;
-
- PreserveMethod (type, method);
- }
- }
-
- bool IsOverridenInUserCode (MethodDefinition method)
- {
- if (!method.IsVirtual)
- return false;
-
- var overrides = Annotations.GetOverrides (method);
- if (overrides == null || overrides.Count == 0)
- return false;
-
- foreach (MethodDefinition @override in overrides)
- if (!IsProductMethod (@override))
- return true;
-
- return false;
- }
-
- bool IsExportedMethod (MethodDefinition method)
- {
- return HasExportAttribute (method);
- }
-
- bool HasExportAttribute (ICustomAttributeProvider provider)
- {
- if (!provider.HasCustomAttributes)
- return false;
-
- foreach (CustomAttribute attribute in provider.CustomAttributes)
- if (attribute.AttributeType.FullName == ExportAttribute)
- return true;
-
- return false;
- }
-
- void PreserveIntPtrConstructor (TypeDefinition type)
- {
- if (!type.HasMethods)
- return;
-
- foreach (MethodDefinition constructor in type.GetConstructors ()) {
- if (!constructor.HasParameters)
- continue;
-
- if (constructor.Parameters.Count != 1 || constructor.Parameters [0].ParameterType.FullName != "System.IntPtr")
- continue;
-
- PreserveMethod (type, constructor);
- break; // only one .ctor can match this
- }
- }
-
- void PreserveMethod (TypeDefinition type, MethodDefinition method)
- {
- Annotations.AddPreservedMethod (type, method);
- }
-
- static bool IsProductMethod (MethodDefinition method)
- {
- return IsProductType (method.DeclaringType);
- }
-
- static bool IsProductType (TypeDefinition type)
- {
- return Profile.IsProductAssembly (type.Module.Assembly);
- }
- }
-}
diff --git a/src/tuner/Mono.Tuner/MoonlightA11yApiMarker.cs b/src/tuner/Mono.Tuner/MoonlightA11yApiMarker.cs
deleted file mode 100644
index fcd61afbd..000000000
--- a/src/tuner/Mono.Tuner/MoonlightA11yApiMarker.cs
+++ /dev/null
@@ -1,88 +0,0 @@
-//
-// MoonlightA11yApiMarker.cs
-//
-// Author:
-// Andrés G. Aragoneses (aaragoneses@novell.com)
-//
-// (C) 2009 Novell, Inc.
-//
-// 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.
-//
-
-using System;
-using System.Collections;
-using System.Xml;
-
-using Mono.Linker;
-using Mono.Linker.Steps;
-
-using Mono.Cecil;
-
-namespace Mono.Tuner {
-
- public class MoonlightA11yApiMarker : MarkStep {
-
- bool IsA11yAssembly (AssemblyDefinition assembly)
- {
- return assembly.ToString ().Contains ("DummyEntry") || assembly.ToString ().Contains ("MoonAtkBridge");
- }
-
- protected override void InitializeAssembly (AssemblyDefinition assembly)
- {
- if (IsA11yAssembly (assembly))
- base.InitializeAssembly (assembly);
- }
-
- protected override void EnqueueMethod (MethodDefinition method)
- {
- if (IsA11yAssembly (method.DeclaringType.Module.Assembly))
- base.EnqueueMethod (method);
- else
- Annotations.Mark (method);
- }
-
- protected override bool IgnoreScope (IMetadataScope scope)
- {
- return false;
- }
-
- protected override TypeDefinition MarkType (TypeReference reference)
- {
- if (reference == null)
- throw new ArgumentNullException ("reference");
-
- reference = GetOriginalType (reference);
-
- if (reference is GenericParameter)
- return null;
-
- TypeDefinition type = reference.Resolve ();
-
- if (type == null)
- throw new ResolutionException (reference);
-
- if (CheckProcessed (type))
- return type;
-
- Annotations.Mark (type);
- return type;
- }
- }
-}
diff --git a/src/tuner/Mono.Tuner/MoonlightA11yAssemblyStep.cs b/src/tuner/Mono.Tuner/MoonlightA11yAssemblyStep.cs
deleted file mode 100644
index 63a82b28d..000000000
--- a/src/tuner/Mono.Tuner/MoonlightA11yAssemblyStep.cs
+++ /dev/null
@@ -1,54 +0,0 @@
-//
-// MoonlightA11yAssemblyStep.cs
-//
-// Author:
-// Andrés G. Aragoneses (aaragoneses@novell.com)
-//
-// (C) 2009 Novell, Inc.
-//
-// 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.
-//
-
-using System;
-using System.Collections;
-using System.IO;
-
-using Mono.Linker;
-using Mono.Linker.Steps;
-
-using Mono.Cecil;
-
-namespace Mono.Tuner {
-
- public class MoonlightA11yAssemblyStep : MoonlightAssemblyStep {
-
- protected override void CustomizePipeline (Pipeline pipeline)
- {
- pipeline.RemoveStep (typeof (LoadI18nAssemblies));
- pipeline.RemoveStep (typeof (BlacklistStep));
- pipeline.RemoveStep (typeof (MarkStep));
- pipeline.RemoveStep (typeof (SweepStep));
- pipeline.RemoveStep (typeof (CleanStep));
- pipeline.RemoveStep (typeof (RegenerateGuidStep));
- pipeline.AddStepBefore (typeof (OutputStep), new MoonlightA11yProcessor ());
- }
-
- }
-}
diff --git a/src/tuner/Mono.Tuner/MoonlightA11yDescriptorGenerator.cs b/src/tuner/Mono.Tuner/MoonlightA11yDescriptorGenerator.cs
deleted file mode 100644
index 17db23b2a..000000000
--- a/src/tuner/Mono.Tuner/MoonlightA11yDescriptorGenerator.cs
+++ /dev/null
@@ -1,337 +0,0 @@
-//
-// MoonlightA11yDescriptorGenerator.cs
-//
-// Author:
-// Andrés G. Aragoneses (aaragoneses@novell.com)
-//
-// (C) 2009 Novell, Inc.
-//
-// 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.
-//
-
-using System;
-using System.Collections;
-using System.Collections.Generic;
-
-using System.IO;
-using System.Text.RegularExpressions;
-using System.Text;
-
-using System.Xml;
-using System.Xml.XPath;
-
-using Mono.Linker;
-using Mono.Linker.Steps;
-
-using Mono.Cecil;
-
-namespace Mono.Tuner {
-
- public class MoonlightA11yDescriptorGenerator : BaseStep {
-
- XmlTextWriter writer = null;
- protected override void ProcessAssembly (AssemblyDefinition assembly)
- {
- if (assembly.Name.Name == "MoonAtkBridge" || assembly.Name.Name == "System.Windows" ||
- assembly.Name.Name.Contains ("Dummy"))
- return;
-
- if (writer == null) {
- if (!Directory.Exists (Context.OutputDirectory))
- Directory.CreateDirectory (Context.OutputDirectory);
-
- string file_name = "descriptors.xml";
- string file_path = Path.Combine (Context.OutputDirectory, file_name);
- if (File.Exists (file_path))
- File.Delete (file_path);
- FileStream xml_file = new FileStream (file_path, FileMode.OpenOrCreate);
- Console.WriteLine ("Created file {0}", file_name);
- Console.Write ("Writing contents...");
-
- writer = new XmlTextWriter (xml_file, System.Text.Encoding.UTF8);
- writer.Formatting = Formatting.Indented;
- writer.WriteStartElement("linker");
- }
-
- SortedDictionary <TypeDefinition, IList> types = ScanAssembly (assembly);
- if (types != null && types.Count > 0) {
- writer.WriteStartElement("assembly");
- writer.WriteAttributeString ("fullname", assembly.Name.Name);
-
- foreach (TypeDefinition type in types.Keys) {
- IList members = types [type];
- if (members != null && members.Count > 0) {
- writer.WriteStartElement("type");
- writer.WriteAttributeString ("fullname", type.FullName);
-
- foreach (IMetadataTokenProvider member in members) {
- MethodDefinition method = member as MethodDefinition;
- if (method != null) {
- writer.WriteStartElement("method");
- writer.WriteAttributeString ("signature",
- method.ReturnType.FullName + " " +
- method.Name + GetMethodParams (method));
- writer.WriteEndElement ();
- continue;
- }
-
- FieldDefinition field = member as FieldDefinition;
- if (field != null) {
- writer.WriteStartElement("field");
- writer.WriteAttributeString ("signature", field.DeclaringType.FullName + " " + field.Name);
- writer.WriteEndElement ();
- }
- }
- writer.WriteEndElement ();
- }
- }
-
- writer.WriteEndElement ();
- Console.WriteLine ();
- }
-
- }
-
- protected override void EndProcess ()
- {
- Console.WriteLine ();
-
- foreach (FileStream stream in streams)
- stream.Close ();
-
- if (writer != null) {
- writer.WriteEndElement ();
- writer.Close ();
- writer = null;
- }
- }
-
- //this is almost the ToString method of MethodDefinition...
- private string GetMethodParams (MethodDefinition method)
- {
- string @params = "(";
- if (method.HasParameters) {
- for (int i = 0; i < method.Parameters.Count; i++) {
- if (i > 0)
- @params += ",";
-
- @params += method.Parameters [i].ParameterType.FullName;
- }
- }
- @params += ")";
- return @params;
- }
-
- SortedDictionary<TypeDefinition, IList> /*,List<IAnnotationProvider>>*/ ScanAssembly (AssemblyDefinition assembly)
- {
- if (Annotations.GetAction (assembly) != AssemblyAction.Link)
- return null;
-
- SortedDictionary<TypeDefinition, IList> members_used = new SortedDictionary<TypeDefinition, IList> (new TypeComparer ());
- foreach (TypeDefinition type in assembly.MainModule.Types) {
- IList used_providers = FilterPublicMembers (ScanType (type));
- if (used_providers.Count > 0)
- members_used [type] = used_providers;
- else if (IsInternal (type, true) &&
- Annotations.IsMarked (type))
- throw new NotSupportedException (String.Format ("The type {0} is used while its API is not", type.ToString ()));
- }
- return members_used;
- }
-
- IList ScanType (TypeDefinition type)
- {
- return ExtractUsedProviders (type.Methods, type.Fields);
- }
-
- static IList FilterPublicMembers (IList members)
- {
- IList new_list = new ArrayList ();
- foreach (MemberReference item in members)
- if (IsInternal (item, true))
- new_list.Add (item);
-
- return new_list;
- }
-
- static string [] master_infos = Directory.GetFiles (Environment.CurrentDirectory, "*.info");
-
- static string FindMasterInfoFile (string name)
- {
- if (master_infos.Length == 0)
- throw new Exception ("No masterinfo files found in current directory");
-
- foreach (string file in master_infos) {
- if (file.EndsWith (name + ".info"))
- return file;
- }
-
- return null;
- }
-
- const string xpath_init = "assemblies/assembly/namespaces/namespace[@name='{0}']/classes/class[@name='{1}']";
-
- static string GetXPathSearchForType (TypeDefinition type)
- {
- TypeDefinition parent_type = type;
- string xpath = String.Empty;
- while (parent_type.DeclaringType != null) {
- xpath = String.Format ("/classes/class[@name='{0}']", parent_type.Name) + xpath;
- parent_type = parent_type.DeclaringType;
- }
- return String.Format (xpath_init, parent_type.Namespace, parent_type.Name) + xpath;
- }
-
- static bool IsInternal (MemberReference member, bool master_info)
- {
- TypeDefinition type = null;
- string master_info_file = null;
-
- if (member is TypeDefinition) {
- type = member as TypeDefinition;
- if (!master_info)
- return (!type.IsNested && !type.IsPublic) ||
- (type.IsNested && (!type.IsNestedPublic || IsInternal (type.DeclaringType, false)));
-
- master_info_file = FindMasterInfoFile (type.Module.Assembly.Name.Name);
- if (master_info_file == null)
- return IsInternal (member, false);
-
- return !NodeExists (master_info_file, GetXPathSearchForType (type));
- }
-
- type = member.DeclaringType.Resolve ();
-
- if (IsInternal (type, master_info))
- return true;
-
- MethodDefinition method = member as MethodDefinition;
- FieldDefinition field = member as FieldDefinition;
-
- if (field == null && method == null)
- throw new System.NotSupportedException ("Members to scan should be methods or fields");
-
- if (!master_info) {
-
- if (method != null)
- return !method.IsPublic;
-
- return !field.IsPublic;
- }
-
- master_info_file = FindMasterInfoFile (type.Module.Assembly.Name.Name);
- if (master_info_file == null)
- return IsInternal (member, false);
-
- string xpath_type = GetXPathSearchForType (type);
- string name;
- if (field != null)
- name = field.Name;
- else {
- name = method.ToString ();
-
- //lame, I know...
- name = WackyOutArgs (WackyCommas (name.Substring (name.IndexOf ("::") + 2)
- .Replace ("/", "+") // nested classes
- .Replace ('<', '[').Replace ('>', ']'))); //generic params
- }
-
- if (field != null || !IsPropertyMethod (method))
- return !NodeExists (master_info_file, xpath_type + String.Format ("/*/*[@name='{0}']", name));
-
- return !NodeExists (master_info_file, xpath_type + String.Format ("/properties/*/*/*[@name='{0}']", name));
- }
-
- //at some point I want to get rid of this method and ask cecil's maintainer to spew commas in a uniform way...
- static string WackyCommas (string method)
- {
- string outstring = String.Empty;
- bool square_bracket = false;
- foreach (char c in method) {
- if (c == '[')
- square_bracket = true;
- else if (c == ']')
- square_bracket = false;
-
- outstring = outstring + c;
-
- if (c == ',' && !square_bracket)
- outstring = outstring + " ";
- }
- return outstring;
- }
-
- //ToString() spews & but not 'out' keyword
- static string WackyOutArgs (string method)
- {
- return Regex.Replace (method, @"\w+&", delegate (Match m) { return "out " + m.ToString (); });
- }
-
- //copied from MarkStep (violating DRY unless I can put this in a better place... Cecil?)
- static bool IsPropertyMethod (MethodDefinition md)
- {
- return (md.SemanticsAttributes & MethodSemanticsAttributes.Getter) != 0 ||
- (md.SemanticsAttributes & MethodSemanticsAttributes.Setter) != 0;
- }
-
- static Dictionary<string, XPathNavigator> navs = new Dictionary<string, XPathNavigator> ();
- static List<FileStream> streams = new List<FileStream> ();
-
- static bool NodeExists (string file, string xpath)
- {
- Console.Write (".");
- //Console.WriteLine ("Looking for node {0} in file {1}", xpath, file.Substring (file.LastIndexOf ("/") + 1));
-
- XPathNavigator nav = null;
- if (!navs.TryGetValue (file, out nav)) {
- FileStream stream = new FileStream (file, FileMode.Open);
- XPathDocument document = new XPathDocument (stream);
- nav = document.CreateNavigator ();
- streams.Add (stream);
- navs [file] = nav;
- }
- return nav.SelectSingleNode (xpath) != null;
- }
-
- IList /*List<IAnnotationProvider>*/ ExtractUsedProviders (params IList[] members)
- {
- IList used = new ArrayList ();
- if (members == null || members.Length == 0)
- return used;
-
- foreach (IList members_list in members)
- foreach (IMetadataTokenProvider provider in members_list)
- if (Annotations.IsMarked (provider))
- used.Add (provider);
-
- return used;
- }
-
- class TypeComparer : IComparer <TypeDefinition> {
-
- public int Compare (TypeDefinition x, TypeDefinition y)
- {
- return string.Compare (x.ToString (), y.ToString ());
- }
-
- }
-
- }
-}
diff --git a/src/tuner/Mono.Tuner/MoonlightA11yProcessor.cs b/src/tuner/Mono.Tuner/MoonlightA11yProcessor.cs
deleted file mode 100644
index 2971b11ad..000000000
--- a/src/tuner/Mono.Tuner/MoonlightA11yProcessor.cs
+++ /dev/null
@@ -1,179 +0,0 @@
-//
-// MoonlightA11yProcessor.cs
-//
-// Author:
-// Andrés G. Aragoneses (aaragoneses@novell.com)
-//
-// (C) 2009 Novell, Inc.
-//
-// 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.
-//
-
-
-using System;
-using System.Linq;
-
-using Mono.Cecil;
-
-using Mono.Linker;
-
-namespace Mono.Tuner {
-
- public class MoonlightA11yProcessor : InjectSecurityAttributes {
-
- protected override bool ConditionToProcess ()
- {
- return true;
- }
-
- protected override void ProcessAssembly (AssemblyDefinition assembly)
- {
- if (Annotations.GetAction (assembly) != AssemblyAction.Link)
- return;
-
- _assembly = assembly;
-
- // remove existing [SecurityCritical] and [SecuritySafeCritical]
- RemoveSecurityAttributes ();
-
- // add [SecurityCritical]
- AddSecurityAttributes ();
-
- // convert all public members into internal
- MakeApiInternal ();
- }
-
- void MakeApiInternal ()
- {
- foreach (TypeDefinition type in _assembly.MainModule.Types) {
- if (type.IsPublic)
- type.IsPublic = false;
-
- if (type.HasMethods && !type.Name.EndsWith ("Adapter"))
- foreach (MethodDefinition ctor in type.Methods.Where (m => m.IsConstructor))
- if (ctor.IsPublic)
- ctor.IsAssembly = true;
-
- if (type.HasMethods)
- foreach (MethodDefinition method in type.Methods.Where (m => !m.IsConstructor))
- if (method.IsPublic)
- method.IsAssembly = true;
- }
- }
-
- void AddSecurityAttributes ()
- {
- foreach (TypeDefinition type in _assembly.MainModule.Types) {
- AddCriticalAttribute (type);
-
- if (type.HasMethods)
- foreach (MethodDefinition ctor in type.Methods.Where (m => m.IsConstructor))
- AddCriticalAttribute (ctor);
-
- if (type.HasMethods)
- foreach (MethodDefinition method in type.Methods.Where (m => !m.IsConstructor)) {
- MethodDefinition parent = null;
-
- //TODO: take in account generic params
- if (!method.HasGenericParameters) {
-
- /*
- * we need to scan base methods because the CoreCLR complains about SC attribs added
- * to overriden methods whose base (virtual or interface) method is not marked as SC
- * with TypeLoadExceptions
- */
- parent = GetBaseMethod (type, method);
- }
-
- //if there's no base method
- if (parent == null ||
-
- //if it's our bridge assembly, we're sure it will (finally, at the end of the linking process) have the SC attrib
- _assembly.MainModule.Types.Contains (parent.DeclaringType) ||
-
- //if the type is in the moonlight assemblies, check if it has the SC attrib
- HasSecurityAttribute (parent, AttributeType.Critical))
-
- AddCriticalAttribute (method);
- }
-
- }
- }
-
- MethodDefinition GetBaseMethod (TypeDefinition finalType, MethodDefinition final)
- {
- // both GetOverridenMethod and GetInterfaceMethod return null if there is no base method
- return GetOverridenMethod (finalType, final) ?? GetInterfaceMethod (finalType, final);
- }
-
- //note: will not return abstract methods
- MethodDefinition GetOverridenMethod (TypeDefinition finalType, MethodDefinition final)
- {
- TypeReference baseType = finalType.BaseType;
- while (baseType != null && baseType.Resolve () != null) {
- foreach (MethodDefinition method in baseType.Resolve ().Methods) {
- if (!method.IsVirtual || method.Name != final.Name)
- continue;
-
- //TODO: should we discard them?
- if (method.IsAbstract)
- continue;
-
- if (HasSameSignature (method, final))
- return method;
- }
- baseType = baseType.Resolve().BaseType;
- }
- return null;
- }
-
- MethodDefinition GetInterfaceMethod (TypeDefinition finalType, MethodDefinition final)
- {
- TypeDefinition baseType = finalType;
- while (baseType != null) {
- if (baseType.HasInterfaces)
- foreach (var @interface in baseType.Interfaces)
- foreach (MethodDefinition method in @interface.InterfaceType.Resolve ().Methods)
- if (method.Name == final.Name && HasSameSignature (method, final))
- return method;
-
- baseType = baseType.BaseType == null ? null : baseType.BaseType.Resolve ();
- }
- return null;
- }
-
- bool HasSameSignature (MethodDefinition method1, MethodDefinition method2)
- {
- if (method1.ReturnType.FullName != method2.ReturnType.FullName)
- return false;
-
- if (method1.Parameters.Count != method2.Parameters.Count)
- return false;
-
- for (int i = 0; i < method1.Parameters.Count; i++) {
- if (method1.Parameters [i].ParameterType.FullName !=
- method2.Parameters [i].ParameterType.FullName)
- return false;
- }
-
- return true;
- }
- }
-}
diff --git a/src/tuner/Mono.Tuner/MoonlightA11yUsageInspectionStep.cs b/src/tuner/Mono.Tuner/MoonlightA11yUsageInspectionStep.cs
deleted file mode 100644
index 27aa4a2ff..000000000
--- a/src/tuner/Mono.Tuner/MoonlightA11yUsageInspectionStep.cs
+++ /dev/null
@@ -1,52 +0,0 @@
-//
-// MoonlightA11yUsageInspectionStep.cs
-//
-// Author:
-// Andrés G. Aragoneses (aaragoneses@novell.com)
-//
-// (C) 2009 Novell, Inc.
-//
-// 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.
-//
-
-using System;
-using System.Collections;
-using System.IO;
-
-using Mono.Linker;
-using Mono.Linker.Steps;
-
-using Mono.Cecil;
-
-namespace Mono.Tuner {
-
- public class MoonlightA11yUsageInspectionStep : MoonlightAssemblyStep {
-
- protected override void CustomizePipeline (Pipeline pipeline)
- {
- pipeline.ReplaceStep (typeof (MarkStep), new MoonlightA11yApiMarker ());
- pipeline.ReplaceStep (typeof (SweepStep), new MoonlightA11yDescriptorGenerator ());
- pipeline.RemoveStep (typeof (LoadI18nAssemblies));
- pipeline.RemoveStep (typeof (CleanStep));
- pipeline.RemoveStep (typeof (RegenerateGuidStep));
- pipeline.RemoveStep (typeof (OutputStep));
- }
- }
-}
diff --git a/src/tuner/Mono.Tuner/MoonlightAssemblyStep.cs b/src/tuner/Mono.Tuner/MoonlightAssemblyStep.cs
deleted file mode 100644
index fc98536f5..000000000
--- a/src/tuner/Mono.Tuner/MoonlightAssemblyStep.cs
+++ /dev/null
@@ -1,66 +0,0 @@
-//
-// MoonlightAssemblyStep.cs
-//
-// Author:
-// Jb Evain (jbevain@novell.com)
-//
-// (C) 2009 Novell, Inc.
-//
-// 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.
-//
-
-using System;
-using System.Collections;
-using System.IO;
-
-using Mono.Linker;
-using Mono.Linker.Steps;
-
-using Mono.Cecil;
-
-namespace Mono.Tuner {
-
- public class MoonlightAssemblyStep : IStep {
-
- public void Process (LinkContext context)
- {
- CustomizePipeline (context.Pipeline);
- ProcessAssemblies (context);
- }
-
- static void ProcessAssemblies (LinkContext context)
- {
- foreach (AssemblyDefinition assembly in context.GetAssemblies ())
- context.Annotations.SetAction (assembly, AssemblyAction.Link);
- }
-
- protected virtual void CustomizePipeline (Pipeline pipeline)
- {
- pipeline.RemoveStep (typeof (LoadI18nAssemblies));
- pipeline.RemoveStep (typeof (BlacklistStep));
- pipeline.RemoveStep (typeof (TypeMapStep));
- pipeline.RemoveStep (typeof (MarkStep));
- pipeline.RemoveStep (typeof (SweepStep));
- pipeline.RemoveStep (typeof (CleanStep));
- pipeline.RemoveStep (typeof (RegenerateGuidStep));
- pipeline.AddStepBefore (typeof (OutputStep), new InjectSecurityAttributes ());
- }
- }
-}
diff --git a/src/tuner/Mono.Tuner/PreserveCrypto.cs b/src/tuner/Mono.Tuner/PreserveCrypto.cs
deleted file mode 100644
index 18dbe7ff2..000000000
--- a/src/tuner/Mono.Tuner/PreserveCrypto.cs
+++ /dev/null
@@ -1,122 +0,0 @@
-using System;
-using System.Collections;
-using System.Collections.Generic;
-using System.Linq;
-
-using Mono.Linker;
-using Mono.Linker.Steps;
-
-using Mono.Cecil;
-using Mono.Cecil.Cil;
-
-namespace Mono.Tuner {
-
- public class PreserveCrypto : IStep {
-
- AnnotationStore annotations;
-
- public void Process (LinkContext context)
- {
- annotations = context.Annotations;
-
- ProcessCorlib (context);
- ProcessSystemCore (context);
- }
-
- void ProcessCorlib (LinkContext context)
- {
- AssemblyDefinition corlib;
- if (!context.TryGetLinkedAssembly ("mscorlib", out corlib))
- return;
-
- AddPreserveInfo (corlib, "DES", "DESCryptoServiceProvider");
- AddPreserveInfo (corlib, "DSA", "DSACryptoServiceProvider");
- AddPreserveInfo (corlib, "RandomNumberGenerator", "RNGCryptoServiceProvider");
- AddPreserveInfo (corlib, "SHA1", "SHA1CryptoServiceProvider");
- AddPreserveInfo (corlib, "SHA1", "SHA1Managed");
- AddPreserveInfo (corlib, "MD5", "MD5CryptoServiceProvider");
- AddPreserveInfo (corlib, "RC2", "RC2CryptoServiceProvider");
- AddPreserveInfo (corlib, "TripleDES", "TripleDESCryptoServiceProvider");
-
- AddPreserveInfo (corlib, "Rijndael", "RijndaelManaged");
- AddPreserveInfo (corlib, "RIPEMD160", "RIPEMD160Managed");
- AddPreserveInfo (corlib, "SHA256", "SHA256Managed");
- AddPreserveInfo (corlib, "SHA384", "SHA384Managed");
- AddPreserveInfo (corlib, "SHA512", "SHA512Managed");
-
- AddPreserveInfo (corlib, "HMAC", "HMACMD5");
- AddPreserveInfo (corlib, "HMAC", "HMACRIPEMD160");
- AddPreserveInfo (corlib, "HMAC", "HMACSHA1");
- AddPreserveInfo (corlib, "HMAC", "HMACSHA256");
- AddPreserveInfo (corlib, "HMAC", "HMACSHA384");
- AddPreserveInfo (corlib, "HMAC", "HMACSHA512");
-
- AddPreserveInfo (corlib, "HMACMD5", "MD5CryptoServiceProvider");
- AddPreserveInfo (corlib, "HMACRIPEMD160", "RIPEMD160Managed");
- AddPreserveInfo (corlib, "HMACSHA1", "SHA1CryptoServiceProvider");
- AddPreserveInfo (corlib, "HMACSHA1", "SHA1Managed");
- AddPreserveInfo (corlib, "HMACSHA256", "SHA256Managed");
- AddPreserveInfo (corlib, "HMACSHA384", "SHA384Managed");
- AddPreserveInfo (corlib, "HMACSHA512", "SHA512Managed");
-
- TryAddPreserveInfo (corlib, "Aes", "AesManaged");
-
- var corlibAes = GetCryptoType (corlib, "Aes");
- Preserve (corlibAes, GetCryptoType (corlib, "AesManaged"));
-
- AssemblyDefinition syscore;
- if (context.TryGetLinkedAssembly ("System.Core", out syscore))
- Preserve (corlibAes, GetCryptoType (syscore, "AesCryptoServiceProvider"));
- }
-
- void ProcessSystemCore (LinkContext context)
- {
- AssemblyDefinition syscore;
- if (!context.TryGetLinkedAssembly ("System.Core", out syscore))
- return;
-
- // AddPreserveInfo (syscore, "Aes", "AesCryptoServiceProvider");
- TryAddPreserveInfo (syscore, "Aes", "AesManaged");
- }
-
- bool TryAddPreserveInfo (AssemblyDefinition assembly, string name, string type)
- {
- var marker = GetCryptoType (assembly, name);
- if (marker == null)
- return false;
-
- var implementation = GetCryptoType (assembly, type);
- if (implementation == null)
- return false;
-
- Preserve (marker, implementation);
- return true;
- }
-
- void AddPreserveInfo (AssemblyDefinition assembly, string name, string type)
- {
- var marker = GetCryptoType (assembly, name);
- if (marker == null)
- throw new ArgumentException (name);
-
- var implementation = GetCryptoType (assembly, type);
- if (implementation == null)
- throw new ArgumentException (type);
-
- Preserve (marker, implementation);
- }
-
- void Preserve (TypeDefinition marker, TypeDefinition implementation)
- {
- if (marker == null || implementation == null)
- return;
- foreach (var constructor in implementation.GetConstructors ())
- annotations.AddPreservedMethod (marker, constructor);
- }
-
- TypeDefinition GetCryptoType (AssemblyDefinition assembly, string name)
- {
- return assembly.MainModule.GetType ("System.Security.Cryptography." + name);
- }
- }
-}
diff --git a/src/tuner/Mono.Tuner/PreserveHttps.cs b/src/tuner/Mono.Tuner/PreserveHttps.cs
deleted file mode 100644
index c3c56c79f..000000000
--- a/src/tuner/Mono.Tuner/PreserveHttps.cs
+++ /dev/null
@@ -1,83 +0,0 @@
-using System;
-using System.IO;
-using System.Xml.XPath;
-
-using Mono.Linker;
-using Mono.Linker.Steps;
-
-using Mono.Cecil;
-
-namespace Mono.Tuner {
-
- public class PreserveHttps : BaseStep {
-
- static string [] types = new [] {
- "System.Net.WebRequest",
- "System.Net.WebClient",
- "System.Net.Security.RemoteCertificateValidationCallback",
- "System.Web.Services.Protocols.WebClientProtocol",
- "System.Security.Cryptography.X509Certificates.X509Certificate",
- "System.ServiceModel.ClientBase`1",
- "System.Web.Services.WebServiceBindingAttribute",
- "System.Web.Services.Protocols.SoapHttpClientProtocol",
- "System.Xml.XmlDocument"
- };
-
- bool need_https;
-
- protected override void ProcessAssembly (AssemblyDefinition assembly)
- {
- if (need_https)
- return;
-
- if (Profile.IsSdkAssembly (assembly) || Profile.IsProductAssembly (assembly))
- return;
-
- if (HasNeededReference (assembly.MainModule))
- need_https = true;
- }
-
- static bool HasNeededReference (ModuleDefinition module)
- {
- foreach (var type in types)
- if (module.HasTypeReference (type))
- return true;
-
- return false;
- }
-
- protected override void EndProcess ()
- {
- if (!need_https)
- return;
-
- var mono_security = Context.Resolve ("Mono.Security");
- if (mono_security == null)
- return;
-
- if (Annotations.GetAction (mono_security) != AssemblyAction.Link)
- return;
-
- var xml_preserve = CreatePreserveStep ();
- Context.Pipeline.AddStepAfter (typeof (PreserveHttps), xml_preserve);
-// Context.Pipeline.AddStepAfter (xml_preserve, new PreserveCrypto ());
- }
-
- static IStep CreatePreserveStep ()
- {
- return new ResolveFromXmlStep (
- new XPathDocument (
- new StringReader (descriptor)));
- }
-
- const string descriptor = @"<?xml version=""1.0"" encoding=""utf-8"" ?>
-<linker>
- <assembly fullname=""Mono.Security"">
- <type fullname=""Mono.Security.Protocol.Tls.HttpsClientStream"" />
- <type fullname=""Mono.Security.Protocol.Tls.SslClientStream"" />
- <type fullname=""Mono.Security.Protocol.Tls.SslStreamBase"" />
- </assembly>
-</linker>
-";
- }
-}
diff --git a/src/tuner/Mono.Tuner/PreserveSoapHttpClients.cs b/src/tuner/Mono.Tuner/PreserveSoapHttpClients.cs
deleted file mode 100644
index bdb04a94d..000000000
--- a/src/tuner/Mono.Tuner/PreserveSoapHttpClients.cs
+++ /dev/null
@@ -1,90 +0,0 @@
-using System;
-
-using Mono.Linker;
-
-using Mono.Cecil;
-
-namespace Mono.Tuner {
-
- public class PreserveSoapHttpClients : BaseSubStep {
-
- public override SubStepTargets Targets {
- get { return SubStepTargets.Type; }
- }
-
- public override bool IsActiveFor (AssemblyDefinition assembly)
- {
- return Annotations.GetAction (assembly) == AssemblyAction.Link && !Profile.IsSdkAssembly (assembly);
- }
-
- public override void ProcessType (TypeDefinition type)
- {
- if (IsWebServiceClient (type))
- PreserveClient (type);
- }
-
- void PreserveClient (TypeDefinition type)
- {
- if (!type.HasMethods)
- return;
-
- foreach (MethodDefinition method in type.Methods) {
- string sync_method;
- if (!TryExtractSyncMethod (method, out sync_method))
- continue;
-
- AddPreservedMethod (method, sync_method);
- }
- }
-
- void AddPreservedMethod (MethodDefinition target, string methodName)
- {
- foreach (MethodDefinition method in target.DeclaringType.Methods)
- if (method.Name == methodName)
- Annotations.AddPreservedMethod (target, method);
- }
-
- static bool TryExtractSyncMethod (MethodDefinition method, out string sync_method)
- {
- if (TryExtractPrefixedMethodName ("Begin", method.Name, out sync_method))
- return true;
-
- if (TryExtractPrefixedMethodName ("End", method.Name, out sync_method))
- return true;
-
- if (TryExtractSuffixedMethodName ("Async", method.Name, out sync_method))
- return true;
-
- return false;
- }
-
- static bool TryExtractPrefixedMethodName (string prefix, string fullName, out string methodName)
- {
- methodName = null;
-
- int pos = fullName.IndexOf (prefix, StringComparison.Ordinal);
- if (pos == -1)
- return false;
-
- methodName = fullName.Substring (prefix.Length);
- return true;
- }
-
- static bool TryExtractSuffixedMethodName (string suffix, string fullName, out string methodName)
- {
- methodName = null;
-
- int pos = fullName.LastIndexOf (suffix, StringComparison.Ordinal);
- if (pos == -1)
- return false;
-
- methodName = fullName.Substring (0, pos);
- return true;
- }
-
- static bool IsWebServiceClient (TypeDefinition type)
- {
- return type.Inherits ("System.Web.Services.Protocols", "SoapHttpClientProtocol");
- }
- }
-} \ No newline at end of file
diff --git a/src/tuner/Mono.Tuner/PrintStatus.cs b/src/tuner/Mono.Tuner/PrintStatus.cs
deleted file mode 100644
index 374395bac..000000000
--- a/src/tuner/Mono.Tuner/PrintStatus.cs
+++ /dev/null
@@ -1,86 +0,0 @@
-//
-// PrintStatus.cs
-//
-// Author:
-// Jb Evain (jbevain@novell.com)
-//
-// (C) 2007 Novell, Inc.
-//
-// 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.
-//
-
-using System;
-using System.Collections;
-
-using Mono.Linker;
-using Mono.Linker.Steps;
-
-using Mono.Cecil;
-
-namespace Mono.Tuner {
-
- public class PrintStatus : BaseStep {
-
- static string display_internalized = "display_internalized";
-
- protected override void ProcessAssembly (AssemblyDefinition assembly)
- {
- if (Annotations.GetAction (assembly) != AssemblyAction.Link)
- return;
-
- Console.WriteLine ("Assembly `{0}' ({1}) tuned", assembly.Name, assembly.MainModule.FullyQualifiedName);
-
- if (!DisplayInternalized ())
- return;
-
- foreach (TypeDefinition type in assembly.MainModule.Types)
- ProcessType (type);
- }
-
- bool DisplayInternalized ()
- {
- try {
- return bool.Parse (Context.GetParameter (display_internalized));
- } catch {
- return false;
- }
- }
-
- void ProcessType (TypeDefinition type)
- {
- ProcessCollection (type.Fields);
- ProcessCollection (type.Methods);
- }
-
- void ProcessCollection (ICollection collection)
- {
- foreach (IMetadataTokenProvider provider in collection)
- ProcessProvider (provider);
- }
-
- void ProcessProvider (IMetadataTokenProvider provider)
- {
- if (!TunerAnnotations.IsInternalized (Context, provider))
- return;
-
- Console.WriteLine ("[internalized] {0}", provider);
- }
- }
-}
diff --git a/src/tuner/Mono.Tuner/PrintTypeMap.cs b/src/tuner/Mono.Tuner/PrintTypeMap.cs
deleted file mode 100644
index 8838b1aed..000000000
--- a/src/tuner/Mono.Tuner/PrintTypeMap.cs
+++ /dev/null
@@ -1,71 +0,0 @@
-//
-// PrintTypeMap.cs
-//
-// Author:
-// Jb Evain (jbevain@novell.com)
-//
-// (C) 2009 Novell, Inc.
-//
-// 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.
-//
-
-using System;
-using System.Collections;
-using System.Collections.Generic;
-
-using Mono.Linker;
-using Mono.Linker.Steps;
-
-using Mono.Cecil;
-
-namespace Mono.Tuner {
-
- public class PrintTypeMap : BaseStep {
-
- protected override void ProcessAssembly (AssemblyDefinition assembly)
- {
- foreach (TypeDefinition type in assembly.MainModule.GetAllTypes ())
- PrintMap (type);
- }
-
- void PrintMap (TypeDefinition type)
- {
- if (!type.HasMethods)
- return;
-
- Console.WriteLine ("Type {0} map", type);
-
- foreach (MethodDefinition method in type.Methods) {
- if (!method.IsVirtual)
- continue;
-
- Console.WriteLine (" Method {0} map", method);
-
- IEnumerable<MethodDefinition> overrides = Annotations.GetOverrides (method);
- foreach (var @override in overrides ?? new MethodDefinition [0])
- Console.WriteLine (" HasOverride {0}", @override);
-
- IEnumerable<MethodDefinition> bases = Annotations.GetBaseMethods (method);
- foreach (var @base in bases ?? new MethodDefinition [0])
- Console.WriteLine (" Base {0}", @base);
- }
- }
- }
-}
diff --git a/src/tuner/Mono.Tuner/Profile.cs b/src/tuner/Mono.Tuner/Profile.cs
deleted file mode 100644
index 54cfffa64..000000000
--- a/src/tuner/Mono.Tuner/Profile.cs
+++ /dev/null
@@ -1,78 +0,0 @@
-using System;
-using System.Collections.Generic;
-
-using Mono.Cecil;
-
-namespace Mono.Tuner {
-
- public abstract class Profile {
-
- static Profile current;
-
- public static Profile Current {
- get {
- if (current != null)
- return current;
-
- current = CreateProfile ("MonoTouch");
- if (current != null)
- return current;
-
- current = CreateProfile ("MonoDroid");
- if (current != null)
- return current;
-
- current = CreateProfile ("MonoMac");
- if (current != null)
- return current;
-
- throw new NotSupportedException ("No active profile");
- }
- set {
- current = value;
- }
- }
-
- static Profile CreateProfile (string name)
- {
- var type = Type.GetType (string.Format ("{0}.Tuner.{0}Profile", name));
- if (type == null)
- return null;
-
- return (Profile) Activator.CreateInstance (type);
- }
-
- public static bool IsSdkAssembly (AssemblyDefinition assembly)
- {
- return Current.IsSdk (assembly);
- }
-
- public static bool IsSdkAssembly (string assemblyName)
- {
- return Current.IsSdk (assemblyName);
- }
-
- public static bool IsProductAssembly (AssemblyDefinition assembly)
- {
- return Current.IsProduct (assembly);
- }
-
- public static bool IsProductAssembly (string assemblyName)
- {
- return Current.IsProduct (assemblyName);
- }
-
- protected virtual bool IsSdk (AssemblyDefinition assembly)
- {
- return IsSdk (assembly.Name.Name);
- }
-
- protected virtual bool IsProduct (AssemblyDefinition assembly)
- {
- return IsProduct (assembly.Name.Name);
- }
-
- protected abstract bool IsSdk (string assemblyName);
- protected abstract bool IsProduct (string assemblyName);
- }
-}
diff --git a/src/tuner/Mono.Tuner/RemoveAttributesBase.cs b/src/tuner/Mono.Tuner/RemoveAttributesBase.cs
deleted file mode 100644
index 663979e63..000000000
--- a/src/tuner/Mono.Tuner/RemoveAttributesBase.cs
+++ /dev/null
@@ -1,119 +0,0 @@
-using System;
-using System.Collections;
-using System.Collections.Generic;
-using System.Linq;
-
-using Mono.Linker;
-using Mono.Linker.Steps;
-
-using Mono.Tuner;
-
-using Mono.Cecil;
-
-namespace Mono.Tuner {
-
- public abstract class RemoveAttributesBase : BaseSubStep {
-
- public override SubStepTargets Targets {
- get {
- return SubStepTargets.Assembly
- | SubStepTargets.Type
- | SubStepTargets.Field
- | SubStepTargets.Method
- | SubStepTargets.Property
- | SubStepTargets.Event;
- }
- }
-
- public override bool IsActiveFor (AssemblyDefinition assembly)
- {
- return Annotations.GetAction (assembly) == AssemblyAction.Link;
- }
-
- public override void ProcessAssembly (AssemblyDefinition assembly)
- {
- ProcessAttributeProvider (assembly);
- ProcessAttributeProvider (assembly.MainModule);
- }
-
- public override void ProcessType (TypeDefinition type)
- {
- ProcessAttributeProvider (type);
- ProcessGenericParameterProvider (type);
-
- if (type.HasInterfaces)
- ProcessAttributeProviderCollection (type.Interfaces);
- }
-
- void ProcessAttributeProviderCollection (IList list)
- {
- for (int i = 0; i < list.Count; i++)
- ProcessAttributeProvider ((ICustomAttributeProvider) list [i]);
- }
-
- public override void ProcessField (FieldDefinition field)
- {
- ProcessAttributeProvider (field);
- }
-
- void ProcessGenericParameterProvider (IGenericParameterProvider provider)
- {
- if (!provider.HasGenericParameters)
- return;
-
- foreach (var parameter in provider.GenericParameters) {
- ProcessAttributeProvider (parameter);
-
- if (!parameter.HasConstraints)
- continue;
-
- foreach (var constraint in parameter.Constraints)
- ProcessAttributeProvider (constraint);
- }
- }
-
- public override void ProcessMethod (MethodDefinition method)
- {
- ProcessMethodAttributeProvider (method);
- }
-
- void ProcessMethodAttributeProvider (MethodDefinition method)
- {
- ProcessAttributeProvider (method);
- ProcessAttributeProvider (method.MethodReturnType);
-
- if (method.HasParameters)
- ProcessAttributeProviderCollection (method.Parameters);
-
- ProcessGenericParameterProvider (method);
- }
-
- public override void ProcessProperty (PropertyDefinition property)
- {
- ProcessAttributeProvider (property);
- }
-
- public override void ProcessEvent (EventDefinition @event)
- {
- ProcessAttributeProvider (@event);
- }
-
- void ProcessAttributeProvider (ICustomAttributeProvider provider)
- {
- if (!provider.HasCustomAttributes)
- return;
-
- for (int i = 0; i < provider.CustomAttributes.Count; i++) {
- var attrib = provider.CustomAttributes [i];
- if (!IsRemovedAttribute (attrib))
- continue;
-
- WillRemoveAttribute (provider, attrib);
- provider.CustomAttributes.RemoveAt (i--);
- }
- }
-
- protected abstract bool IsRemovedAttribute (CustomAttribute attribute);
- protected virtual void WillRemoveAttribute (ICustomAttributeProvider provider, CustomAttribute attribute) { }
- }
-}
diff --git a/src/tuner/Mono.Tuner/RemoveResources.cs b/src/tuner/Mono.Tuner/RemoveResources.cs
deleted file mode 100644
index 19c638615..000000000
--- a/src/tuner/Mono.Tuner/RemoveResources.cs
+++ /dev/null
@@ -1,63 +0,0 @@
-using System;
-
-using Mono.Linker;
-using Mono.Linker.Steps;
-
-using Mono.Cecil;
-
-namespace Mono.Tuner {
-
- public class RemoveResources : IStep {
-
- readonly I18nAssemblies assemblies;
-
- public RemoveResources (I18nAssemblies assemblies)
- {
- this.assemblies = assemblies;
- }
-
- public virtual void Process (LinkContext context)
- {
- AssemblyDefinition assembly;
- if (!context.TryGetLinkedAssembly ("mscorlib", out assembly))
- return;
-
- // skip this if we're not linking mscorlib, e.g. --linkskip=mscorlib
- if (context.Annotations.GetAction (assembly) != AssemblyAction.Link)
- return;
-
- var resources = assembly.MainModule.Resources;
-
- for (int i = 0; i < resources.Count; i++) {
- var resource = resources [i] as EmbeddedResource;
- if (resource == null)
- continue;
-
- if (RemoveResource (resource.Name))
- resources.RemoveAt(i--);
- }
- }
-
- bool RemoveResource (string name)
- {
- switch (name) {
- case "mscorlib.xml":
- return true;
- case "collation.core.bin":
- case "collation.tailoring.bin":
- return false;
- default:
- if (!name.Contains("cjk"))
- return false;
- if (IncludeCJK())
- return false;
- return true;
- }
- }
-
- bool IncludeCJK ()
- {
- return (assemblies & I18nAssemblies.CJK) != 0;
- }
- }
-}
diff --git a/src/tuner/Mono.Tuner/RemoveSecurity.cs b/src/tuner/Mono.Tuner/RemoveSecurity.cs
deleted file mode 100644
index 2704564a6..000000000
--- a/src/tuner/Mono.Tuner/RemoveSecurity.cs
+++ /dev/null
@@ -1,50 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-
-using Mono.Linker;
-using Mono.Linker.Steps;
-
-using Mono.Cecil;
-
-namespace Mono.Tuner {
-
- public class RemoveSecurity : BaseSubStep {
-
- public override SubStepTargets Targets {
- get {
- return SubStepTargets.Assembly
- | SubStepTargets.Type
- | SubStepTargets.Method;
- }
- }
-
- public override bool IsActiveFor (AssemblyDefinition assembly)
- {
- return Annotations.GetAction (assembly) == AssemblyAction.Link;
- }
-
- public override void ProcessAssembly (AssemblyDefinition assembly)
- {
- ProcessSecurityProvider (assembly);
- }
-
- public override void ProcessType (TypeDefinition type)
- {
- ProcessSecurityProvider (type);
- }
-
- public override void ProcessMethod (MethodDefinition method)
- {
- ProcessSecurityProvider (method);
- }
-
- static void ProcessSecurityProvider (ISecurityDeclarationProvider provider)
- {
- if (!provider.HasSecurityDeclarations)
- return;
-
- provider.SecurityDeclarations.Clear ();
- }
- }
-}
diff --git a/src/tuner/Mono.Tuner/RemoveSerialization.cs b/src/tuner/Mono.Tuner/RemoveSerialization.cs
deleted file mode 100644
index d38aef196..000000000
--- a/src/tuner/Mono.Tuner/RemoveSerialization.cs
+++ /dev/null
@@ -1,149 +0,0 @@
-//
-// RemoveSerialization.cs
-//
-// Author:
-// Jb Evain (jbevain@novell.com)
-//
-// (C) 2007 Novell, Inc.
-//
-// 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.
-//
-
-using System;
-using System.Collections;
-
-using Mono.Linker;
-using Mono.Linker.Steps;
-
-using Mono.Cecil;
-
-namespace Mono.Tuner {
-
- public class RemoveSerialization : BaseStep {
-
- static readonly string _Serialization = "System.Runtime.Serialization";
- static readonly string _ISerializable = Concat (_Serialization, "ISerializable");
- static readonly string _IDeserializationCallback = Concat (_Serialization, "IDeserializationCallback");
- static readonly string _SerializationInfo = Concat (_Serialization, "SerializationInfo");
- static readonly string _StreamingContext = Concat (_Serialization, "StreamingContext");
-
- static readonly string _GetObjectData = "GetObjectData";
- static readonly string _OnDeserialization = "OnDeserialization";
-
- static string Concat (string lhs, string rhs)
- {
- return string.Concat (lhs, ".", rhs);
- }
-
- protected override void ProcessAssembly (AssemblyDefinition assembly)
- {
- if (assembly.Name.Name == "mscorlib")
- return;
-
- if (Annotations.GetAction (assembly) != AssemblyAction.Link)
- return;
-
- foreach (ModuleDefinition module in assembly.Modules)
- foreach (TypeDefinition type in module.Types)
- ProcessType (type);
- }
-
- static void RemoveInterface (TypeDefinition type, string name)
- {
- for (int i = 0; i < type.Interfaces.Count; i++) {
- TypeReference iface = type.Interfaces [i].InterfaceType;
- if (iface.FullName == name) {
- type.Interfaces.RemoveAt (i);
- return;
- }
- }
- }
-
- static void RemoveSerializableFlag (TypeDefinition type)
- {
- type.Attributes &= ~TypeAttributes.Serializable;
- }
-
- static void ProcessType (TypeDefinition type)
- {
- RemoveSerializableFlag (type);
-
- RemoveInterface (type, _ISerializable);
- RemoveMethod (type, ".ctor", _SerializationInfo, _StreamingContext);
- RemoveInterfaceMethod (type, _ISerializable, _GetObjectData, _SerializationInfo, _StreamingContext);
-
- RemoveInterface (type, _IDeserializationCallback);
- RemoveInterfaceMethod (type, _IDeserializationCallback, _OnDeserialization, "System.Object");
-
- RemoveField (type);
- }
-
- static void RemoveField (TypeDefinition type)
- {
- for (int i = 0; i < type.Fields.Count; i++) {
- FieldDefinition field = type.Fields [i];
- if (field.FieldType.FullName == _SerializationInfo) {
- type.Fields.RemoveAt (i);
- break;
- }
- }
- }
-
- static bool ParametersMatch (IMethodSignature meth, string [] parameters)
- {
- for (int i = 0; i < parameters.Length; i++) {
- ParameterDefinition param = meth.Parameters [i];
- if (param.ParameterType.FullName != parameters [i])
- return false;
- }
-
- return true;
- }
-
- static void RemoveInterfaceMethod (TypeDefinition type, string iface, string method, params string [] parameters)
- {
- RemoveMethod (type, method, parameters);
- RemoveMethod (type, Concat (iface, method), parameters);
- }
-
- static void RemoveMethod (TypeDefinition type, string name, params string [] parameters)
- {
- RemoveMethod (type.Methods, name, parameters);
- }
-
- static void RemoveMethod (IList container, string name, params string [] parameters)
- {
- for (int i = 0; i < container.Count; i++) {
- MethodDefinition method = (MethodDefinition) container [i];
- if (method.Name != name)
- continue;
-
- if (method.Parameters.Count != parameters.Length)
- continue;
-
- if (!ParametersMatch (method, parameters))
- continue;
-
- container.RemoveAt (i);
- return;
- }
- }
- }
-}
diff --git a/src/tuner/Mono.Tuner/TunerAnnotations.cs b/src/tuner/Mono.Tuner/TunerAnnotations.cs
deleted file mode 100644
index 2107ac4a0..000000000
--- a/src/tuner/Mono.Tuner/TunerAnnotations.cs
+++ /dev/null
@@ -1,55 +0,0 @@
-//
-// TunerAnnotations.cs
-//
-// Author:
-// Jb Evain (jbevain@novell.com)
-//
-// (C) 2007 Novell, Inc.
-//
-// 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.
-//
-
-using Mono.Cecil;
-using Mono.Linker;
-
-namespace Mono.Tuner {
-
- public class TunerAnnotations {
-
- static readonly object _internalizedKey = new object ();
-
- public static void Internalized (LinkContext context, IMetadataTokenProvider provider)
- {
- var annotations = context.Annotations.GetCustomAnnotations (_internalizedKey);
- annotations [provider] = _internalizedKey;
- }
-
- public static bool IsInternalized (LinkContext context, IMetadataTokenProvider provider)
- {
- var annotations = context.Annotations.GetCustomAnnotations (_internalizedKey);
-
- return annotations.ContainsKey (provider);
- }
-
- private TunerAnnotations ()
- {
- }
- }
-}
diff --git a/src/tuner/MonoMac.Tuner/ApplyPreserveAttribute.cs b/src/tuner/MonoMac.Tuner/ApplyPreserveAttribute.cs
deleted file mode 100644
index d7c49b886..000000000
--- a/src/tuner/MonoMac.Tuner/ApplyPreserveAttribute.cs
+++ /dev/null
@@ -1,21 +0,0 @@
-using System;
-using System.Collections;
-using System.Collections.Generic;
-using System.Linq;
-
-using Mono.Linker;
-using Mono.Linker.Steps;
-
-using Mono.Tuner;
-
-using Mono.Cecil;
-
-namespace MonoMac.Tuner {
-
- public class ApplyPreserveAttribute : ApplyPreserveAttributeBase {
-
- protected override string PreserveAttribute {
- get { return "MonoMac.Foundation.PreserveAttribute"; }
- }
- }
-}
diff --git a/src/tuner/MonoMac.Tuner/Extensions.cs b/src/tuner/MonoMac.Tuner/Extensions.cs
deleted file mode 100644
index ec7fd1f8d..000000000
--- a/src/tuner/MonoMac.Tuner/Extensions.cs
+++ /dev/null
@@ -1,27 +0,0 @@
-using System;
-using System.Collections.Generic;
-
-using Mono.Cecil;
-
-using Mono.Linker;
-
-using Mono.Tuner;
-
-namespace MonoMac.Tuner {
-
- static class Extensions {
-
- const string NSObject = "MonoMac.Foundation.NSObject";
- const string INativeObject = "MonoMac.ObjCRuntime.INativeObject";
-
- public static bool IsNSObject (this TypeDefinition type)
- {
- return type.Inherits (NSObject);
- }
-
- public static bool IsNativeObject (this TypeDefinition type)
- {
- return type.Implements (INativeObject);
- }
- }
-}
diff --git a/src/tuner/MonoMac.Tuner/MarkNSObjects.cs b/src/tuner/MonoMac.Tuner/MarkNSObjects.cs
deleted file mode 100644
index 163deccbb..000000000
--- a/src/tuner/MonoMac.Tuner/MarkNSObjects.cs
+++ /dev/null
@@ -1,53 +0,0 @@
-//
-// MarkNSObjects.cs
-//
-// Authors:
-// Jb Evain (jbevain@novell.com)
-// Sebastien Pouliot <sebastien@xamarin.com>
-//
-// (C) 2009 Novell, Inc.
-// Copyright (C) 2011 Xamarin, Inc.
-//
-// 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.
-//
-
-using System;
-
-using Mono.Tuner;
-
-using Mono.Cecil;
-
-namespace MonoMac.Tuner {
-
- public class MarkNSObjects : MarkNSObjectsBase {
-
- protected override string ExportAttribute {
- get { return "MonoMac.Foundation.ExportAttribute"; }
- }
-
- public override void ProcessType (TypeDefinition type)
- {
- if (!type.IsNSObject () || !type.IsNativeObject ())
- return;
-
- base.ProcessType (type);
- }
- }
-}
diff --git a/src/tuner/MonoMac.Tuner/MethodMapInjection.cs b/src/tuner/MonoMac.Tuner/MethodMapInjection.cs
deleted file mode 100644
index ebb24073a..000000000
--- a/src/tuner/MonoMac.Tuner/MethodMapInjection.cs
+++ /dev/null
@@ -1,382 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-
-using Mono.Linker;
-using Mono.Linker.Steps;
-
-using Mono.Tuner;
-
-using Mono.Cecil;
-using Mono.Cecil.Cil;
-
-namespace MonoMac.Tuner {
-
- public class MethodMapInjection : BaseStep {
-
- struct ExportedMethod {
- public readonly CustomAttribute attribute;
- public readonly MethodDefinition method;
-
- public ExportedMethod (CustomAttribute attribute, MethodDefinition method)
- {
- this.attribute = attribute;
- this.method = method;
- }
- }
-
- ModuleDefinition module;
-
- bool imported;
- TypeReference void_type;
- TypeReference dictionary_intptr_methoddesc;
- MethodReference dictionary_intptr_methoddesc_ctor;
- MethodReference dictionary_intptr_methoddesc_set_item;
- MethodReference methoddesc_ctor;
- MethodReference selector_get_handle;
- MethodReference methodbase_get_method_from_handle;
- MethodReference class_register_methods;
- MethodReference type_get_type_from_handle;
- FieldReference selector_init;
-
- protected override void ProcessAssembly (AssemblyDefinition assembly)
- {
- if (Annotations.GetAction (assembly) != AssemblyAction.Link)
- return;
-
- module = assembly.MainModule;
-
- foreach (TypeDefinition type in module.GetAllTypes ()) {
- if (!type.IsNSObject ())
- continue;
-
- ProcessNSObject (type);
- }
-
- imported = false;
- }
-
- void PrepareImports ()
- {
- if (imported)
- return;
-
- var corlib = Context.GetAssembly ("mscorlib");
-
- void_type = Import (corlib, "System.Void");
-
- var monomac = Context.GetAssembly ("MonoMac");
-
- var dictionary = Import (corlib, "System.Collections.Generic.Dictionary`2");
-
- var intptr = Import (corlib, "System.IntPtr");
- var method_desc = Import (monomac, "MonoMac.ObjCRuntime.MethodDescription");
-
- var dic_i_md = new GenericInstanceType (dictionary);
- dic_i_md.GenericArguments.Add (intptr);
- dic_i_md.GenericArguments.Add (method_desc);
- dictionary_intptr_methoddesc = dic_i_md;
-
- dictionary_intptr_methoddesc_ctor = Import (".ctor", dic_i_md, false, void_type, Import (corlib, "System.Int32"));
-
- dictionary_intptr_methoddesc_set_item = Import ("set_Item", dic_i_md, false, void_type,
- dictionary.GenericParameters [0],
- dictionary.GenericParameters [1]);
-
- methoddesc_ctor = Import (".ctor", method_desc, false, void_type,
- Import (corlib, "System.Reflection.MethodBase"),
- Import (monomac, "MonoMac.ObjCRuntime.ArgumentSemantic"));
-
- var selector = Import (monomac, "MonoMac.ObjCRuntime.Selector");
-
- selector_get_handle = Import ("GetHandle", selector, true, intptr, Import (corlib, "System.String"));
- selector_init = new FieldReference ("Init", selector, intptr);
-
- var methodbase = Import (corlib, "System.Reflection.MethodBase");
-
- methodbase_get_method_from_handle = Import ("GetMethodFromHandle", methodbase, true, methodbase, Import (corlib, "System.RuntimeMethodHandle"));
-
- var type = Import (corlib, "System.Type");
-
- type_get_type_from_handle = Import ("GetTypeFromHandle", type, true, type, Import (corlib, "System.RuntimeTypeHandle"));
-
- var @class = Import (monomac, "MonoMac.ObjCRuntime.Class");
-
- class_register_methods = Import ("RegisterMethods", @class, true, void_type, type, dic_i_md);
-
- imported = true;
- }
-
- MethodReference Import (string name, TypeReference declaring_type, bool @static, TypeReference return_type, params TypeReference [] parameters_type)
- {
- var reference = new MethodReference (name, return_type, declaring_type) {
- HasThis = !@static,
- ExplicitThis = false,
- CallingConvention = MethodCallingConvention.Default,
- };
-
- foreach (var parameter_type in parameters_type)
- reference.Parameters.Add (new ParameterDefinition (parameter_type));
-
- return reference;
- }
-
- TypeReference Import (TypeReference type)
- {
- return module.Import (type);
- }
-
- TypeReference Import (AssemblyDefinition assembly, string type_name)
- {
- return Import (assembly.MainModule.GetType (type_name));
- }
-
- void ProcessNSObject (TypeDefinition type)
- {
- var exported = new List<ExportedMethod> ();
-
- if (type.HasMethods) {
- ProcessMethods (type, exported);
- ProcessConstructors (type, exported);
- }
-
- if (exported.Count == 0)
- return;
-
- InjectMethodMap (type, exported);
- }
-
- void InjectMethodMap (TypeDefinition type, List<ExportedMethod> exported_methods)
- {
- PrepareImports ();
-
- var cctor = GetTypeConstructor (type);
-
- var selectors = MapSelectors (cctor);
-
- var map = new VariableDefinition (dictionary_intptr_methoddesc);
- map.Name = "$method_map";
- cctor.Body.Variables.Add (map);
- cctor.Body.SimplifyMacros ();
-
- var il = cctor.Body.GetILProcessor ();
-
- var instructions = new List<Instruction> {
- il.Create (OpCodes.Ldc_I4, exported_methods.Count),
- il.Create (OpCodes.Newobj, dictionary_intptr_methoddesc_ctor),
- il.Create (OpCodes.Stloc, map),
- };
-
- foreach (var exported in exported_methods) {
-
- instructions.Add (il.Create (OpCodes.Ldloc, map));
-
- if (!IsDefaultConstructor (exported)) {
- var selector_name = GetSelectorName (exported);
- FieldReference selector;
-
- if (selectors != null && selectors.TryGetValue (selector_name, out selector)) {
- instructions.Add (il.Create (OpCodes.Ldsfld, selector));
- } else {
- instructions.AddRange (new [] {
- il.Create (OpCodes.Ldstr, selector_name),
- il.Create (OpCodes.Call, selector_get_handle),
- });
- }
- } else
- instructions.Add (il.Create (OpCodes.Ldsfld, selector_init));
-
- instructions.AddRange (new [] {
- il.Create (OpCodes.Ldtoken, exported.method),
- il.Create (OpCodes.Call, methodbase_get_method_from_handle),
- il.Create (OpCodes.Ldc_I4, GetArgumentSemantic (exported)),
- il.Create (OpCodes.Newobj, methoddesc_ctor),
- il.Create (OpCodes.Callvirt, dictionary_intptr_methoddesc_set_item),
- });
- }
-
- instructions.AddRange (new [] {
- il.Create (OpCodes.Ldtoken, type),
- il.Create (OpCodes.Call, type_get_type_from_handle),
- il.Create (OpCodes.Ldloc, map),
- il.Create (OpCodes.Call, class_register_methods),
- });
-
- Append (il, instructions);
-
- cctor.Body.OptimizeMacros ();
- }
-
- static Dictionary<string, FieldReference> MapSelectors (MethodDefinition cctor)
- {
- var instructions = cctor.Body.Instructions;
- Dictionary<string, FieldReference> selectors = null;
-
- for (int i = 0; i < instructions.Count; i++) {
- var instruction = instructions [i];
-
- FieldReference field;
- if (!IsCreateSelector (instruction, out field))
- continue;
-
- if (selectors == null)
- selectors = new Dictionary<string, FieldReference> ();
-
- selectors.Add ((string) instruction.Operand, field);
- }
-
- return selectors;
- }
-
- static bool IsCreateSelector (Instruction instruction, out FieldReference field)
- {
- field = null;
-
- if (instruction.OpCode != OpCodes.Ldstr)
- return false;
-
- if (instruction.Next == null)
- return false;
-
- instruction = instruction.Next;
-
- if (instruction.OpCode != OpCodes.Call)
- return false;
-
- var method = (MethodReference) instruction.Operand;
- if (method.DeclaringType.Name != "Selector")
- return false;
-
- if (method.Name != "GetHandle" && method.Name != "sel_registerName")
- return false;
-
- if (instruction.Next == null)
- return false;
-
- instruction = instruction.Next;
-
- if (instruction.OpCode != OpCodes.Stsfld)
- return false;
-
- field = instruction.Operand as FieldReference;
- return true;
- }
-
- static bool IsDefaultConstructor (ExportedMethod exported)
- {
- return exported.attribute == null && exported.method.IsConstructor && !exported.method.IsStatic;
- }
-
- static void Append (ILProcessor il, IEnumerable<Instruction> instructions)
- {
- var method_instructions = il.Body.Instructions;
- var last = method_instructions [method_instructions.Count - 1];
-
- foreach (var instruction in instructions)
- il.InsertBefore (last, instruction);
- }
-
- static int GetArgumentSemantic (ExportedMethod exported)
- {
- if (exported.attribute == null)
- return 0; // Assign
-
- var arguments = exported.attribute.ConstructorArguments;
-
- if (arguments.Count == 2)
- return (int) arguments [1].Value;
-
- if (arguments.Count == 1)
- return -1; // None
-
- return 0; // Assign
- }
-
- static string GetSelectorName (ExportedMethod exported)
- {
- var arguments = exported.attribute.ConstructorArguments;
-
- if (arguments.Count == 0)
- return exported.method.Name;
-
- return (string) arguments [0].Value;
- }
-
- MethodDefinition GetTypeConstructor (TypeDefinition type)
- {
- return type.GetTypeConstructor () ?? CreateTypeConstructor (type);
- }
-
- MethodDefinition CreateTypeConstructor (TypeDefinition type)
- {
- var cctor = new MethodDefinition (".cctor", MethodAttributes.Private | MethodAttributes.Static | MethodAttributes.SpecialName | MethodAttributes.RTSpecialName, void_type);
- cctor.Body.GetILProcessor ().Emit (OpCodes.Ret);
-
- type.Methods.Add (cctor);
-
- return cctor;
- }
-
- void ProcessConstructors (TypeDefinition type, List<ExportedMethod> exported)
- {
- foreach (MethodDefinition ctor in type.GetConstructors ()) {
- if (!ctor.HasParameters && !ctor.IsStatic) {
- exported.Add (new ExportedMethod (null, ctor));
- continue;
- }
-
- CustomAttribute export;
- if (!TryGetExportAttribute (ctor, out export))
- continue;
-
- exported.Add (new ExportedMethod (export, ctor));
- }
- }
-
- static bool TryGetExportAttribute (MethodDefinition method, out CustomAttribute export)
- {
- export = null;
-
- if (!method.HasCustomAttributes)
- return false;
-
- foreach (CustomAttribute attribute in method.CustomAttributes) {
- if (attribute.AttributeType.FullName != "MonoMac.Foundation.ExportAttribute")
- continue;
-
- export = attribute;
- return true;
- }
-
- return false;
- }
-
- void ProcessMethods (TypeDefinition type, List<ExportedMethod> exported)
- {
- foreach (MethodDefinition method in type.GetMethods ()) {
- CustomAttribute attribute;
- if (TryGetExportAttribute (method, out attribute)) {
- exported.Add (new ExportedMethod (attribute, method));
- continue;
- }
-
- if (!method.IsVirtual)
- continue;
-
- var bases = Annotations.GetBaseMethods (method);
- if (bases == null)
- continue;
-
- foreach (MethodDefinition @base in bases) {
- if (@base.DeclaringType.IsInterface)
- continue;
-
- if (TryGetExportAttribute (@base, out attribute)) {
- exported.Add (new ExportedMethod (attribute, method));
- break;
- }
- }
- }
- }
- }
-}
diff --git a/src/tuner/MonoMac.Tuner/MonoMac.xml b/src/tuner/MonoMac.Tuner/MonoMac.xml
deleted file mode 100644
index 9a078c887..000000000
--- a/src/tuner/MonoMac.Tuner/MonoMac.xml
+++ /dev/null
@@ -1,38 +0,0 @@
-<?xml version="1.0" encoding="utf-8" ?>
-<linker>
- <assembly fullname="MonoMac">
- <namespace fullname="MonoMac.ObjCRuntime" />
- <!--
- <type fullname="MonoMac.ObjCRuntime.Runtime" />
- <type fullname="MonoMac.ObjCRuntime.Class" />
- <type fullname="MonoMac.ObjCRuntime.Selector" />
- <type fullname="MonoMac.ObjCRuntime.NativeConstructorBuilder" />
- <type fullname="MonoMac.ObjCRuntime.NativeImplementationBuilder" />
- <type fullname="MonoMac.ObjCRuntime.NativeMethodBuilder" />
- <type fullname="MonoMac.ObjCRuntime.INativeObject" />
- -->
- <type fullname="MonoMac.Foundation.NSObject" preserve="fields">
- <method name="NativeRelease" />
- <method name="NativeRetain" />
- <method name="Retain" />
- </type>
- <type fullname="MonoMac.Foundation.NSArray" preserve="fields">
- <method name="ArrayFromHandle" />
- <method name="StringArrayFromHandle" />
- <method name="FromNSObjects" />
- <method name="FromStrings" />
- </type>
- <type fullname="MonoMac.Foundation.ExportAttribute" />
- </assembly>
- <assembly fullname="mscorlib">
- <type fullname="System.Runtime.Serialization.FormatterServices">
- <method name="GetUninitializedObject" />
- </type>
- <type fullname="System.Runtime.InteropServices.Marshal">
- <method name="StructureToPtr" />
- </type>
- <type fullname="System.Runtime.InteropServices.MarshalAsAttribute">
- <field name="MarshalTypeRef" />
- </type>
- </assembly>
-</linker>
diff --git a/src/tuner/MonoMac.Tuner/MonoMacProfile.cs b/src/tuner/MonoMac.Tuner/MonoMacProfile.cs
deleted file mode 100644
index 0692e481e..000000000
--- a/src/tuner/MonoMac.Tuner/MonoMacProfile.cs
+++ /dev/null
@@ -1,117 +0,0 @@
-using System;
-using System.Collections.Generic;
-
-using Mono.Tuner;
-
-using Mono.Cecil;
-
-namespace MonoMac.Tuner {
-
- class MonoMacProfile : Profile {
-
- static readonly HashSet<string> Sdk = new HashSet<string> {
- "mscorlib",
- "I18N.CJK",
- "I18N",
- "I18N.MidEast",
- "I18N.Other",
- "I18N.Rare",
- "I18N.West",
- "Microsoft.Build.Engine",
- "Microsoft.Build.Framework",
- "Microsoft.Build.Tasks.v4.0",
- "Microsoft.Build.Utilities.v4.0",
- "Microsoft.CSharp",
- "Microsoft.Web.Infrastructure",
- "Mono.C5",
- "Mono.Cairo",
- "Mono.CodeContracts",
- "Mono.CompilerServices.SymbolWriter",
- "Mono.Configuration.Crypto",
- "Mono.CSharp",
- "Mono.Data.Sqlite",
- "Mono.Data.Tds",
- "Mono.Debugger.Soft",
- "Mono.Http",
- "Mono.Management",
- "Mono.Messaging",
- "Mono.Messaging.RabbitMQ",
- "Mono.Options",
- "Mono.Parallel",
- "Mono.Posix",
- "Mono.Security",
- "Mono.Security.Win32",
- "Mono.Simd",
- "Mono.Tasklets",
- "Mono.Tuner",
- "Mono.WebBrowser",
- "Mono.Web",
- "Novell.Directory.Ldap",
- "Npgsql",
- "OpenSystem.C",
- "PEAPI",
- "System.ComponentModel.Composition",
- "System.ComponentModel.DataAnnotations",
- "System.Configuration",
- "System.Configuration.Install",
- "System.Core",
- "System.Data.DataSetExtensions",
- "System.Data",
- "System.Data.Linq",
- "System.Data.OracleClient",
- "System.Data.Services.Client",
- "System.Data.Services",
- "System.Design",
- "System.DirectoryServices",
- "System",
- "System.Drawing.Design",
- "System.Drawing",
- "System.Dynamic",
- "System.EnterpriseServices",
- "System.IdentityModel",
- "System.IdentityModel.Selectors",
- "System.Management",
- "System.Messaging",
- "System.Net",
- "System.Numerics",
- "System.Runtime.Caching",
- "System.Runtime.DurableInstancing",
- "System.Runtime.Remoting",
- "System.Runtime.Serialization",
- "System.Runtime.Serialization.Formatters.Soap",
- "System.Security",
- "System.ServiceModel.Discovery",
- "System.ServiceModel",
- "System.ServiceModel.Routing",
- "System.ServiceModel.Web",
- "System.ServiceProcess",
- "System.Transactions",
- "System.Web.Abstractions",
- "System.Web.ApplicationServices",
- "System.Web",
- "System.Web.DynamicData",
- "System.Web.Extensions.Design",
- "System.Web.Extensions",
- "System.Web.Routing",
- "System.Web.Services",
- "System.Windows.Forms.DataVisualization",
- "System.Windows.Forms",
- "System.Xaml",
- "System.Xml",
- "System.Xml.Linq",
- "WebMatrix.Data",
- "WindowsBase",
- "Microsoft.VisualBasic",
- };
-
- protected override bool IsSdk (AssemblyDefinition assembly)
- {
- return Sdk.Contains (assembly.Name.Name);
- }
-
- protected override bool IsProduct (AssemblyDefinition assembly)
- {
- return assembly.Name.Name == "MonoMac";
- }
- }
-}
diff --git a/src/tuner/MonoMac.Tuner/RemoveSelectors.cs b/src/tuner/MonoMac.Tuner/RemoveSelectors.cs
deleted file mode 100644
index 0c201aece..000000000
--- a/src/tuner/MonoMac.Tuner/RemoveSelectors.cs
+++ /dev/null
@@ -1,189 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-
-using Mono.Linker;
-using Mono.Linker.Steps;
-
-using Mono.Cecil;
-using Mono.Cecil.Cil;
-
-using Mono.Tuner;
-
-namespace MonoMac.Tuner {
-
- public class RemoveSelectors : IStep {
-
- public void Process (LinkContext context)
- {
- AssemblyDefinition monomac;
- if (!context.TryGetLinkedAssembly ("MonoMac", out monomac))
- return;
-
- foreach (TypeDefinition type in monomac.MainModule.Types) {
- if (!type.IsNSObject ())
- continue;
-
- ProcessNSObject (type);
- }
- }
-
- static void ProcessNSObject (TypeDefinition type)
- {
- var selectors = PopulateSelectors (type);
- if (selectors == null)
- return;
-
- foreach (var method in CollectMethods (type))
- CheckSelectorUsage (method, selectors);
-
- if (selectors.Count == 0)
- return;
-
- PatchStaticConstructor (type, selectors);
- RemoveUnusedSelectors (type, selectors);
- }
-
- static void CheckSelectorUsage (MethodDefinition method, HashSet<FieldDefinition> selectors)
- {
- if (!method.HasBody)
- return;
-
- foreach (Instruction instruction in method.Body.Instructions) {
- switch (instruction.OpCode.OperandType) {
- case OperandType.InlineTok:
- case OperandType.InlineField:
- var field = instruction.Operand as FieldDefinition;
- if (field == null)
- continue;
-
- if (selectors.Contains (field))
- selectors.Remove (field);
-
- break;
- }
- }
- }
-
- static void PatchStaticConstructor (TypeDefinition type, HashSet<FieldDefinition> selectors)
- {
- var cctor = type.GetTypeConstructor ();
- if (cctor == null || !cctor.HasBody)
- return;
-
- var instructions = cctor.Body.Instructions;
-
- for (int i = 0; i < instructions.Count; i++) {
- var instruction = instructions [i];
- if (!IsCreateSelector (instruction, selectors))
- continue;
-
- instructions.RemoveAt (i--);
- instructions.RemoveAt (i--);
- instructions.RemoveAt (i--);
- }
- }
-
- static bool IsCreateSelector (Instruction instruction, HashSet<FieldDefinition> selectors)
- {
- if (instruction.OpCode != OpCodes.Stsfld)
- return false;
-
- var field = instruction.Operand as FieldDefinition;
- if (field == null)
- return false;
-
- if (!selectors.Contains (field))
- return false;
-
- instruction = instruction.Previous;
- if (instruction == null)
- return false;
-
- if (instruction.OpCode != OpCodes.Call)
- return false;
-
- if (!IsRegisterSelector (instruction.Operand as MethodReference))
- return false;
-
- instruction = instruction.Previous;
- if (instruction == null)
- return false;
-
- if (instruction.OpCode != OpCodes.Ldstr)
- return false;
-
- return true;
- }
-
- static bool IsRegisterSelector (MethodReference method)
- {
- if (method == null)
- return false;
-
- if (method.Name != "GetHandle" && method.Name != "sel_registerName")
- return false;
-
- if (method.DeclaringType.FullName != "MonoMac.ObjCRuntime.Selector")
- return false;
-
- return true;
- }
-
- static void RemoveUnusedSelectors (TypeDefinition type, HashSet<FieldDefinition> selectors)
- {
- var fields = type.Fields;
-
- for (int i = 0; i < fields.Count; i++)
- if (selectors.Contains (fields [i]))
- fields.RemoveAt (i--);
- }
-
- static HashSet<FieldDefinition> PopulateSelectors (TypeDefinition type)
- {
- if (!type.HasFields)
- return null;
-
- HashSet<FieldDefinition> selectors = null;
-
- foreach (FieldDefinition field in type.Fields) {
- if (!IsSelector (field))
- continue;
-
- if (selectors == null)
- selectors = new HashSet<FieldDefinition> ();
-
- selectors.Add (field);
- }
-
- return selectors;
- }
-
- static bool IsSelector (FieldDefinition field)
- {
- if (!field.IsStatic)
- return false;
-
- if (field.FieldType.FullName != "System.IntPtr")
- return false;
-
- if (!field.Name.StartsWith ("sel"))
- return false;
-
- return true;
- }
-
- static IEnumerable<MethodDefinition> CollectMethods (TypeDefinition type)
- {
- if (!type.HasMethods)
- yield break;
-
- foreach (MethodDefinition method in type.Methods) {
- if (method.IsStatic && method.IsConstructor)
- continue;
-
- yield return method;
- }
- }
- }
-}
diff --git a/test/ILLink.RoslynAnalyzer.Tests/ILLink.RoslynAnalyzer.Tests.csproj b/test/ILLink.RoslynAnalyzer.Tests/ILLink.RoslynAnalyzer.Tests.csproj
index 07aa8f3d7..18d987223 100644
--- a/test/ILLink.RoslynAnalyzer.Tests/ILLink.RoslynAnalyzer.Tests.csproj
+++ b/test/ILLink.RoslynAnalyzer.Tests/ILLink.RoslynAnalyzer.Tests.csproj
@@ -4,7 +4,6 @@
<Nullable>enable</Nullable>
<LangVersion>latest</LangVersion>
<TargetFramework>net5.0</TargetFramework>
- <DefineConstants>$(DefineConstants);ILLINK</DefineConstants>
</PropertyGroup>
<ItemGroup>
diff --git a/test/ILLink.RoslynAnalyzer.Tests/TestCaseUtils.cs b/test/ILLink.RoslynAnalyzer.Tests/TestCaseUtils.cs
index c62c2d762..d334559bf 100644
--- a/test/ILLink.RoslynAnalyzer.Tests/TestCaseUtils.cs
+++ b/test/ILLink.RoslynAnalyzer.Tests/TestCaseUtils.cs
@@ -186,7 +186,7 @@ In diagnostics:
return MSBuildProperties.Select (msbp => ($"build_property.{msbp}", "true")).ToArray ();
}
- internal static void GetDirectoryPaths (out string rootSourceDirectory, out string testAssemblyPath, [CallerFilePath] string thisFile = null)
+ internal static void GetDirectoryPaths (out string rootSourceDirectory, out string testAssemblyPath)
{
#if DEBUG
@@ -194,28 +194,12 @@ In diagnostics:
#else
var configDirectoryName = "Release";
#endif
-
-#if NET5_0
- var tfm = "net5.0";
-#elif NET471
- var tfm = "net471";
-#else
- var tfm = "";
-#endif
-
-#if ILLINK
- // Deterministic builds sanitize source paths, so CallerFilePathAttribute gives an incorrect path.
- // Instead, get the testcase dll based on the working directory of the test runner.
+ const string tfm = "net5.0";
// working directory is artifacts/bin/Mono.Linker.Tests/<config>/<tfm>
var artifactsBinDir = Path.Combine (Directory.GetCurrentDirectory (), "..", "..", "..");
rootSourceDirectory = Path.GetFullPath (Path.Combine (artifactsBinDir, "..", "..", "test", "Mono.Linker.Tests.Cases"));
testAssemblyPath = Path.GetFullPath (Path.Combine (artifactsBinDir, "ILLink.RoslynAnalyzer.Tests", configDirectoryName, tfm));
-#else
- var thisDirectory = Path.GetDirectoryName (thisFile);
- rootSourceDirectory = Path.GetFullPath (Path.Combine (thisDirectory, "..", "..", "Mono.Linker.Tests.Cases"));
- testCaseAssemblyPath = Path.GetFullPath (Path.Combine (rootSourceDirectory, "bin", configDirectoryName, tfm));
-#endif // ILLINK
}
}
}
diff --git a/test/Mono.Linker.Tests.Cases.Expectations/Mono.Linker.Tests.Cases.Expectations.csproj b/test/Mono.Linker.Tests.Cases.Expectations/Mono.Linker.Tests.Cases.Expectations.csproj
index 211c1540b..c760b181c 100644
--- a/test/Mono.Linker.Tests.Cases.Expectations/Mono.Linker.Tests.Cases.Expectations.csproj
+++ b/test/Mono.Linker.Tests.Cases.Expectations/Mono.Linker.Tests.Cases.Expectations.csproj
@@ -5,15 +5,8 @@
<RunAnalyzers>false</RunAnalyzers>
</PropertyGroup>
- <PropertyGroup Condition="'$(MonoBuild)' == ''">
+ <PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
</PropertyGroup>
- <PropertyGroup Condition="'$(MonoBuild)' != ''">
- <TargetFramework>net471</TargetFramework>
- </PropertyGroup>
-
- <ItemGroup Condition="'$(MonoBuild)' == ''">
- <Compile Remove="System.Diagnostics.CodeAnalysis\*.cs" />
- </ItemGroup>
</Project>
diff --git a/test/Mono.Linker.Tests.Cases.Expectations/System.Diagnostics.CodeAnalysis/DynamicDependencyAttribute.cs b/test/Mono.Linker.Tests.Cases.Expectations/System.Diagnostics.CodeAnalysis/DynamicDependencyAttribute.cs
deleted file mode 100644
index 107521234..000000000
--- a/test/Mono.Linker.Tests.Cases.Expectations/System.Diagnostics.CodeAnalysis/DynamicDependencyAttribute.cs
+++ /dev/null
@@ -1,136 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-
-#nullable enable
-
-namespace System.Diagnostics.CodeAnalysis
-{
- /// <summary>
- /// States a dependency that one member has on another.
- /// </summary>
- /// <remarks>
- /// This can be used to inform tooling of a dependency that is otherwise not evident purely from
- /// metadata and IL, for example a member relied on via reflection.
- /// </remarks>
- /// <remarks>
- /// This is a copy of the enum definition in the framework at https://github.com/dotnet/runtime/blob/master/src/libraries/System.Private.CoreLib/src/System/Diagnostics/CodeAnalysis/DynamicDependencyAttribute.cs
- /// </remarks>
- [AttributeUsage (
- AttributeTargets.Constructor | AttributeTargets.Field | AttributeTargets.Method,
- AllowMultiple = true, Inherited = false)]
- public sealed class DynamicDependencyAttribute : Attribute
- {
- /// <summary>
- /// Initializes a new instance of the <see cref="DynamicDependencyAttribute"/> class
- /// with the specified signature of a member on the same type as the consumer.
- /// </summary>
- /// <param name="memberSignature">The signature of the member depended on.</param>
- public DynamicDependencyAttribute (string memberSignature)
- {
- MemberSignature = memberSignature;
- }
-
- /// <summary>
- /// Initializes a new instance of the <see cref="DynamicDependencyAttribute"/> class
- /// with the specified signature of a member on a <see cref="System.Type"/>.
- /// </summary>
- /// <param name="memberSignature">The signature of the member depended on.</param>
- /// <param name="type">The <see cref="System.Type"/> containing <paramref name="memberSignature"/>.</param>
- public DynamicDependencyAttribute (string memberSignature, Type type)
- {
- MemberSignature = memberSignature;
- Type = type;
- }
-
- /// <summary>
- /// Initializes a new instance of the <see cref="DynamicDependencyAttribute"/> class
- /// with the specified signature of a member on a type in an assembly.
- /// </summary>
- /// <param name="memberSignature">The signature of the member depended on.</param>
- /// <param name="typeName">The full name of the type containing the specified member.</param>
- /// <param name="assemblyName">The assembly name of the type containing the specified member.</param>
- public DynamicDependencyAttribute (string memberSignature, string typeName, string assemblyName)
- {
- MemberSignature = memberSignature;
- TypeName = typeName;
- AssemblyName = assemblyName;
- }
-
- /// <summary>
- /// Initializes a new instance of the <see cref="DynamicDependencyAttribute"/> class
- /// with the specified types of members on a <see cref="System.Type"/>.
- /// </summary>
- /// <param name="memberTypes">The types of members depended on.</param>
- /// <param name="type">The <see cref="System.Type"/> containing the specified members.</param>
- public DynamicDependencyAttribute (DynamicallyAccessedMemberTypes memberTypes, Type type)
- {
- MemberTypes = memberTypes;
- Type = type;
- }
-
- /// <summary>
- /// Initializes a new instance of the <see cref="DynamicDependencyAttribute"/> class
- /// with the specified types of members on a type in an assembly.
- /// </summary>
- /// <param name="memberTypes">The types of members depended on.</param>
- /// <param name="typeName">The full name of the type containing the specified members.</param>
- /// <param name="assemblyName">The assembly name of the type containing the specified members.</param>
- public DynamicDependencyAttribute (DynamicallyAccessedMemberTypes memberTypes, string typeName, string assemblyName)
- {
- MemberTypes = memberTypes;
- TypeName = typeName;
- AssemblyName = assemblyName;
- }
-
- /// <summary>
- /// Gets the signature of the member depended on.
- /// </summary>
- /// <remarks>
- /// Either <see cref="MemberSignature"/> must be a valid string or <see cref="MemberTypes"/>
- /// must not equal <see cref="DynamicallyAccessedMemberTypes.None"/>, but not both.
- /// </remarks>
- public string? MemberSignature { get; }
-
- /// <summary>
- /// Gets the <see cref="DynamicallyAccessedMemberTypes"/> which specifies the type
- /// of members depended on.
- /// </summary>
- /// <remarks>
- /// Either <see cref="MemberSignature"/> must be a valid string or <see cref="MemberTypes"/>
- /// must not equal <see cref="DynamicallyAccessedMemberTypes.None"/>, but not both.
- /// </remarks>
- public DynamicallyAccessedMemberTypes MemberTypes { get; }
-
- /// <summary>
- /// Gets the <see cref="System.Type"/> containing the specified member.
- /// </summary>
- /// <remarks>
- /// If neither <see cref="Type"/> nor <see cref="TypeName"/> are specified,
- /// the type of the consumer is assumed.
- /// </remarks>
- public Type? Type { get; }
-
- /// <summary>
- /// Gets the full name of the type containing the specified member.
- /// </summary>
- /// <remarks>
- /// If neither <see cref="Type"/> nor <see cref="TypeName"/> are specified,
- /// the type of the consumer is assumed.
- /// </remarks>
- public string? TypeName { get; }
-
- /// <summary>
- /// Gets the assembly name of the specified type.
- /// </summary>
- /// <remarks>
- /// <see cref="AssemblyName"/> is only valid when <see cref="TypeName"/> is specified.
- /// </remarks>
- public string? AssemblyName { get; }
-
- /// <summary>
- /// Gets or sets the condition in which the dependency is applicable, e.g. "DEBUG".
- /// </summary>
- public string? Condition { get; set; }
- }
-}
diff --git a/test/Mono.Linker.Tests.Cases.Expectations/System.Diagnostics.CodeAnalysis/DynamicallyAccessedMemberTypes.cs b/test/Mono.Linker.Tests.Cases.Expectations/System.Diagnostics.CodeAnalysis/DynamicallyAccessedMemberTypes.cs
deleted file mode 100644
index 74949a1b9..000000000
--- a/test/Mono.Linker.Tests.Cases.Expectations/System.Diagnostics.CodeAnalysis/DynamicallyAccessedMemberTypes.cs
+++ /dev/null
@@ -1,94 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-
-namespace System.Diagnostics.CodeAnalysis
-{
- /// <summary>
- /// Specifies the types of members that are dynamically accessed.
- ///
- /// This enumeration has a <see cref="FlagsAttribute"/> attribute that allows a
- /// bitwise combination of its member values.
- /// </summary>
- /// <remarks>
- /// This is a copy of the enum definition in the framework at https://github.com/dotnet/runtime/blob/master/src/libraries/System.Private.CoreLib/src/System/Diagnostics/CodeAnalysis/DynamicallyAccessedMemberTypes.cs
- /// </remarks>
- [Flags]
- public enum DynamicallyAccessedMemberTypes
- {
- /// <summary>
- /// Specifies no members.
- /// </summary>
- None = 0,
-
- /// <summary>
- /// Specifies the default, parameterless public constructor.
- /// </summary>
- PublicParameterlessConstructor = 0x0001,
-
- /// <summary>
- /// Specifies all public constructors.
- /// </summary>
- PublicConstructors = 0x0002 | PublicParameterlessConstructor,
-
- /// <summary>
- /// Specifies all non-public constructors.
- /// </summary>
- NonPublicConstructors = 0x0004,
-
- /// <summary>
- /// Specifies all public methods.
- /// </summary>
- PublicMethods = 0x0008,
-
- /// <summary>
- /// Specifies all non-public methods.
- /// </summary>
- NonPublicMethods = 0x0010,
-
- /// <summary>
- /// Specifies all public fields.
- /// </summary>
- PublicFields = 0x0020,
-
- /// <summary>
- /// Specifies all non-public fields.
- /// </summary>
- NonPublicFields = 0x0040,
-
- /// <summary>
- /// Specifies all public nested types.
- /// </summary>
- PublicNestedTypes = 0x0080,
-
- /// <summary>
- /// Specifies all non-public nested types.
- /// </summary>
- NonPublicNestedTypes = 0x0100,
-
- /// <summary>
- /// Specifies all public properties.
- /// </summary>
- PublicProperties = 0x0200,
-
- /// <summary>
- /// Specifies all non-public properties.
- /// </summary>
- NonPublicProperties = 0x0400,
-
- /// <summary>
- /// Specifies all public events.
- /// </summary>
- PublicEvents = 0x0800,
-
- /// <summary>
- /// Specifies all non-public events.
- /// </summary>
- NonPublicEvents = 0x1000,
-
- /// <summary>
- /// Specifies all members.
- /// </summary>
- All = ~None
- }
-}
diff --git a/test/Mono.Linker.Tests.Cases.Expectations/System.Diagnostics.CodeAnalysis/DynamicallyAccessedMembersAttribute.cs b/test/Mono.Linker.Tests.Cases.Expectations/System.Diagnostics.CodeAnalysis/DynamicallyAccessedMembersAttribute.cs
deleted file mode 100644
index b7f16b961..000000000
--- a/test/Mono.Linker.Tests.Cases.Expectations/System.Diagnostics.CodeAnalysis/DynamicallyAccessedMembersAttribute.cs
+++ /dev/null
@@ -1,45 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-
-namespace System.Diagnostics.CodeAnalysis
-{
- /// <summary>
- /// Indicates that certain members on a specified <see cref="Type"/> are accessed dynamically,
- /// for example through <see cref="System.Reflection"/>.
- /// </summary>
- /// <remarks>
- /// This allows tools to understand which members are being accessed during the execution
- /// of a program.
- ///
- /// This attribute is valid on members whose type is <see cref="Type"/> or <see cref="string"/>.
- ///
- /// When this attribute is applied to a location of type <see cref="string"/>, the assumption is
- /// that the string represents a fully qualified type name.
- ///
- /// This is a copy of the code from framework at https://github.com/dotnet/runtime/blob/master/src/libraries/System.Private.CoreLib/src/System/Diagnostics/CodeAnalysis/DynamicallyAccessedMembersAttribute.cs
- /// </remarks>
- [AttributeUsage (
- AttributeTargets.Field | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter |
- AttributeTargets.Parameter | AttributeTargets.Property |
- AttributeTargets.Method, // This is used only to mark the "this" parameter - it should not appear in public API for this attribute (and we don't support it on anything but System.Type)
- Inherited = false)]
- public sealed class DynamicallyAccessedMembersAttribute : Attribute
- {
- /// <summary>
- /// Initializes a new instance of the <see cref="DynamicallyAccessedMembersAttribute"/> class
- /// with the specified member types.
- /// </summary>
- /// <param name="memberTypes">The types of members dynamically accessed.</param>
- public DynamicallyAccessedMembersAttribute (DynamicallyAccessedMemberTypes memberTypes)
- {
- MemberTypes = memberTypes;
- }
-
- /// <summary>
- /// Gets the <see cref="DynamicallyAccessedMemberTypes"/> which specifies the type
- /// of members dynamically accessed.
- /// </summary>
- public DynamicallyAccessedMemberTypes MemberTypes { get; }
- }
-}
diff --git a/test/Mono.Linker.Tests.Cases.Expectations/System.Diagnostics.CodeAnalysis/RequiresUnreferencedCodeAttribute.cs b/test/Mono.Linker.Tests.Cases.Expectations/System.Diagnostics.CodeAnalysis/RequiresUnreferencedCodeAttribute.cs
deleted file mode 100644
index 11e56f543..000000000
--- a/test/Mono.Linker.Tests.Cases.Expectations/System.Diagnostics.CodeAnalysis/RequiresUnreferencedCodeAttribute.cs
+++ /dev/null
@@ -1,43 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-
-namespace System.Diagnostics.CodeAnalysis
-{
- /// <summary>
- /// Indicates that the specified method requires dynamic access to code that is not referenced
- /// statically, for example through <see cref="System.Reflection"/>.
- /// </summary>
- /// <remarks>
- /// This allows tools to understand which methods are unsafe to call when removing unreferenced
- /// code from an application.
- ///
- /// This is a copy of the attribute from dotnet/runtime repo - once linker runs on .NET 5 this should be removed.
- /// </remarks>
- [AttributeUsage (AttributeTargets.Method | AttributeTargets.Constructor, Inherited = false)]
- public sealed class RequiresUnreferencedCodeAttribute : Attribute
- {
- /// <summary>
- /// Initializes a new instance of the <see cref="RequiresUnreferencedCodeAttribute"/> class
- /// with the specified message.
- /// </summary>
- /// <param name="message">
- /// A message that contains information about the usage of unreferenced code.
- /// </param>
- public RequiresUnreferencedCodeAttribute (string message)
- {
- Message = message;
- }
-
- /// <summary>
- /// Gets a message that contains information about the usage of unreferenced code.
- /// </summary>
- public string Message { get; }
-
- /// <summary>
- /// Gets or sets an optional URL that contains more information about the method,
- /// why it requries unreferenced code, and what options a consumer has to deal with it.
- /// </summary>
- public string Url { get; set; }
- }
-} \ No newline at end of file
diff --git a/test/Mono.Linker.Tests.Cases.Expectations/System.Diagnostics.CodeAnalysis/UnconditionalSuppressMessageAttribute.cs b/test/Mono.Linker.Tests.Cases.Expectations/System.Diagnostics.CodeAnalysis/UnconditionalSuppressMessageAttribute.cs
deleted file mode 100644
index 15aca6fe4..000000000
--- a/test/Mono.Linker.Tests.Cases.Expectations/System.Diagnostics.CodeAnalysis/UnconditionalSuppressMessageAttribute.cs
+++ /dev/null
@@ -1,93 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-
-namespace System.Diagnostics.CodeAnalysis
-{
- /// <summary>
- /// Suppresses reporting of a specific rule violation, allowing multiple suppressions on a
- /// single code artifact.
- /// </summary>
- /// <remarks>
- /// <see cref="UnconditionalSuppressMessageAttribute"/> is different than
- /// <see cref="SuppressMessageAttribute"/> in that it doesn't have a
- /// <see cref="ConditionalAttribute"/>. So it is always preserved in the compiled assembly.
- ///
- /// This file was copied from the dotnet/runtime repo:
- /// https://github.com/dotnet/runtime/blob/master/src/libraries/System.Private.CoreLib/src/System/Diagnostics/CodeAnalysis/UnconditionalSuppressMessageAttribute.cs
- ///
- /// This file should be removed when we start using .NET 5
- /// The nullable reference types where changed to optional properties due to monobuild
- /// using C# v.7.3., which is incompatible with the former feature.
- /// </remarks>
- [AttributeUsage (AttributeTargets.All, Inherited = false, AllowMultiple = true)]
- public sealed class UnconditionalSuppressMessageAttribute : Attribute
- {
- /// <summary>
- /// Initializes a new instance of the <see cref="UnconditionalSuppressMessageAttribute"/>
- /// class, specifying the category of the tool and the identifier for an analysis rule.
- /// </summary>
- /// <param name="category">The category for the attribute.</param>
- /// <param name="checkId">The identifier of the analysis rule the attribute applies to.</param>
- public UnconditionalSuppressMessageAttribute (string category, string checkId)
- {
- Category = category;
- CheckId = checkId;
- }
-
- /// <summary>
- /// Gets the category identifying the classification of the attribute.
- /// </summary>
- /// <remarks>
- /// The <see cref="Category"/> property describes the tool or tool analysis category
- /// for which a message suppression attribute applies.
- /// </remarks>
- public string Category { get; }
-
- /// <summary>
- /// Gets the identifier of the analysis tool rule to be suppressed.
- /// </summary>
- /// <remarks>
- /// Concatenated together, the <see cref="Category"/> and <see cref="CheckId"/>
- /// properties form a unique check identifier.
- /// </remarks>
- public string CheckId { get; }
-
- /// <summary>
- /// Gets or sets the scope of the code that is relevant for the attribute.
- /// </summary>
- /// <remarks>
- /// The Scope property is an optional argument that specifies the metadata scope for which
- /// the attribute is relevant.
- /// </remarks>
- public string Scope { get; set; } = null;
-
- /// <summary>
- /// Gets or sets a fully qualified path that represents the target of the attribute.
- /// </summary>
- /// <remarks>
- /// The <see cref="Target"/> property is an optional argument identifying the analysis target
- /// of the attribute. An example value is "System.IO.Stream.ctor():System.Void".
- /// Because it is fully qualified, it can be long, particularly for targets such as parameters.
- /// The analysis tool user interface should be capable of automatically formatting the parameter.
- /// </remarks>
- public string Target { get; set; } = null;
-
- /// <summary>
- /// Gets or sets an optional argument expanding on exclusion criteria.
- /// </summary>
- /// <remarks>
- /// The <see cref="MessageId "/> property is an optional argument that specifies additional
- /// exclusion where the literal metadata target is not sufficiently precise. For example,
- /// the <see cref="UnconditionalSuppressMessageAttribute"/> cannot be applied within a method,
- /// and it may be desirable to suppress a violation against a statement in the method that will
- /// give a rule violation, but not against all statements in the method.
- /// </remarks>
- public string MessageId { get; set; } = null;
-
- /// <summary>
- /// Gets or sets the justification for suppressing the code analysis message.
- /// </summary>
- public string Justification { get; set; } = null;
- }
-} \ No newline at end of file
diff --git a/test/Mono.Linker.Tests.Cases/Attributes/OnlyKeepUsed/NullableOnConstraints.cs b/test/Mono.Linker.Tests.Cases/Attributes/OnlyKeepUsed/NullableOnConstraints.cs
index 5d6eacb06..3cfb0bcd9 100644
--- a/test/Mono.Linker.Tests.Cases/Attributes/OnlyKeepUsed/NullableOnConstraints.cs
+++ b/test/Mono.Linker.Tests.Cases/Attributes/OnlyKeepUsed/NullableOnConstraints.cs
@@ -5,9 +5,6 @@ using Mono.Linker.Tests.Cases.Expectations.Metadata;
namespace Mono.Linker.Tests.Cases.Attributes.OnlyKeepUsed
{
-#if ILLINK
- [IgnoreTestCase ("Ignored for illink for some reason")]
-#endif
[SetupCSharpCompilerToUse ("csc")]
[SetupCompileArgument ("/langversion:8.0")]
[SetupLinkerArgument ("--used-attrs-only", "true")]
diff --git a/test/Mono.Linker.Tests.Cases/DataFlow/IReflectDataflow.cs b/test/Mono.Linker.Tests.Cases/DataFlow/IReflectDataflow.cs
index c45e5478f..bdfb4f492 100644
--- a/test/Mono.Linker.Tests.Cases/DataFlow/IReflectDataflow.cs
+++ b/test/Mono.Linker.Tests.Cases/DataFlow/IReflectDataflow.cs
@@ -8,11 +8,7 @@ namespace Mono.Linker.Tests.Cases.DataFlow
{
// Hits what appears to be a bug in the tool
// Could not initialize vtable of class(0x02000007) .MyReflect due to VTable setup of type Mono.Linker.Tests.Cases.DataFlow.IReflectDataflow+MyReflect failed assembly:/tmp/linker_tests/output/test.exe type:MyReflect member:(null)
-#if ILLINK
- [SkipPeVerify (SkipPeVerifyForToolchian.Pedump)]
-#else
[SkipPeVerify]
-#endif
class IReflectDataflow
{
[ExpectBodyModified]
diff --git a/test/Mono.Linker.Tests.Cases/LinkAttributes/LinkerAttributeRemoval.cs b/test/Mono.Linker.Tests.Cases/LinkAttributes/LinkerAttributeRemoval.cs
index 5bc04b1fc..6cafb467a 100644
--- a/test/Mono.Linker.Tests.Cases/LinkAttributes/LinkerAttributeRemoval.cs
+++ b/test/Mono.Linker.Tests.Cases/LinkAttributes/LinkerAttributeRemoval.cs
@@ -15,13 +15,11 @@ namespace Mono.Linker.Tests.Cases.LinkAttributes
[SetupLinkAttributesFile ("LinkerAttributeRemoval.xml")]
[IgnoreLinkAttributes (false)]
-#if !ILLINK
- [Reference ("System.dll")]
-#endif
[SetupCompileBefore ("attribute.dll", new[] { "Dependencies/LinkerAttributeRemovalAttributeToRemove.cs" })]
[SetupCompileBefore ("copyattribute.dll", new[] { "Dependencies/LinkerAttributeRemovalAttributeFromCopyAssembly.cs" })]
[SetupLinkerAction ("copy", "copyattribute")]
-#if !ILLINK
+#if !NETCOREAPP
+ [Reference ("System.dll")]
[SetupCompileBefore ("copyassembly.dll", new[] { "Dependencies/LinkerAttributeRemovalCopyAssembly.cs" }, references: new[] { "System.dll", "attribute.dll" })]
#else
[SetupCompileBefore ("copyassembly.dll", new[] { "Dependencies/LinkerAttributeRemovalCopyAssembly.cs" }, references: new[] { "attribute.dll" })]
diff --git a/test/Mono.Linker.Tests.Cases/Mono.Linker.Tests.Cases.csproj b/test/Mono.Linker.Tests.Cases/Mono.Linker.Tests.Cases.csproj
index 6d73b707c..735aef42a 100644
--- a/test/Mono.Linker.Tests.Cases/Mono.Linker.Tests.Cases.csproj
+++ b/test/Mono.Linker.Tests.Cases/Mono.Linker.Tests.Cases.csproj
@@ -10,13 +10,8 @@
<RunAnalyzers>false</RunAnalyzers>
</PropertyGroup>
- <PropertyGroup Condition="'$(MonoBuild)' == ''">
+ <PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
- <DefineConstants>$(DefineConstants);ILLINK</DefineConstants>
- </PropertyGroup>
-
- <PropertyGroup Condition="'$(MonoBuild)' != ''">
- <TargetFramework>net471</TargetFramework>
</PropertyGroup>
<ItemGroup>
@@ -70,7 +65,7 @@
<EmbeddedResource Include="LinkXml\CanPreserveExcludedFeatureCom.xml" />
</ItemGroup>
- <ItemGroup Condition="'$(MonoBuild)' == ''">
+ <ItemGroup>
<PackageReference Include="System.Security.Permissions" Version="4.5.0" />
<PackageReference Include="NUnit" Version="3.6.1" />
<PackageReference Include="NUnit.ConsoleRunner" Version="3.6.1" />
diff --git a/test/Mono.Linker.Tests.Cases/UnreachableBlock/SizeOfInConditions.cs b/test/Mono.Linker.Tests.Cases/UnreachableBlock/SizeOfInConditions.cs
index fffd2c268..0e0c1ef2a 100644
--- a/test/Mono.Linker.Tests.Cases/UnreachableBlock/SizeOfInConditions.cs
+++ b/test/Mono.Linker.Tests.Cases/UnreachableBlock/SizeOfInConditions.cs
@@ -4,7 +4,7 @@ using Mono.Linker.Tests.Cases.Expectations.Metadata;
namespace Mono.Linker.Tests.Cases.UnreachableBlock
{
-#if ILLINK
+#if NETCOREAPP
[SetupLinkerSubstitutionFile ("SizeOfInConditions.netcore.xml")]
#else
[SetupLinkerSubstitutionFile ("SizeOfInConditions.net_4_x.xml")]
diff --git a/test/Mono.Linker.Tests.Cases/Warnings/Individual/CanGenerateWarningSuppressionFileCSharp.cs b/test/Mono.Linker.Tests.Cases/Warnings/Individual/CanGenerateWarningSuppressionFileCSharp.cs
index 374eaeacf..39ba5b3aa 100644
--- a/test/Mono.Linker.Tests.Cases/Warnings/Individual/CanGenerateWarningSuppressionFileCSharp.cs
+++ b/test/Mono.Linker.Tests.Cases/Warnings/Individual/CanGenerateWarningSuppressionFileCSharp.cs
@@ -8,11 +8,9 @@ using Mono.Linker.Tests.Cases.Warnings.Dependencies;
namespace Mono.Linker.Tests.Cases.Warnings.Individual
{
-#if !ILLINK
- [Reference ("System.Core.dll")]
-#endif
[SetupLinkerCoreAction ("skip")]
-#if !ILLINK
+#if !NETCOREAPP
+ [Reference ("System.Core.dll")]
[SetupCompileBefore ("library.dll", new[] { typeof (TriggerWarnings_Lib) }, new[] { "System.Core.dll" })]
#else
[SetupCompileBefore ("library.dll", new[] { typeof (TriggerWarnings_Lib) })]
diff --git a/test/Mono.Linker.Tests.Cases/Warnings/Individual/CanGenerateWarningSuppressionFileXml.cs b/test/Mono.Linker.Tests.Cases/Warnings/Individual/CanGenerateWarningSuppressionFileXml.cs
index 1e942ea90..e021fae44 100644
--- a/test/Mono.Linker.Tests.Cases/Warnings/Individual/CanGenerateWarningSuppressionFileXml.cs
+++ b/test/Mono.Linker.Tests.Cases/Warnings/Individual/CanGenerateWarningSuppressionFileXml.cs
@@ -5,7 +5,7 @@ using Mono.Linker.Tests.Cases.Warnings.Dependencies;
namespace Mono.Linker.Tests.Cases.Warnings.Individual
{
[SetupLinkerCoreAction ("skip")]
-#if !ILLINK
+#if !NETCOREAPP
[SetupCompileBefore ("library.dll", new[] { typeof (TriggerWarnings_Lib) }, new[] { "System.Core.dll" })]
#else
[SetupCompileBefore ("library.dll", new[] { typeof (TriggerWarnings_Lib) })]
diff --git a/test/Mono.Linker.Tests.Cases/Warnings/Individual/WarningsAreSorted.cs b/test/Mono.Linker.Tests.Cases/Warnings/Individual/WarningsAreSorted.cs
index faeef0628..0604926ef 100644
--- a/test/Mono.Linker.Tests.Cases/Warnings/Individual/WarningsAreSorted.cs
+++ b/test/Mono.Linker.Tests.Cases/Warnings/Individual/WarningsAreSorted.cs
@@ -13,7 +13,7 @@ namespace Mono.Linker.Tests.Cases.Warnings.Individual
{
[SkipRemainingErrorsValidation]
[SetupLinkerCoreAction ("skip")]
-#if !ILLINK
+#if !NETCOREAPP
[SetupCompileBefore ("library.dll", new[] { typeof (TriggerWarnings_Lib) }, new[] { "System.Core.dll" })]
#else
[SetupCompileBefore ("library.dll", new[] { typeof (TriggerWarnings_Lib) })]
diff --git a/test/Mono.Linker.Tests.Cases/Warnings/WarningSuppression/AddSuppressionsBeforeAttributeRemoval.cs b/test/Mono.Linker.Tests.Cases/Warnings/WarningSuppression/AddSuppressionsBeforeAttributeRemoval.cs
index 55ba8ee23..0b8fe2311 100644
--- a/test/Mono.Linker.Tests.Cases/Warnings/WarningSuppression/AddSuppressionsBeforeAttributeRemoval.cs
+++ b/test/Mono.Linker.Tests.Cases/Warnings/WarningSuppression/AddSuppressionsBeforeAttributeRemoval.cs
@@ -6,7 +6,7 @@ using Mono.Linker.Tests.Cases.Expectations.Metadata;
namespace Mono.Linker.Tests.Cases.Warnings.WarningSuppression
{
-#if !ILLINK
+#if !NETCOREAPP
[Reference ("System.Core.dll")]
#endif
[SkipKeptItemsValidation]
diff --git a/test/Mono.Linker.Tests.Cases/Warnings/WarningSuppression/SuppressWarningsInAssembly.cs b/test/Mono.Linker.Tests.Cases/Warnings/WarningSuppression/SuppressWarningsInAssembly.cs
index a2457ba40..9aacd9c8e 100644
--- a/test/Mono.Linker.Tests.Cases/Warnings/WarningSuppression/SuppressWarningsInAssembly.cs
+++ b/test/Mono.Linker.Tests.Cases/Warnings/WarningSuppression/SuppressWarningsInAssembly.cs
@@ -8,7 +8,7 @@ using Mono.Linker.Tests.Cases.Expectations.Metadata;
namespace Mono.Linker.Tests.Cases.Warnings.WarningSuppression
{
-#if !ILLINK
+#if !NETCOREAPP
[Reference ("System.Core.dll")]
#endif
[SkipKeptItemsValidation]
diff --git a/test/Mono.Linker.Tests.Cases/Warnings/WarningSuppression/SuppressWarningsInMembersAndTypes.cs b/test/Mono.Linker.Tests.Cases/Warnings/WarningSuppression/SuppressWarningsInMembersAndTypes.cs
index a26a80dd0..1b19ef3b7 100644
--- a/test/Mono.Linker.Tests.Cases/Warnings/WarningSuppression/SuppressWarningsInMembersAndTypes.cs
+++ b/test/Mono.Linker.Tests.Cases/Warnings/WarningSuppression/SuppressWarningsInMembersAndTypes.cs
@@ -6,7 +6,7 @@ using Mono.Linker.Tests.Cases.Expectations.Metadata;
namespace Mono.Linker.Tests.Cases.Warnings.WarningSuppression
{
-#if !ILLINK
+#if !NETCOREAPP
[Reference ("System.Core.dll")]
#endif
[SkipKeptItemsValidation]
diff --git a/test/Mono.Linker.Tests.Cases/Warnings/WarningSuppression/SuppressWarningsInMembersAndTypesUsingTarget.cs b/test/Mono.Linker.Tests.Cases/Warnings/WarningSuppression/SuppressWarningsInMembersAndTypesUsingTarget.cs
index fa22d8431..7fcbc85a2 100644
--- a/test/Mono.Linker.Tests.Cases/Warnings/WarningSuppression/SuppressWarningsInMembersAndTypesUsingTarget.cs
+++ b/test/Mono.Linker.Tests.Cases/Warnings/WarningSuppression/SuppressWarningsInMembersAndTypesUsingTarget.cs
@@ -12,7 +12,7 @@ using Mono.Linker.Tests.Cases.Expectations.Metadata;
namespace Mono.Linker.Tests.Cases.Warnings.WarningSuppression
{
-#if !ILLINK
+#if !NETCOREAPP
[Reference ("System.Core.dll")]
#endif
[SkipKeptItemsValidation]
diff --git a/test/Mono.Linker.Tests.Cases/Warnings/WarningSuppression/SuppressWarningsInModule.cs b/test/Mono.Linker.Tests.Cases/Warnings/WarningSuppression/SuppressWarningsInModule.cs
index 301252af6..7ecaef5a7 100644
--- a/test/Mono.Linker.Tests.Cases/Warnings/WarningSuppression/SuppressWarningsInModule.cs
+++ b/test/Mono.Linker.Tests.Cases/Warnings/WarningSuppression/SuppressWarningsInModule.cs
@@ -8,7 +8,7 @@ using Mono.Linker.Tests.Cases.Expectations.Metadata;
namespace Mono.Linker.Tests.Cases.Warnings.WarningSuppression
{
-#if !ILLINK
+#if !NETCOREAPP
[Reference ("System.Core.dll")]
#endif
[SkipKeptItemsValidation]
diff --git a/test/Mono.Linker.Tests.Cases/Warnings/WarningSuppression/SuppressWarningsUsingTargetViaXml.cs b/test/Mono.Linker.Tests.Cases/Warnings/WarningSuppression/SuppressWarningsUsingTargetViaXml.cs
index 1b4aef0e5..1b33f6a4c 100644
--- a/test/Mono.Linker.Tests.Cases/Warnings/WarningSuppression/SuppressWarningsUsingTargetViaXml.cs
+++ b/test/Mono.Linker.Tests.Cases/Warnings/WarningSuppression/SuppressWarningsUsingTargetViaXml.cs
@@ -14,12 +14,9 @@ namespace Mono.Linker.Tests.Cases.Warnings.WarningSuppression
// that assembly is not yet loaded into the closure in the linker, so it won't find the attribute type.
#if NETCOREAPP
[SetupLinkAttributesFile ("SuppressWarningsUsingTargetViaXml.netcore.xml")]
-#else
- [SetupLinkAttributesFile ("SuppressWarningsUsingTargetViaXml.mono.xml")]
-#endif
-#if !ILLINK
[SetupCompileBefore ("library.dll", new[] { typeof (TriggerWarnings_Lib) }, new[] { "System.Core.dll" })]
#else
+ [SetupLinkAttributesFile ("SuppressWarningsUsingTargetViaXml.mono.xml")]
[SetupCompileBefore ("library.dll", new[] { typeof (TriggerWarnings_Lib) })]
#endif
diff --git a/test/Mono.Linker.Tests/Mono.Linker.Tests.csproj b/test/Mono.Linker.Tests/Mono.Linker.Tests.csproj
index c9136c801..0302b28ff 100644
--- a/test/Mono.Linker.Tests/Mono.Linker.Tests.csproj
+++ b/test/Mono.Linker.Tests/Mono.Linker.Tests.csproj
@@ -6,16 +6,11 @@
<RunAnalyzers>false</RunAnalyzers>
</PropertyGroup>
- <PropertyGroup Condition="'$(MonoBuild)' == ''">
+ <PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
- <DefineConstants>$(DefineConstants);ILLINK</DefineConstants>
<DefineConstants Condition="'$(Configuration)' == 'Debug'">$(DefineConstants);DEBUG</DefineConstants>
</PropertyGroup>
- <PropertyGroup Condition="'$(MonoBuild)' != ''">
- <TargetFramework>net471</TargetFramework>
- </PropertyGroup>
-
<ItemGroup>
<Folder Include="Properties\" />
<Folder Include="TestCasesRunner\" />
@@ -30,7 +25,7 @@
<ProjectReference Include="..\Mono.Linker.Tests.Cases.Expectations\Mono.Linker.Tests.Cases.Expectations.csproj" />
</ItemGroup>
- <ItemGroup Condition="'$(MonoBuild)' == ''">
+ <ItemGroup>
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="3.8.0" />
<PackageReference Include="nunit" Version="3.12.0" />
<PackageReference Include="NUnit3TestAdapter" Version="3.17.0" />
@@ -40,7 +35,7 @@
<PackageReference Include="System.Threading.AccessControl" Version="4.5.0" />
</ItemGroup>
- <Target Name="PrepareTools" BeforeTargets="Build" Condition="'$(MonoBuild)' == ''">
+ <Target Name="PrepareTools" BeforeTargets="Build">
<!-- Restore ilasm using ilasm.ilproj. Restore must be done
separately from copy with a different set of input
properties, to force MSBuild to re-evaluate using new props
@@ -53,21 +48,10 @@
<MSBuild Projects="$(IlasmProject)" Targets="CopyILAsmTool" />
</Target>
- <ItemGroup Condition="'$(MonoBuild)' != ''">
- <ProjectReference Condition="'$(UseCecilPackage)' != 'true'" Include="..\..\external\cecil\symbols\mdb\Mono.Cecil.Mdb.csproj" />
- <PackageReference Include="NUnit" Version="3.12.0" />
- <PackageReference Include="NUnit.ConsoleRunner" Version="3.10.0" />
- <PackageReference Include="NUnit3TestAdapter" Version="3.17.0" />
- </ItemGroup>
-
<ItemGroup>
<None Update="TestCases\Dependencies\PInvokesExpectations.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
- <Target Name="RunTestsOnMono" Condition="'$(MonoBuild)' != ''">
- <Exec Command="mono $(PkgNUnit_ConsoleRunner)/tools/nunit3-console.exe --result=TestResults.xml $(OutputPath)Mono.Linker.Tests.dll" />
- </Target>
-
</Project>
diff --git a/test/Mono.Linker.Tests/TestCasesRunner/ILCompiler.cs b/test/Mono.Linker.Tests/TestCasesRunner/ILCompiler.cs
index 6d0080862..b2517bc1c 100644
--- a/test/Mono.Linker.Tests/TestCasesRunner/ILCompiler.cs
+++ b/test/Mono.Linker.Tests/TestCasesRunner/ILCompiler.cs
@@ -54,7 +54,7 @@ namespace Mono.Linker.Tests.TestCasesRunner
private string BuildArguments (CompilerOptions options)
{
var args = new StringBuilder ();
-#if ILLINK
+#if NETCOREAPP
args.Append(options.OutputPath.ExtensionWithDot == ".dll" ? "-dll" : "-exe");
args.Append($" -out:{options.OutputPath.InQuotes ()}");
#else
@@ -67,7 +67,7 @@ namespace Mono.Linker.Tests.TestCasesRunner
public static NPath LocateIlasm ()
{
-#if ILLINK
+#if NETCOREAPP
var extension = RuntimeInformation.IsOSPlatform (OSPlatform.Windows) ? ".exe" : "";
// working directory is artifacts/bin/Mono.Linker.Tests/<config>/<tfm>
diff --git a/test/Mono.Linker.Tests/TestCasesRunner/PathUtilities.cs b/test/Mono.Linker.Tests/TestCasesRunner/PathUtilities.cs
index b1b7913c7..3ff96d618 100644
--- a/test/Mono.Linker.Tests/TestCasesRunner/PathUtilities.cs
+++ b/test/Mono.Linker.Tests/TestCasesRunner/PathUtilities.cs
@@ -27,7 +27,7 @@ namespace Mono.Linker.Tests.TestCasesRunner
public static string GetTestsSourceRootDirectory ([CallerFilePath] string thisFile = null)
{
-#if ILLINK
+#if NETCOREAPP
// Deterministic builds sanitize source paths, so CallerFilePathAttribute gives an incorrect path.
// Instead, get the testcase dll based on the working directory of the test runner.
@@ -37,16 +37,16 @@ namespace Mono.Linker.Tests.TestCasesRunner
#else
var thisDirectory = Path.GetDirectoryName (thisFile);
return Path.GetFullPath (Path.Combine (thisDirectory, "..", ".."));
-#endif // ILLINK
+#endif
}
public static string GetTestAssemblyPath (string assemblyName)
{
-#if ILLINK
+#if NETCOREAPP
return Path.GetFullPath (Path.Combine (GetTestsSourceRootDirectory (), "..", "artifacts", "bin", assemblyName, ConfigDirectoryName, TFMDirectoryName, $"{assemblyName}.dll"));
#else
return Path.GetFullPath (Path.Combine (GetTestsSourceRootDirectory (), assemblyName, "bin", ConfigDirectoryName, TFMDirectoryName, $"{assemblyName}.dll"));
-#endif // ILLINK
+#endif
}
}
} \ No newline at end of file