[linker] Resolve types inside custom attributes since they might refer to types in...
[mono.git] / mcs / tools / linker / Mono.Linker.Steps / MarkStep.cs
index 18f34bdc9c8f7e623425f33fdb470023479aa0a0..8525256e68fcca193352a79995e62a471dfd5f7b 100644 (file)
@@ -277,13 +277,23 @@ namespace Mono.Linker.Steps {
 
                                MarkType (et);
                                foreach (var cac in (CustomAttributeArgument[]) argument.Value)
-                                       MarkType ((TypeReference) cac.Value);
+                                       MarkWithResolvedScope ((TypeReference) cac.Value);
                        } else if (at.Namespace == "System" && at.Name == "Type") {
                                MarkType (argument.Type);
-                               MarkType ((TypeReference) argument.Value);
+                               MarkWithResolvedScope ((TypeReference) argument.Value);
                        }
                }
 
+               // custom attributes encoding means it's possible to have a scope that will point into a PCL facade
+               // even if we (just before saving) will resolve all type references (bug #26752)
+               void MarkWithResolvedScope (TypeReference type)
+               {
+                       var td = type.Resolve ();
+                       if (td != null)
+                               type.Scope = td.Scope;
+                       MarkType (type);
+               }
+
                protected bool CheckProcessed (IMetadataTokenProvider provider)
                {
                        if (Annotations.IsProcessed (provider))