[linker] match type pattern with nested types
authorRadek Doulik <rodo@xamarin.com>
Tue, 27 Oct 2015 17:23:41 +0000 (18:23 +0100)
committerRadek Doulik <rodo@xamarin.com>
Tue, 27 Oct 2015 17:32:28 +0000 (18:32 +0100)
 - this way the following xml will match all the types in the assembly
   MyAssembly

    <linker>
        <assembly fullname="MyAssembly">
            <namespace type="*" />
        </assembly>
    </linker>

   before this change it will only match the types defined in main
   module and none of the nested types

mcs/tools/linker/Mono.Linker.Steps/ResolveFromXmlStep.cs

index a0fe3934cac49a2b6e37f020a10d14b5033355bb..6a797c16e4ecd0baeb9d8ac9945c2729f4a9a84b 100644 (file)
@@ -129,15 +129,24 @@ namespace Mono.Linker.Steps {
                        return new Regex (pattern.Replace(".", @"\.").Replace("*", "(.*)"));
                }
 
+               void MatchType (TypeDefinition type, Regex regex, XPathNavigator nav)
+               {
+                       if (regex.Match (type.FullName).Success)
+                               ProcessType (type, nav);
+
+                       if (!type.HasNestedTypes)
+                               return;
+
+                       foreach (var nt in type.NestedTypes)
+                               MatchType (nt, regex, nav);
+               }
+
                void ProcessTypePattern (string fullname, AssemblyDefinition assembly, XPathNavigator nav)
                {
                        Regex regex = CreateRegexFromPattern (fullname);
 
                        foreach (TypeDefinition type in assembly.MainModule.Types) {
-                               if (!regex.Match (type.FullName).Success)
-                                       continue;
-
-                               ProcessType (type, nav);
+                               MatchType (type, regex, nav);
                        }
                }