[linker] Fix scope resolution of custom attributes (generic/array) argument types...
authorSebastien Pouliot <sebastien@xamarin.com>
Fri, 10 Apr 2015 21:33:41 +0000 (17:33 -0400)
committerSebastien Pouliot <sebastien@xamarin.com>
Fri, 10 Apr 2015 21:33:41 +0000 (17:33 -0400)
mcs/tools/linker/Mono.Linker.Steps/MarkStep.cs

index b6276ac2490d3fa84f7b6297386aa13378685406..b47f8603c5a3faca95020602390ee59bc5f52643 100644 (file)
@@ -288,9 +288,25 @@ namespace Mono.Linker.Steps {
                // even if we (just before saving) will resolve all type references (bug #26752)
                void MarkWithResolvedScope (TypeReference type)
                {
-                       // we cannot set the Scope of a TypeSpecification so there's no point in resolving it
-                       if ((type == null) || (type is TypeSpecification))
+                       if (type == null)
+                               return;
+
+                       // a GenericInstanceType can could contains generic arguments with scope that
+                       // needs to be updated out of the PCL facade (bug #28823)
+                       var git = (type as GenericInstanceType);
+                       if ((git != null) && git.HasGenericArguments) {
+                               foreach (var ga in git.GenericArguments)
+                                       MarkWithResolvedScope (ga);
                                return;
+                       }
+                       // we cannot set the Scope of a TypeSpecification but it's element type can be set
+                       // e.g. System.String[] -> System.String
+                       var ts = (type as TypeSpecification);
+                       if (ts != null) {
+                               MarkWithResolvedScope (ts.GetElementType ());
+                               return;
+                       }
+
                        var td = type.Resolve ();
                        if (td != null)
                                type.Scope = td.Scope;