diff --git a/src/Microsoft.Android.Sdk.ILLink/ApplyPreserveAttribute.cs b/src/Microsoft.Android.Sdk.ILLink/ApplyPreserveAttribute.cs
index de2a9590cc0..4c4af5ab10e 100644
--- a/src/Microsoft.Android.Sdk.ILLink/ApplyPreserveAttribute.cs
+++ b/src/Microsoft.Android.Sdk.ILLink/ApplyPreserveAttribute.cs
@@ -2,11 +2,10 @@
using System.Collections;
using System.Collections.Generic;
using System.Linq;
-
+using Mono.Cecil;
using Mono.Linker;
using Mono.Linker.Steps;
-
-using Mono.Cecil;
+using Xamarin.Android.Tasks;
namespace Microsoft.Android.Sdk.ILLink
{
@@ -25,7 +24,7 @@ public override SubStepTargets Targets {
public override bool IsActiveFor (AssemblyDefinition assembly)
{
- return !Profile.IsSdkAssembly (assembly) && Annotations.GetAction (assembly) == AssemblyAction.Link;
+ return !MonoAndroidHelper.IsFrameworkAssembly (assembly) && Annotations.GetAction (assembly) == AssemblyAction.Link;
}
public override void ProcessType (TypeDefinition type)
diff --git a/src/Microsoft.Android.Sdk.ILLink/MarkJavaObjects.cs b/src/Microsoft.Android.Sdk.ILLink/MarkJavaObjects.cs
index bb029b7421a..dc39f615a08 100644
--- a/src/Microsoft.Android.Sdk.ILLink/MarkJavaObjects.cs
+++ b/src/Microsoft.Android.Sdk.ILLink/MarkJavaObjects.cs
@@ -6,7 +6,6 @@
using Mono.Linker.Steps;
using Java.Interop.Tools.Cecil;
using Xamarin.Android.Tasks;
-using Profile = Microsoft.Android.Sdk.ILLink.Profile;
namespace MonoDroid.Tuner {
@@ -27,9 +26,7 @@ public override void Initialize (LinkContext context, MarkContext markContext)
bool IsActiveFor (AssemblyDefinition assembly)
{
- if (Profile.IsSdkAssembly (assembly))
- return false;
- if (Profile.IsProductAssembly (assembly))
+ if (MonoAndroidHelper.IsFrameworkAssembly (assembly))
return false;
return assembly.MainModule.HasTypeReference ("System.Net.Http.HttpMessageHandler") ||
@@ -397,7 +394,7 @@ static bool IsImplementor (TypeDefinition type, IMetadataResolver cache)
static bool IsUserType (TypeDefinition type)
{
- return !MonoAndroidHelper.IsFrameworkAssembly (type.Module.Assembly.Name.Name + ".dll");
+ return !MonoAndroidHelper.IsFrameworkAssembly (type.Module.Assembly);
}
void PreserveImplementor (TypeDefinition type)
diff --git a/src/Microsoft.Android.Sdk.ILLink/Microsoft.Android.Sdk.ILLink.csproj b/src/Microsoft.Android.Sdk.ILLink/Microsoft.Android.Sdk.ILLink.csproj
index de1051930e3..fe94767ae24 100644
--- a/src/Microsoft.Android.Sdk.ILLink/Microsoft.Android.Sdk.ILLink.csproj
+++ b/src/Microsoft.Android.Sdk.ILLink/Microsoft.Android.Sdk.ILLink.csproj
@@ -11,8 +11,6 @@
-
-
@@ -21,8 +19,6 @@
-
-
diff --git a/src/Microsoft.Android.Sdk.ILLink/PreserveApplications.cs b/src/Microsoft.Android.Sdk.ILLink/PreserveApplications.cs
index 5e3e1b0c44d..ddf99cf90df 100644
--- a/src/Microsoft.Android.Sdk.ILLink/PreserveApplications.cs
+++ b/src/Microsoft.Android.Sdk.ILLink/PreserveApplications.cs
@@ -1,14 +1,11 @@
using System;
using System.Collections;
using System.Linq;
-
+using Mono.Cecil;
using Mono.Linker;
using Mono.Linker.Steps;
-
using Mono.Tuner;
-using Mobile.Tuner;
-
-using Mono.Cecil;
+using Xamarin.Android.Tasks;
namespace MonoDroid.Tuner {
diff --git a/src/Microsoft.Android.Sdk.ILLink/PreserveExportedTypes.cs b/src/Microsoft.Android.Sdk.ILLink/PreserveExportedTypes.cs
index 13de9feb243..1b2664dc953 100644
--- a/src/Microsoft.Android.Sdk.ILLink/PreserveExportedTypes.cs
+++ b/src/Microsoft.Android.Sdk.ILLink/PreserveExportedTypes.cs
@@ -2,12 +2,11 @@
using System.Collections;
using System.Collections.Generic;
using System.Linq;
-
+using Microsoft.Android.Sdk.ILLink;
+using Mono.Cecil;
using Mono.Linker;
using Mono.Linker.Steps;
-
-using Mono.Cecil;
-using Microsoft.Android.Sdk.ILLink;
+using Xamarin.Android.Tasks;
namespace Mono.Tuner {
@@ -24,7 +23,11 @@ public override SubStepTargets Targets {
public override bool IsActiveFor (AssemblyDefinition assembly)
{
- return !Profile.IsSdkAssembly (assembly);
+ if (MonoAndroidHelper.IsFrameworkAssembly (assembly))
+ return false;
+
+ return assembly.MainModule.HasTypeReference ("Java.Interop.ExportAttribute") ||
+ assembly.MainModule.HasTypeReference ("Java.Interop.ExportFieldAttribute");
}
public override void ProcessField (FieldDefinition field)
diff --git a/src/Microsoft.Android.Sdk.ILLink/PreserveJavaExceptions.cs b/src/Microsoft.Android.Sdk.ILLink/PreserveJavaExceptions.cs
index 1c0ad8f0898..d60b064ef32 100644
--- a/src/Microsoft.Android.Sdk.ILLink/PreserveJavaExceptions.cs
+++ b/src/Microsoft.Android.Sdk.ILLink/PreserveJavaExceptions.cs
@@ -1,14 +1,11 @@
using System;
using System.Collections;
using System.Linq;
-
+using Mono.Cecil;
using Mono.Linker;
using Mono.Linker.Steps;
-
using Mono.Tuner;
-using Mobile.Tuner;
-
-using Mono.Cecil;
+using Xamarin.Android.Tasks;
namespace MonoDroid.Tuner {
diff --git a/src/Microsoft.Android.Sdk.ILLink/Profile.cs b/src/Microsoft.Android.Sdk.ILLink/Profile.cs
deleted file mode 100644
index 90a72c6d068..00000000000
--- a/src/Microsoft.Android.Sdk.ILLink/Profile.cs
+++ /dev/null
@@ -1,52 +0,0 @@
-using Mono.Cecil;
-using MonoDroid.Tuner;
-
-namespace Microsoft.Android.Sdk.ILLink
-{
- public abstract class Profile
- {
- static Profile current;
-
- public static Profile Current {
- get {
- if (current == null)
- current = new MonoDroidProfile ();
-
- return current;
- }
- }
-
- 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/Microsoft.Android.Sdk.ILLink/SetupStep.cs b/src/Microsoft.Android.Sdk.ILLink/SetupStep.cs
deleted file mode 100644
index 53ee2f3017f..00000000000
--- a/src/Microsoft.Android.Sdk.ILLink/SetupStep.cs
+++ /dev/null
@@ -1,20 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Reflection;
-using Java.Interop.Tools.Cecil;
-using Mono.Cecil;
-using Mono.Linker;
-using Mono.Linker.Steps;
-using MonoDroid.Tuner;
-
-namespace Microsoft.Android.Sdk.ILLink
-{
- class SetupStep : BaseStep
- {
- protected override void Process ()
- {
- if (Context.TryGetCustomData ("XATargetFrameworkDirectories", out string tfmPaths))
- Xamarin.Android.Tasks.MonoAndroidHelper.TargetFrameworkDirectories = tfmPaths.Split (new char [] { ';' });
- }
- }
-}
diff --git a/src/Microsoft.Android.Sdk.ILLink/StripEmbeddedLibraries.cs b/src/Microsoft.Android.Sdk.ILLink/StripEmbeddedLibraries.cs
index e455d80dc1f..041bead3f92 100644
--- a/src/Microsoft.Android.Sdk.ILLink/StripEmbeddedLibraries.cs
+++ b/src/Microsoft.Android.Sdk.ILLink/StripEmbeddedLibraries.cs
@@ -17,17 +17,13 @@ protected override void ProcessAssembly (AssemblyDefinition assembly)
if (action == AssemblyAction.Skip || action == AssemblyAction.Delete)
return;
- var fileName = assembly.Name.Name + ".dll";
- if (MonoAndroidHelper.IsFrameworkAssembly (fileName) &&
- !MonoAndroidHelper.FrameworkEmbeddedJarLookupTargets.Contains (fileName) &&
- !MonoAndroidHelper.FrameworkEmbeddedNativeLibraryAssemblies.Contains (fileName))
+ if (MonoAndroidHelper.IsFrameworkAssembly (assembly))
return;
-
bool assembly_modified = false;
foreach (var mod in assembly.Modules) {
foreach (var r in mod.Resources.ToArray ()) {
if (ShouldStripResource (r)) {
- Context.LogMessage ($" Stripped {r.Name} from {fileName}");
+ Context.LogMessage ($" Stripped {r.Name} from {assembly.Name.Name}.dll");
mod.Resources.Remove (r);
assembly_modified = true;
}
diff --git a/src/Xamarin.Android.Build.Tasks/Linker/Mobile.Tuner/MobileProfile.cs b/src/Xamarin.Android.Build.Tasks/Linker/Mobile.Tuner/MobileProfile.cs
deleted file mode 100644
index 3fc0c4acbec..00000000000
--- a/src/Xamarin.Android.Build.Tasks/Linker/Mobile.Tuner/MobileProfile.cs
+++ /dev/null
@@ -1,205 +0,0 @@
-using System;
-using System.Collections.Generic;
-
-using Mono.Cecil;
-
-using Mono.Tuner;
-#if ILLINK
-using Microsoft.Android.Sdk.ILLink;
-#endif
-
-namespace Mobile.Tuner {
-
- public abstract class MobileProfile : Profile {
-
- static readonly HashSet Sdk = new HashSet {
- "SMDiagnostics",
- "mscorlib",
- "System",
- "System.ComponentModel.Composition",
- "System.ComponentModel.DataAnnotations",
- "System.Core",
- "System.Data",
- "System.Data.DataSetExtensions",
- "System.Data.Services.Client",
- "System.EnterpriseServices",
- "System.IdentityModel",
- "System.IO.Compression.FileSystem",
- "System.IO.Compression",
- "System.Json",
- "System.Net",
- "System.Net.Http",
- "System.Net.Http.WinHttpHandler",
- "System.Numerics",
- "System.Numerics.Vectors",
- "System.Reflection.Context",
- "System.Runtime.Serialization",
- "System.Security",
- "System.ServiceModel",
- "System.ServiceModel.Internals",
- "System.ServiceModel.Web",
- "System.Transactions",
- "System.Web.Services",
- "System.Windows",
- "System.Xml",
- "System.Xml.Linq",
- "System.Xml.Serialization",
- "Microsoft.CSharp",
- "Microsoft.VisualBasic",
- "Mono.CSharp",
- "Mono.Cairo",
- "Mono.CompilerServices.SymbolWriter",
- "Mono.Data.Tds",
- "Mono.Data.Sqlite",
- "Mono.Posix",
- "Mono.Security",
- // Facades assemblies (PCL)
- "Microsoft.Win32.Primitives",
- "Microsoft.Win32.Registry.AccessControl",
- "Microsoft.Win32.Registry",
- "System.AppContext",
- "System.Collections.Concurrent",
- "System.Collections.NonGeneric",
- "System.Collections.Specialized",
- "System.Collections",
- "System.ComponentModel.Annotations",
- "System.ComponentModel.EventBasedAsync",
- "System.ComponentModel.Primitives",
- "System.ComponentModel.TypeConverter",
- "System.ComponentModel",
- "System.Console",
- "System.Data.Common",
- "System.Data.SqlClient",
- "System.Diagnostics.Contracts",
- "System.Diagnostics.Debug",
- "System.Diagnostics.FileVersionInfo",
- "System.Diagnostics.Process",
- "System.Diagnostics.StackTrace",
- "System.Diagnostics.TextWriterTraceListener",
- "System.Diagnostics.Tools",
- "System.Diagnostics.TraceEvent",
- "System.Diagnostics.TraceSource",
- "System.Diagnostics.Tracing",
- "System.Drawing.Common",
- "System.Drawing.Primitives",
- "System.Dynamic.Runtime",
- "System.Globalization.Calendars",
- "System.Globalization.Extensions",
- "System.Globalization",
- "System.IO",
- "System.IO.Compression.ZipFile",
- "System.IO.FileSystem.AccessControl",
- "System.IO.FileSystem.DriveInfo",
- "System.IO.FileSystem.Primitives",
- "System.IO.FileSystem.Watcher",
- "System.IO.FileSystem",
- "System.IO.IsolatedStorage",
- "System.IO.MemoryMappedFiles",
- "System.IO.Pipes",
- "System.IO.UnmanagedMemoryStream",
- "System.Linq.Expressions",
- "System.Linq.Parallel",
- "System.Linq.Queryable",
- "System.Linq",
- "System.Memory",
- "System.Net.AuthenticationManager",
- "System.Net.Cache",
- "System.Net.HttpListener",
- "System.Net.Mail",
- "System.Net.NameResolution",
- "System.Net.NetworkInformation",
- "System.Net.Ping",
- "System.Net.Primitives",
- "System.Net.Requests",
- "System.Net.Security",
- "System.Net.ServicePoint",
- "System.Net.Sockets",
- "System.Net.Utilities",
- "System.Net.WebHeaderCollection",
- "System.Net.WebSockets.Client",
- "System.Net.WebSockets",
- "System.ObjectModel",
- "System.Reflection.DispatchProxy",
- "System.Reflection.Emit.ILGeneration",
- "System.Reflection.Emit.Lightweight",
- "System.Reflection.Emit",
- "System.Reflection.Extensions",
- "System.Reflection.Primitives",
- "System.Reflection.TypeExtensions",
- "System.Reflection",
- "System.Resources.Reader",
- "System.Resources.ReaderWriter",
- "System.Resources.ResourceManager",
- "System.Resources.Writer",
- "System.Runtime.CompilerServices.VisualC",
- "System.Runtime.Extensions",
- "System.Runtime.Handles",
- "System.Runtime.InteropServices",
- "System.Runtime.InteropServices.RuntimeInformation",
- "System.Runtime.InteropServices.WindowsRuntime",
- "System.Runtime.Loader",
- "System.Runtime.Numerics",
- "System.Runtime.Serialization.Formatters",
- "System.Runtime.Serialization.Json",
- "System.Runtime.Serialization.Primitives",
- "System.Runtime.Serialization.Xml",
- "System.Runtime",
- "System.Security.AccessControl",
- "System.Security.Claims",
- "System.Security.Cryptography.Algorithms",
- "System.Security.Cryptography.Cng",
- "System.Security.Cryptography.Csp",
- "System.Security.Cryptography.DeriveBytes",
- "System.Security.Cryptography.Encoding",
- "System.Security.Cryptography.Encryption.Aes",
- "System.Security.Cryptography.Encryption.ECDiffieHellman",
- "System.Security.Cryptography.Encryption.ECDsa",
- "System.Security.Cryptography.Encryption",
- "System.Security.Cryptography.Hashing.Algorithms",
- "System.Security.Cryptography.Hashing",
- "System.Security.Cryptography.OpenSsl",
- "System.Security.Cryptography.Pkcs",
- "System.Security.Cryptography.Primitives",
- "System.Security.Cryptography.ProtectedData",
- "System.Security.Cryptography.RSA",
- "System.Security.Cryptography.RandomNumberGenerator",
- "System.Security.Cryptography.X509Certificates",
- "System.Security.Principal.Windows",
- "System.Security.Principal",
- "System.Security.SecureString",
- "System.ServiceModel.Duplex",
- "System.ServiceModel.NetTcp",
- "System.ServiceModel.Http",
- "System.ServiceModel.Primitives",
- "System.ServiceModel.Security",
- "System.ServiceProcess.ServiceController",
- "System.Text.Encoding.CodePages",
- "System.Text.Encoding.Extensions",
- "System.Text.Encoding",
- "System.Text.RegularExpressions",
- "System.Threading.AccessControl",
- "System.Threading.Overlapped",
- "System.Threading.Tasks.Parallel",
- "System.Threading.Tasks",
- "System.Threading.Thread",
- "System.Threading.ThreadPool",
- "System.Threading.Timer",
- "System.Threading",
- "System.ValueTuple",
- "System.Xml.ReaderWriter",
- "System.Xml.XDocument",
- "System.Xml.XPath.XDocument",
- "System.Xml.XPath.XmlDocument",
- "System.Xml.XPath",
- "System.Xml.XmlDocument",
- "System.Xml.XmlSerializer",
- "System.Xml.Xsl.Primitives",
- "netstandard",
- };
-
- protected override bool IsSdk (string assemblyName)
- {
- return Sdk.Contains (assemblyName);
- }
- }
-}
diff --git a/src/Xamarin.Android.Build.Tasks/Linker/MonoDroid.Tuner/AddKeepAlivesStep.cs b/src/Xamarin.Android.Build.Tasks/Linker/MonoDroid.Tuner/AddKeepAlivesStep.cs
index 8a27d1d7eb8..e143d5c312f 100644
--- a/src/Xamarin.Android.Build.Tasks/Linker/MonoDroid.Tuner/AddKeepAlivesStep.cs
+++ b/src/Xamarin.Android.Build.Tasks/Linker/MonoDroid.Tuner/AddKeepAlivesStep.cs
@@ -10,9 +10,6 @@
using Mono.Linker.Steps;
using Mono.Cecil.Cil;
-#if ILLINK
-using Microsoft.Android.Sdk.ILLink;
-#endif // ILLINK
namespace MonoDroid.Tuner
{
diff --git a/src/Xamarin.Android.Build.Tasks/Linker/MonoDroid.Tuner/FixAbstractMethodsStep.cs b/src/Xamarin.Android.Build.Tasks/Linker/MonoDroid.Tuner/FixAbstractMethodsStep.cs
index 70de2500931..01890ba8c56 100644
--- a/src/Xamarin.Android.Build.Tasks/Linker/MonoDroid.Tuner/FixAbstractMethodsStep.cs
+++ b/src/Xamarin.Android.Build.Tasks/Linker/MonoDroid.Tuner/FixAbstractMethodsStep.cs
@@ -2,17 +2,14 @@
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
-
-using Mono.Cecil;
-
using Java.Interop.Tools.Cecil;
-
+using Mono.Cecil;
using Mono.Linker;
using Mono.Linker.Steps;
-
using Mono.Tuner;
+using Xamarin.Android.Tasks;
+
#if ILLINK
-using Microsoft.Android.Sdk.ILLink;
using Resources = Microsoft.Android.Sdk.ILLink.Properties.Resources;
#else // !ILLINK
using Resources = Xamarin.Android.Tasks.Properties.Resources;
@@ -53,7 +50,7 @@ bool CheckShouldProcessAssembly (AssemblyDefinition assembly)
if (!Annotations.HasAction (assembly))
Annotations.SetAction (assembly, AssemblyAction.Skip);
- if (IsProductOrSdkAssembly (assembly))
+ if (MonoAndroidHelper.IsFrameworkAssembly (assembly))
return false;
CheckAppDomainUsage (assembly, (string msg) =>
@@ -130,12 +127,6 @@ internal void CheckAppDomainUsage (AssemblyDefinition assembly, Action w
}
}
- bool IsProductOrSdkAssembly (AssemblyDefinition assembly) =>
- IsProductOrSdkAssembly (assembly.Name.Name);
-
- public bool IsProductOrSdkAssembly (string assemblyName) =>
- Profile.IsSdkAssembly (assemblyName) || Profile.IsProductAssembly (assemblyName);
-
bool MightNeedFix (TypeDefinition type)
{
return !type.IsAbstract && type.IsSubclassOf ("Java.Lang.Object", cache);
diff --git a/src/Xamarin.Android.Build.Tasks/Linker/MonoDroid.Tuner/FixLegacyResourceDesignerStep.cs b/src/Xamarin.Android.Build.Tasks/Linker/MonoDroid.Tuner/FixLegacyResourceDesignerStep.cs
index 777c419fbc8..f60a9c7a2a0 100644
--- a/src/Xamarin.Android.Build.Tasks/Linker/MonoDroid.Tuner/FixLegacyResourceDesignerStep.cs
+++ b/src/Xamarin.Android.Build.Tasks/Linker/MonoDroid.Tuner/FixLegacyResourceDesignerStep.cs
@@ -13,7 +13,6 @@
using Mono.Tuner;
#if ILLINK
-using Microsoft.Android.Sdk.ILLink;
using Resources = Microsoft.Android.Sdk.ILLink.Properties.Resources;
#else // !ILLINK
using Resources = Xamarin.Android.Tasks.Properties.Resources;
diff --git a/src/Xamarin.Android.Build.Tasks/Linker/MonoDroid.Tuner/MonoDroidProfile.cs b/src/Xamarin.Android.Build.Tasks/Linker/MonoDroid.Tuner/MonoDroidProfile.cs
deleted file mode 100644
index b11d55e9be6..00000000000
--- a/src/Xamarin.Android.Build.Tasks/Linker/MonoDroid.Tuner/MonoDroidProfile.cs
+++ /dev/null
@@ -1,25 +0,0 @@
-using System;
-using System.Collections.Generic;
-
-using Mono.Tuner;
-using Mobile.Tuner;
-
-using Mono.Cecil;
-
-namespace MonoDroid.Tuner {
-
- class MonoDroidProfile : MobileProfile {
-
- protected override bool IsProduct (string assemblyName)
- {
- return assemblyName == "Mono.Android";
- }
-
- protected override bool IsSdk (string assemblyName)
- {
- return assemblyName.Equals ("Java.Interop", StringComparison.Ordinal)
- || assemblyName.Equals ("Java.Interop.GenericMarshaler", StringComparison.Ordinal)
- || base.IsSdk (assemblyName);
- }
- }
-}
diff --git a/src/Xamarin.Android.Build.Tasks/Linker/MonoDroid.Tuner/RemoveResourceDesignerStep.cs b/src/Xamarin.Android.Build.Tasks/Linker/MonoDroid.Tuner/RemoveResourceDesignerStep.cs
index 0ac0e0e7c33..3c1e1a71a9d 100644
--- a/src/Xamarin.Android.Build.Tasks/Linker/MonoDroid.Tuner/RemoveResourceDesignerStep.cs
+++ b/src/Xamarin.Android.Build.Tasks/Linker/MonoDroid.Tuner/RemoveResourceDesignerStep.cs
@@ -93,8 +93,7 @@ internal override bool ProcessAssemblyDesigner (AssemblyDefinition assembly)
{
if (mainDesigner == null)
return false;
- var fileName = assembly.Name.Name + ".dll";
- if (MonoAndroidHelper.IsFrameworkAssembly (fileName))
+ if (MonoAndroidHelper.IsFrameworkAssembly (assembly))
return false;
LogMessage ($" Fixing up {assembly.Name.Name}");
diff --git a/src/Xamarin.Android.Build.Tasks/Microsoft.Android.Sdk/targets/Microsoft.Android.Sdk.ILLink.targets b/src/Xamarin.Android.Build.Tasks/Microsoft.Android.Sdk/targets/Microsoft.Android.Sdk.ILLink.targets
index 1cd67019059..6e783fdf500 100644
--- a/src/Xamarin.Android.Build.Tasks/Microsoft.Android.Sdk/targets/Microsoft.Android.Sdk.ILLink.targets
+++ b/src/Xamarin.Android.Build.Tasks/Microsoft.Android.Sdk/targets/Microsoft.Android.Sdk.ILLink.targets
@@ -32,7 +32,6 @@ This file contains the .NET 5-specific targets to customize ILLink
-->
<_TrimmerCustomData Include="AndroidHttpClientHandlerType" Value="$(AndroidHttpClientHandlerType)" />
<_TrimmerCustomData Include="AndroidCustomViewMapFile" Value="$(_OuterCustomViewMapFile)" />
- <_TrimmerCustomData Include="XATargetFrameworkDirectories" Value="$(_XATargetFrameworkDirectories)" />
<_TrimmerCustomData
Condition=" '$(_ProguardProjectConfiguration)' != '' "
Include="ProguardConfiguration"
@@ -44,8 +43,6 @@ This file contains the .NET 5-specific targets to customize ILLink
https://github.com/dotnet/sdk/blob/a5393731b5b7b225692fff121f747fbbc9e8b140/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.ILLink.targets#L131
-->
-
- <_TrimmerCustomSteps Include="$(_AndroidLinkerCustomStepAssembly)" BeforeStep="MarkStep" Type="Microsoft.Android.Sdk.ILLink.SetupStep" />
<_TrimmerCustomSteps Include="$(_AndroidLinkerCustomStepAssembly)" Type="Microsoft.Android.Sdk.ILLink.PreserveSubStepDispatcher" />
<_TrimmerCustomSteps Include="$(_AndroidLinkerCustomStepAssembly)" Type="MonoDroid.Tuner.MarkJavaObjects" />
diff --git a/src/Xamarin.Android.Build.Tasks/Tasks/FilterAssemblies.cs b/src/Xamarin.Android.Build.Tasks/Tasks/FilterAssemblies.cs
index 9c3fe84407a..057bcfb9bd7 100644
--- a/src/Xamarin.Android.Build.Tasks/Tasks/FilterAssemblies.cs
+++ b/src/Xamarin.Android.Build.Tasks/Tasks/FilterAssemblies.cs
@@ -34,12 +34,7 @@ public override bool RunTask ()
var output = new List (InputAssemblies.Length);
foreach (var assemblyItem in InputAssemblies) {
- // Skip .NET 6.0 assemblies
- var frameworkReferenceName = assemblyItem.GetMetadata ("FrameworkReferenceName") ?? "";
- if (frameworkReferenceName == "Microsoft.Android") {
- continue; // No need to process Mono.Android.dll or Java.Interop.dll
- }
- if (frameworkReferenceName.StartsWith ("Microsoft.NETCore.", StringComparison.OrdinalIgnoreCase)) {
+ if (MonoAndroidHelper.IsFrameworkAssembly (assemblyItem)) {
continue; // No need to process BCL assemblies
}
if (string.Equals (assemblyItem.GetMetadata ("TargetPlatformIdentifier"), "android", StringComparison.OrdinalIgnoreCase)) {
diff --git a/src/Xamarin.Android.Build.Tasks/Tasks/GenerateResourceDesigner.cs b/src/Xamarin.Android.Build.Tasks/Tasks/GenerateResourceDesigner.cs
index 35474f678ac..5986793d0a8 100644
--- a/src/Xamarin.Android.Build.Tasks/Tasks/GenerateResourceDesigner.cs
+++ b/src/Xamarin.Android.Build.Tasks/Tasks/GenerateResourceDesigner.cs
@@ -111,8 +111,7 @@ public override bool RunTask ()
foreach (var assembly in References) {
var assemblyPath = assembly.ItemSpec;
var fileName = Path.GetFileName (assemblyPath);
- if (MonoAndroidHelper.IsFrameworkAssembly (fileName) &&
- !MonoAndroidHelper.FrameworkEmbeddedJarLookupTargets.Contains (fileName)) {
+ if (MonoAndroidHelper.IsFrameworkAssembly (fileName)) {
Log.LogDebugMessage ($"Skipping framework assembly '{fileName}'.");
continue;
}
diff --git a/src/Xamarin.Android.Build.Tasks/Tasks/LinkAssembliesNoShrink.cs b/src/Xamarin.Android.Build.Tasks/Tasks/LinkAssembliesNoShrink.cs
index bb7d7c54516..db271d4948b 100644
--- a/src/Xamarin.Android.Build.Tasks/Tasks/LinkAssembliesNoShrink.cs
+++ b/src/Xamarin.Android.Build.Tasks/Tasks/LinkAssembliesNoShrink.cs
@@ -130,16 +130,16 @@ void DoRunTask (ITaskItem source, ITaskItem destination, RunState runState, Writ
CopyIfChanged (source, destination);
return;
}
- if (runState.fixAbstractMethodsStep!.IsProductOrSdkAssembly (assemblyName)) {
+ if (MonoAndroidHelper.IsFrameworkAssembly (source)) {
CopyIfChanged (source, destination);
return;
}
// Only run the step on "MonoAndroid" assemblies
- if (MonoAndroidHelper.IsMonoAndroidAssembly (source) && !MonoAndroidHelper.IsSharedRuntimeAssembly (source.ItemSpec)) {
+ if (MonoAndroidHelper.IsMonoAndroidAssembly (source)) {
AssemblyDefinition assemblyDefinition = runState.resolver!.GetAssembly (source.ItemSpec);
- bool save = runState.fixAbstractMethodsStep.FixAbstractMethods (assemblyDefinition);
+ bool save = runState.fixAbstractMethodsStep!.FixAbstractMethods (assemblyDefinition);
if (UseDesignerAssembly)
save |= runState.fixLegacyResourceDesignerStep!.ProcessAssemblyDesigner (assemblyDefinition);
if (AddKeepAlives)
diff --git a/src/Xamarin.Android.Build.Tasks/Tasks/ProcessAssemblies.cs b/src/Xamarin.Android.Build.Tasks/Tasks/ProcessAssemblies.cs
index a5b7cfcf36d..bce699d3883 100644
--- a/src/Xamarin.Android.Build.Tasks/Tasks/ProcessAssemblies.cs
+++ b/src/Xamarin.Android.Build.Tasks/Tasks/ProcessAssemblies.cs
@@ -84,7 +84,7 @@ public override bool RunTask ()
if (InputJavaLibraries != null) {
var javaLibraries = new Dictionary (StringComparer.OrdinalIgnoreCase);
foreach (var item in InputJavaLibraries) {
- if (!IsFromAKnownRuntimePack (item))
+ if (!MonoAndroidHelper.IsFromAKnownRuntimePack (item))
continue;
var name = Path.GetFileNameWithoutExtension(item.ItemSpec);
if (!javaLibraries.ContainsKey (name)) {
@@ -126,7 +126,7 @@ void SetMetadataForAssemblies (List output, Dictionary output, Dictionary symbols, ITaskItem assembly)
{
var symbolPath = Path.ChangeExtension (assembly.ItemSpec, ".pdb");
diff --git a/src/Xamarin.Android.Build.Tasks/Tasks/ResolveLibraryProjectImports.cs b/src/Xamarin.Android.Build.Tasks/Tasks/ResolveLibraryProjectImports.cs
index b7ccc1df33d..af9c72f8d8e 100644
--- a/src/Xamarin.Android.Build.Tasks/Tasks/ResolveLibraryProjectImports.cs
+++ b/src/Xamarin.Android.Build.Tasks/Tasks/ResolveLibraryProjectImports.cs
@@ -186,9 +186,7 @@ void Extract (
foreach (var assemblyItem in Assemblies) {
var assemblyPath = assemblyItem.ItemSpec;
var fileName = Path.GetFileName (assemblyPath);
- if (MonoAndroidHelper.IsFrameworkAssembly (fileName) &&
- !MonoAndroidHelper.FrameworkEmbeddedJarLookupTargets.Contains (fileName) &&
- !MonoAndroidHelper.FrameworkEmbeddedNativeLibraryAssemblies.Contains (fileName)) {
+ if (MonoAndroidHelper.IsFrameworkAssembly (fileName)) {
Log.LogDebugMessage ($"Skipping framework assembly '{fileName}'.");
continue;
}
@@ -200,8 +198,7 @@ void Extract (
Log.LogDebugMessage ("Skipping resource extraction for '{0}' .", assemblyPath);
continue;
}
- string assemblyFileName = Path.GetFileName (assemblyPath);
- string assemblyIdentName = assemblyMap.GetLibraryImportDirectoryNameForAssembly (assemblyFileName);
+ string assemblyIdentName = assemblyMap.GetLibraryImportDirectoryNameForAssembly (fileName);
string outDirForDll = Path.Combine (OutputImportDirectory, assemblyIdentName);
string importsDir = Path.Combine (outDirForDll, ImportsDirectory);
string nativeimportsDir = Path.Combine (outDirForDll, NativeImportsDirectory);
@@ -255,7 +252,7 @@ void Extract (
continue;
}
- Log.LogDebugMessage ($"Refreshing {assemblyFileName}");
+ Log.LogDebugMessage ($"Refreshing {fileName}");
using (var pe = new PEReader (File.OpenRead (assemblyPath))) {
var reader = pe.GetMetadataReader ();
diff --git a/src/Xamarin.Android.Build.Tasks/Tasks/ResolveSdksTask.cs b/src/Xamarin.Android.Build.Tasks/Tasks/ResolveSdksTask.cs
index a93bdb23536..8a0aa3f95d6 100644
--- a/src/Xamarin.Android.Build.Tasks/Tasks/ResolveSdksTask.cs
+++ b/src/Xamarin.Android.Build.Tasks/Tasks/ResolveSdksTask.cs
@@ -128,8 +128,6 @@ public override bool RunTask ()
return false;
}
- MonoAndroidHelper.TargetFrameworkDirectories = ReferenceAssemblyPaths;
-
Log.LogDebugMessage ($"{nameof (ResolveSdks)} Outputs:");
Log.LogDebugMessage ($" {nameof (AndroidSdkPath)}: {AndroidSdkPath}");
Log.LogDebugMessage ($" {nameof (AndroidNdkPath)}: {AndroidNdkPath}");
diff --git a/src/Xamarin.Android.Build.Tasks/Utilities/MonoAndroidHelper.Linker.cs b/src/Xamarin.Android.Build.Tasks/Utilities/MonoAndroidHelper.Linker.cs
index 3d13492aec7..b3b863dbda4 100644
--- a/src/Xamarin.Android.Build.Tasks/Utilities/MonoAndroidHelper.Linker.cs
+++ b/src/Xamarin.Android.Build.Tasks/Utilities/MonoAndroidHelper.Linker.cs
@@ -2,50 +2,23 @@
using System.Collections.Generic;
using System.Linq;
using System.IO;
+using Mono.Cecil;
namespace Xamarin.Android.Tasks
{
public partial class MonoAndroidHelper
{
- public static string [] TargetFrameworkDirectories;
-
- internal static readonly string [] FrameworkEmbeddedJarLookupTargets = {
- "Mono.Android.Support.v13.dll",
- "Mono.Android.Support.v4.dll",
- "Xamarin.Android.NUnitLite.dll", // AndroidResources
- };
- internal static readonly string [] FrameworkEmbeddedNativeLibraryAssemblies = {
- "Mono.Data.Sqlite.dll",
- "Mono.Posix.dll",
+ static readonly HashSet KnownAssemblyNames = new (StringComparer.OrdinalIgnoreCase) {
+ "Mono.Android",
+ "Mono.Android.Export",
+ "Java.Interop",
};
- public static bool IsFrameworkAssembly (string assembly)
- {
- return IsFrameworkAssembly (assembly, false);
- }
+ public static bool IsFrameworkAssembly (AssemblyDefinition assembly) =>
+ KnownAssemblyNames.Contains (assembly.Name.Name);
- public static bool IsFrameworkAssembly (string assembly, bool checkSdkPath)
- {
- if (IsSharedRuntimeAssembly (assembly)) {
- return true;
- }
- return TargetFrameworkDirectories == null || !checkSdkPath ? false : ExistsInFrameworkPath (assembly);
- }
-
- public static bool IsSharedRuntimeAssembly (string assembly)
- {
- return Array.BinarySearch (Profile.SharedRuntimeAssemblies, Path.GetFileName (assembly), StringComparer.OrdinalIgnoreCase) >= 0;
- }
-
- public static bool ExistsInFrameworkPath (string assembly)
- {
- return TargetFrameworkDirectories
- // TargetFrameworkDirectories will contain a "versioned" directory,
- // e.g. $prefix/lib/xamarin.android/xbuild-frameworks/MonoAndroid/v1.0.
- // Trim off the version.
- .Select (p => Path.GetDirectoryName (p.TrimEnd (Path.DirectorySeparatorChar)))
- .Any (p => assembly.StartsWith (p, StringComparison.OrdinalIgnoreCase));
- }
+ public static bool IsFrameworkAssembly (string assembly) =>
+ KnownAssemblyNames.Contains (Path.GetFileNameWithoutExtension (assembly));
static readonly char [] CustomViewMapSeparator = [';'];
diff --git a/src/Xamarin.Android.Build.Tasks/Utilities/MonoAndroidHelper.cs b/src/Xamarin.Android.Build.Tasks/Utilities/MonoAndroidHelper.cs
index b4daa6d8bc0..833d2b3a534 100644
--- a/src/Xamarin.Android.Build.Tasks/Utilities/MonoAndroidHelper.cs
+++ b/src/Xamarin.Android.Build.Tasks/Utilities/MonoAndroidHelper.cs
@@ -415,6 +415,32 @@ public static ZipArchive ReadZipFile (string filename)
}
#if MSBUILD
+ public static bool IsFrameworkAssembly (ITaskItem assembly)
+ {
+ // Known assembly names: Mono.Android, Java.Interop, etc.
+ if (IsFrameworkAssembly (assembly.ItemSpec))
+ return true;
+
+ // Known %(FrameworkReferenceName)
+ var frameworkReferenceName = assembly.GetMetadata ("FrameworkReferenceName") ?? "";
+ if (frameworkReferenceName == "Microsoft.Android") {
+ return true; // Microsoft.Android assemblies
+ }
+ if (frameworkReferenceName.StartsWith ("Microsoft.NETCore.", StringComparison.OrdinalIgnoreCase)) {
+ return true; // BCL assemblies
+ }
+
+ // Known %(NuGetPackageId) runtime pack names
+ return IsFromAKnownRuntimePack (assembly);
+ }
+
+ public static bool IsFromAKnownRuntimePack (ITaskItem assembly)
+ {
+ string packageId = assembly.GetMetadata ("NuGetPackageId") ?? "";
+ return packageId.StartsWith ("Microsoft.NETCore.App.Runtime.", StringComparison.OrdinalIgnoreCase) ||
+ packageId.StartsWith ("Microsoft.Android.Runtime.", StringComparison.OrdinalIgnoreCase);
+ }
+
public static bool SaveMapFile (IBuildEngine4 engine, string mapFile, Dictionary map)
{
engine?.RegisterTaskObjectAssemblyLocal (mapFile, map, RegisteredTaskObjectLifetime.Build);
diff --git a/src/Xamarin.Android.Build.Tasks/Utilities/Profile.cs b/src/Xamarin.Android.Build.Tasks/Utilities/Profile.cs
deleted file mode 100644
index 7c9e72a0a0b..00000000000
--- a/src/Xamarin.Android.Build.Tasks/Utilities/Profile.cs
+++ /dev/null
@@ -1,44 +0,0 @@
-using System.Collections.Generic;
-
-namespace Xamarin.Android.Tasks
-{
- public partial class Profile
- {
- public static readonly HashSet Sdk = new HashSet {
- "mscorlib",
- "System",
- "System.Core",
- "System.Data",
- "System.EnterpriseServices",
- "System.Net.Http",
- "System.Runtime.Serialization",
- "System.ServiceModel",
- "System.ServiceModel.Web",
- "System.Transactions",
- "System.Web.Services",
- "System.Xml",
- "System.Xml.Linq",
- "System.Json",
- "System.Numerics",
- "Microsoft.CSharp",
- "Mono.CSharp",
- "Mono.CompilerServices.SymbolWriter",
- "Mono.Security",
- "Mono.Data.Tds",
- "Mono.Data.Sqlite",
- };
-
- // KEEP THIS SORTED ALPHABETICALLY, CASE-INSENSITIVE
- public static readonly string[] ValidAbis = new[]{
- "arm64-v8a",
- "armeabi-v7a",
- "x86",
- "x86_64",
- };
-
- public static readonly string[] ValidProfilers = new[]{
- "log",
- };
- }
-}
-
diff --git a/src/Xamarin.Android.Build.Tasks/Xamarin.Android.Build.Tasks.csproj b/src/Xamarin.Android.Build.Tasks/Xamarin.Android.Build.Tasks.csproj
index e44695081db..9586df6e7c1 100644
--- a/src/Xamarin.Android.Build.Tasks/Xamarin.Android.Build.Tasks.csproj
+++ b/src/Xamarin.Android.Build.Tasks/Xamarin.Android.Build.Tasks.csproj
@@ -44,7 +44,6 @@
-
@@ -56,8 +55,6 @@
-
-
@@ -78,7 +75,6 @@
-
Mono.Android\IntentFilterAttribute.cs
diff --git a/src/Xamarin.Android.Build.Tasks/Xamarin.Android.Build.Tasks.targets b/src/Xamarin.Android.Build.Tasks/Xamarin.Android.Build.Tasks.targets
index 4ce99eb4493..3fd82ecdc9c 100644
--- a/src/Xamarin.Android.Build.Tasks/Xamarin.Android.Build.Tasks.targets
+++ b/src/Xamarin.Android.Build.Tasks/Xamarin.Android.Build.Tasks.targets
@@ -8,7 +8,6 @@
<_SharedRuntimeBuildPath Condition=" '$(_SharedRuntimeBuildPath)' == '' ">$(XAInstallPrefix)xbuild-frameworks\MonoAndroid\
- <_GeneratedProfileClass>$(MSBuildThisFileDirectory)$(IntermediateOutputPath)Profile.g.cs
$(ResolveReferencesDependsOn);
_GenerateSupportedPlatforms;
@@ -163,16 +162,6 @@
PreserveNewest
-
- <_SharedRuntimeAssemblies Include="@(MonoProfileAssembly->'$(_SharedRuntimeBuildPath)v1.0\%(Identity)')" />
- <_SharedRuntimeAssemblies Include="$(_SharedRuntimeBuildPath)v1.0\Mono.Data.Sqlite.dll" />
- <_SharedRuntimeAssemblies Include="$(_SharedRuntimeBuildPath)v1.0\Mono.Posix.dll" />
- <_SharedRuntimeAssemblies Include="$(_SharedRuntimeBuildPath)v1.0\Java.Interop.dll" />
- <_SharedRuntimeAssemblies Include="$(_SharedRuntimeBuildPath)v1.0\System.EnterpriseServices.dll" />
- <_SharedRuntimeAssemblies Include="$(_SharedRuntimeBuildPath)$(AndroidFrameworkVersion)\Mono.Android.Export.dll" />
-
- <_SharedRuntimeAssemblies Include="$(_SharedRuntimeBuildPath)$(AndroidFrameworkVersion)\Mono.Android.dll" />
-
-
-
-
-
-
-
-