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
path: root/linker
diff options
context:
space:
mode:
authorRadek Doulik <rodo@xamarin.com>2017-07-28 17:28:12 +0300
committerMarek Safar <marek.safar@gmail.com>2017-08-02 23:58:17 +0300
commit305e0f60533d164676099c918fa4dd09c718017b (patch)
tree45162f531548f17b7ace627273b3f35cafe80ce7 /linker
parentc39f545b10306e5e0420501a0777f7288bbbbf24 (diff)
[linker] added workaround for invalid type forwards
- fixes #57645 - ignore invalid forwards of nested types of exported forwarded types, which were added by a bug in csc. description by Marek Safar from https://bugzilla.xamarin.com/show_bug.cgi?id=57645#c13 Native csc (pre-Roslyn version) when encountered typeforwarded type it added automatically all its nested types including private/protected/internal ones. This bug was fixed in Roslyn csc but there are still many assemblies compiled with native csc (pre VS2015) which can have typeforwarded typeref to a type which is not available because it's not included in public API. - ignoring these forwarders here should be harmless, because if these types were used somewhere in the application, the linker would fail in the mark step, when trying to resolve the typereference to them - also added throwing the LoadException in case of missing non-nested forwarded exported types, instead of just crashing with System.NullReferenceException
Diffstat (limited to 'linker')
-rw-r--r--linker/Mono.Linker.Steps/ResolveFromAssemblyStep.cs13
1 files changed, 13 insertions, 0 deletions
diff --git a/linker/Mono.Linker.Steps/ResolveFromAssemblyStep.cs b/linker/Mono.Linker.Steps/ResolveFromAssemblyStep.cs
index 34645b7a4..b7a4d44e8 100644
--- a/linker/Mono.Linker.Steps/ResolveFromAssemblyStep.cs
+++ b/linker/Mono.Linker.Steps/ResolveFromAssemblyStep.cs
@@ -123,6 +123,19 @@ namespace Mono.Linker.Steps
} catch (AssemblyResolutionException) {
continue;
}
+ if (resolvedExportedType == null) {
+ // we ignore the nested forwarders here as a workaround for older csc bug,
+ // where it was adding nested forwarders to exported types, even when the nested type was not public
+ // see https://bugzilla.xamarin.com/show_bug.cgi?id=57645#c13
+ if (exported.DeclaringType != null) {
+ if (context.LogInternalExceptions)
+ System.Console.WriteLine ($"warning: unable to resolve exported nested type: {exported} (declaring type: {exported.DeclaringType}) from the assembly: {assembly}");
+
+ continue;
+ }
+ throw new LoadException ($"unable to resolve exported forwarded type: {exported} from the assembly: {assembly}");
+ }
+
context.Resolve (resolvedExportedType.Scope);
MarkType (context, resolvedExportedType, rootVisibility);
context.Annotations.Mark (exported);