private static void ResolveNamespace(Project project, Project reference, HashSet <FileDescriptor> referenceAssemblies) { foreach (ReferenceNode tmp in reference.Files.Nodes) { if (tmp is SharpReferenceNode) { SharpReferenceNode node = (tmp as SharpReferenceNode); foreach (KeyValuePair <int, string> @using in node.NamespaceReferences) { if (@using.Value != "System") { List <FileDescriptor> assemblies; if (SharpAnalyzer.AssemblyResolver.TryGetAssemblies(@using.Value.Fnv32(), out assemblies)) { foreach (FileDescriptor assembly in assemblies) { if (!referenceAssemblies.Contains(assembly)) { project.Externals.Add(assembly); referenceAssemblies.Add(assembly); } } } } } } } }
public static Project CreateProject(UInt32 tag, PathDescriptor location, List <FileSystemDescriptor> files) { Project project = new Project(tag, location); files.ParallelFor((file) => { SharpReferenceNode node = new SharpReferenceNode(file as FileDescriptor); node.FetchExports(); lock (project) { project.Files.Nodes.Add(node); foreach (KeyValuePair <int, string> type in node.Declarations) { project.Files[type.Value].Add(node); } } if (node.Flags.Count != 0) { lock (project) project.AssemblyType = (OutputAssemblyType)node.Flags[0]; } }); ProjectAnalyzer.AddProjectFiles(project); return(project); }
public static void ConnectNodes(Project project, SharpReferenceNode node, Project graph, bool connectNamespaces) { foreach (KeyValuePair <int, string> reference in node.TypeReferences) { List <ReferenceNode> types; if (graph.Files.TryGetType(reference.Value, out types)) { KeyValuePair <int, string> @namespace = node.GetDeclaringNamespace(reference); foreach (ReferenceNode rtmp in types) { bool isNamespaceRoot = !string.IsNullOrWhiteSpace(@namespace.Value) && [email protected]("."); SharpReferenceNode @ref = (rtmp as SharpReferenceNode); foreach (KeyValuePair <int, string> nmsp in @ref.GetDeclaringNamespaces(reference.Value)) { bool match; if (isNamespaceRoot) { match = @namespace.Value == nmsp.Value; } else { match = MatchesNamespace(@namespace.Value, nmsp.Value); } if (match) { node.AddDependency(@ref); if (project != graph) { lock (project) if (!project.References.Contains(graph)) { project.References.Add(graph); } } continue; } } } } } if (connectNamespaces) { graph.Files.Nodes.ParallelFor((rtmp) => { bool connected; SharpReferenceNode @ref = (rtmp as SharpReferenceNode); foreach (KeyValuePair <int, string> @namespace in node.NamespaceReferences) { connected = false; bool isNamespaceRoot = [email protected]("."); foreach (KeyValuePair <int, string> nmsp in @ref.Namespaces) { bool match; if (isNamespaceRoot) { match = @namespace.Value == nmsp.Value; } else { match = MatchesNamespace(@namespace.Value, nmsp.Value); } if (match) { connected = true; node.AddDependency(@ref); if (project != graph) { lock (project) if (!project.References.Contains(graph)) { project.References.Add(graph); } } break; } } if (connected) { break; } } }); } }