Ejemplo n.º 1
0
        public InheritMap(Project project)
        {
            this.project = project;

            // cache for assemblies not in the project
            AssemblyCache cache = new AssemblyCache (project);
            //string[] lPaths = project.
            cache.ExtraFolders.AddRange (project.ExtraPaths);

            foreach (AssemblyInfo info in project) {
                cache.ExtraFolders.Add (System.IO.Path.GetDirectoryName (info.Filename));
                foreach (TypeDefinition type in info.GetAllTypeDefinitions()) {
                    if (type.FullName == "<Module>")
                        continue;

                    TypeKey typeKey = new TypeKey (type);

                    baseTypes [typeKey] = GetBaseTypes (type);

                    int i = 0;
                    int j;

                    MethodKey[] methods = GetVirtualMethods (cache, type);
                    while (i < methods.Length) {
                        MethodGroup group;
                        if (!methodGroups.TryGetValue (methods [i], out group))
                            group = null;

                        for (j = i + 1; j < methods.Length; j++) {
                            if (!MethodsMatch(methods, i, j))
                                continue;

                            // found an override

                            // see if either method is already in a group
                            if (group != null)
                                group = AddToGroup (group, methods [j]);
                            else if (methodGroups.TryGetValue (methods [j], out group))
                                group = AddToGroup (group, methods [i]);
                            else {
                                group = new MethodGroup ();

                                group = AddToGroup (group, methods [i]);
                                group = AddToGroup (group, methods [j]);
                            }

                            // if the group isn't already external, see if it should be
                            Debug.Assert (group != null, "should have a group by now");
                            if (!group.External && !project.Contains (methods [j].TypeKey))
                                group.External = true;
                        }

                        // if the group isn't already external, see if it should be
                        if (group != null && !group.External && !project.Contains (methods [i].TypeKey))
                            group.External = true;

                        // move on to the next thing that doesn't match
                        i++;
                    }
                }
            }
        }
Ejemplo n.º 2
0
        MethodGroup AddToGroup(MethodGroup group, MethodKey methodKey)
        {
            // add the method to the group
            group.Methods.Add (methodKey);

            // point the method at the group
            MethodGroup group2;
            if (methodGroups.TryGetValue (methodKey, out group2) && group2 != group) {
                // we have a problem; two unrelated groups come together; merge them
                if (group.Methods.Count > group2.Methods.Count) {
                    group.Name = group.Name ?? group2.Name;
                    group.External = group.External | group2.External;
                    foreach (MethodKey mk in group2.Methods) {
                        methodGroups [mk] = group;
                        group.Methods.Add (mk);

                    }
                    return group;
                } else {
                    group2.Name = group2.Name ?? group.Name;
                    group2.External = group2.External | group.External;
                    foreach (MethodKey mk in group.Methods) {
                        methodGroups [mk] = group2;
                        group2.Methods.Add (mk);

                    }
                    return group2;
                }
            }
            methodGroups [methodKey] = group;

            return group;
        }
Ejemplo n.º 3
0
        public InheritMap(Project project)
        {
            this.project = project;

            // cache for assemblies not in the project
            AssemblyCache cache = new AssemblyCache(project);

            //string[] lPaths = project.
            cache.ExtraFolders.AddRange(project.ExtraPaths);

            foreach (AssemblyInfo info in project)
            {
                cache.ExtraFolders.Add(System.IO.Path.GetDirectoryName(info.Filename));
                foreach (TypeDefinition type in info.GetAllTypeDefinitions())
                {
                    if (type.FullName == "<Module>")
                    {
                        continue;
                    }

                    TypeKey typeKey = new TypeKey(type);

                    baseTypes [typeKey] = GetBaseTypes(type);

                    int i = 0;
                    int j;

                    MethodKey[] methods = GetVirtualMethods(cache, type);
                    while (i < methods.Length)
                    {
                        MethodGroup group;
                        if (!methodGroups.TryGetValue(methods [i], out group))
                        {
                            group = null;
                        }

                        for (j = i + 1; j < methods.Length; j++)
                        {
                            if (!MethodsMatch(methods, i, j))
                            {
                                continue;
                            }

                            // found an override

                            // see if either method is already in a group
                            if (group != null)
                            {
                                group = AddToGroup(group, methods [j]);
                            }
                            else if (methodGroups.TryGetValue(methods [j], out group))
                            {
                                group = AddToGroup(group, methods [i]);
                            }
                            else
                            {
                                group = new MethodGroup();

                                group = AddToGroup(group, methods [i]);
                                group = AddToGroup(group, methods [j]);
                            }

                            // if the group isn't already external, see if it should be
                            Debug.Assert(group != null, "should have a group by now");
                            if (!group.External && !project.Contains(methods [j].TypeKey))
                            {
                                group.External = true;
                            }
                        }

                        // if the group isn't already external, see if it should be
                        if (group != null && !group.External && !project.Contains(methods [i].TypeKey))
                        {
                            group.External = true;
                        }

                        // move on to the next thing that doesn't match
                        i++;
                    }
                }
            }
        }
