From df81fe40c5f3324d2aad9caccf85a04142aa9cc3 Mon Sep 17 00:00:00 2001 From: Sebastien Pouliot Date: Fri, 16 Dec 2016 11:13:57 -0500 Subject: Fix marking types inside custom attributes. Fixes #47064 (#4126) The existing code for marking custom attributes was only marking the type and the lowest element type, i.e. marking (1) would also mark (3) but would miss (2). 1. [System.ServiceModel.ServiceKnownTypeAttribute(typeof(System.Collections.Generic.Dictionary[][]))] 2. [System.ServiceModel.ServiceKnownTypeAttribute(typeof(System.Collections.Generic.Dictionary[]))] 3. [System.ServiceModel.ServiceKnownTypeAttribute(typeof(System.Collections.Generic.Dictionary))] That's generally not an issue since the type is marked (elsewhere). However, in the case of custom attributes, we need to update the Scope to what was resolved (and that was missed). That lack of updated Scope means that a PCL assembly would still keep references to System.Runtime, which is something that the linker is eliminating (causing a TypeLoadException at runtime) reference: * https://bugzilla.xamarin.com/show_bug.cgi?id=47064 Note: The linker is not in mono/master and there's a PR in the new linker repo for the same https://github.com/mono/linker/pull/7 --- mcs/tools/linker/Mono.Linker.Steps/MarkStep.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mcs/tools/linker/Mono.Linker.Steps/MarkStep.cs b/mcs/tools/linker/Mono.Linker.Steps/MarkStep.cs index 9bf293d7f13..5c205f37911 100644 --- a/mcs/tools/linker/Mono.Linker.Steps/MarkStep.cs +++ b/mcs/tools/linker/Mono.Linker.Steps/MarkStep.cs @@ -372,7 +372,7 @@ namespace Mono.Linker.Steps { // e.g. System.String[] -> System.String var ts = (type as TypeSpecification); if (ts != null) { - MarkWithResolvedScope (ts.GetElementType ()); + MarkWithResolvedScope (ts.ElementType); return; } -- cgit v1.2.3