diff options
author | Rolf Bjarne Kvinge <rolf@xamarin.com> | 2017-11-01 13:41:57 +0300 |
---|---|---|
committer | Marek Safar <marek.safar@gmail.com> | 2017-11-22 13:29:03 +0300 |
commit | f602bccd2b4f4a211a293b6d2db892d669cc6b13 (patch) | |
tree | 518767b7a3c33f0545482465ca3cb047f07cb8cd | |
parent | 4f4203f481b2e2642288e545684ee20d68fd2599 (diff) |
Make interface marking overridable by derived classes.
Make interface marking overridable by derived classes, so that derived classes
can decide whether an interface implementation should be marked or not.
Also remove any non-marked interface implementations.
-rw-r--r-- | linker/Mono.Linker.Steps/MarkStep.cs | 9 | ||||
-rw-r--r-- | linker/Mono.Linker.Steps/SweepStep.cs | 18 |
2 files changed, 25 insertions, 2 deletions
diff --git a/linker/Mono.Linker.Steps/MarkStep.cs b/linker/Mono.Linker.Steps/MarkStep.cs index f46f9d682..fe38bca42 100644 --- a/linker/Mono.Linker.Steps/MarkStep.cs +++ b/linker/Mono.Linker.Steps/MarkStep.cs @@ -647,8 +647,7 @@ namespace Mono.Linker.Steps { if (type.HasInterfaces) { foreach (var iface in type.Interfaces) { - MarkCustomAttributes (iface); - MarkType (iface.InterfaceType); + MarkInterfaceImplementation (type, iface); } } @@ -1568,5 +1567,11 @@ namespace Mono.Linker.Steps { throw new ResolutionException (reference); } } + + protected virtual void MarkInterfaceImplementation (TypeDefinition type, InterfaceImplementation iface) + { + MarkCustomAttributes (iface); + MarkType (iface.InterfaceType); + } } } diff --git a/linker/Mono.Linker.Steps/SweepStep.cs b/linker/Mono.Linker.Steps/SweepStep.cs index 089379e21..b33b21608 100644 --- a/linker/Mono.Linker.Steps/SweepStep.cs +++ b/linker/Mono.Linker.Steps/SweepStep.cs @@ -255,6 +255,9 @@ namespace Mono.Linker.Steps { if (type.HasNestedTypes) SweepNestedTypes (type); + + if (type.HasInterfaces) + SweepInterfaces (type); } protected void SweepNestedTypes (TypeDefinition type) @@ -270,6 +273,17 @@ namespace Mono.Linker.Steps { } } + protected void SweepInterfaces (TypeDefinition type) + { + for (int i = type.Interfaces.Count - 1; i >= 0; i--) { + var iface = type.Interfaces [i]; + if (Annotations.IsMarked (iface.InterfaceType.Resolve ())) + continue; + InterfaceRemoved (type, iface); + type.Interfaces.RemoveAt (i); + } + } + void SweepMethods (Collection<MethodDefinition> methods) { SweepCollection (methods); @@ -352,5 +366,9 @@ namespace Mono.Linker.Steps { protected virtual void ReferenceRemoved (AssemblyDefinition assembly, AssemblyNameReference reference) { } + + protected virtual void InterfaceRemoved (TypeDefinition type, InterfaceImplementation iface) + { + } } } |