Ejemplo n.º 4
0
        public InheritMap(Project project)
        {
            this.project = project;

            // cache for assemblies not in the project
            project.Cache = new AssemblyCache(project);

            foreach (AssemblyInfo info in project)
            {
                foreach (TypeDefinition type in info.GetAllTypeDefinitions())
                {
                    if (type.FullName == "<Module>")
                    {
                        continue;
                    }

                    TypeKey typeKey = new TypeKey(type);

                    baseTypes[typeKey] = GetBaseTypes(type);

                    int i = 0;
                    int j;

                    MethodKey[] methods = GetVirtualMethods(project.Cache, type);
                    while (i < methods.Length)
                    {
                        MethodGroup group;
                        var         left = methods[i];
                        if (!methodGroups.TryGetValue(left, out group))
                        {
                            group = null;
                        }

                        for (j = i + 1; j < methods.Length; j++)
                        {
                            var right = methods[j];
                            if (!MethodsMatch(left, right))
                            {
                                continue;
                            }

                            // found an override

                            // see if either method is already in a group
                            if (group != null)
                            {
                                group = AddToGroup(group, right);
                            }
                            else if (methodGroups.TryGetValue(right, out group))
                            {
                                group = AddToGroup(group, left);
                            }
                            else
                            {
                                group = new MethodGroup();

                                group = AddToGroup(group, left);
                                group = AddToGroup(group, right);
                            }

                            // if the group isn't already external, see if it should be
                            Debug.Assert(group != null, "should have a group by now");
                            if (!group.External && !project.Contains(right.TypeKey))
                            {
                                group.External = true;
                            }
                        }

                        // if the group isn't already external, see if it should be
                        if (group != null && !group.External && !project.Contains(left.TypeKey))
                        {
                            group.External = true;
                        }

                        // move on to the next thing that doesn't match
                        i++;
                    }
                }
            }
        }
Ejemplo n.º 5
0
        public InheritMap(Project project)
        {
            this.project = project;

            // cache for assemblies not in the project
            project.Cache = new AssemblyCache (project);

            foreach (AssemblyInfo info in project) {
                foreach (TypeDefinition type in info.GetAllTypeDefinitions()) {
                    if (type.FullName == "<Module>")
                        continue;

                    TypeKey typeKey = new TypeKey (type);

                    baseTypes [typeKey] = GetBaseTypes (type);

                    int i = 0;
                    int j;

                    MethodKey[] methods = GetVirtualMethods (project.Cache, type);
                    while (i < methods.Length) {
                        MethodGroup group;
                        var left = methods [i];
                        if (!methodGroups.TryGetValue (left, out group))
                            group = null;

                        for (j = i + 1; j < methods.Length; j++) {
                            var right = methods [j];
                            if (!MethodsMatch (left, right))
                                continue;

                            // found an override

                            // see if either method is already in a group
                            if (group != null)
                                group = AddToGroup (group, right);
                            else if (methodGroups.TryGetValue (right, out group))
                                group = AddToGroup (group, left);
                            else {
                                group = new MethodGroup ();

                                group = AddToGroup (group, left);
                                group = AddToGroup (group, right);
                            }

                            // if the group isn't already external, see if it should be
                            Debug.Assert (group != null, "should have a group by now");
                            if (!group.External && !project.Contains (right.TypeKey))
                                group.External = true;
                        }

                        // if the group isn't already external, see if it should be
                        if (group != null && !group.External && !project.Contains (left.TypeKey))
                            group.External = true;

                        // move on to the next thing that doesn't match
                        i++;
                    }
                }
            }
        }