Exemple #1
0
        void SetBasicNamespace(Project project, VisualSharpProject csproj)
        {
            Dictionary <string, int> gatherer = new Dictionary <string, int>();

            foreach (ReferenceNode node in project.Files.Nodes)
            {
                foreach (KeyValuePair <int, string> @namespace in (node as SharpAnalyzer.SharpReferenceNode).Namespaces)
                {
                    string tmp = gatherer.Keys.Where(x => SharpAnalyzer.DependencyResolver.MatchesNamespace(x, @namespace.Value)).FirstOrDefault();
                    if (string.IsNullOrWhiteSpace(tmp))
                    {
                        tmp = @namespace.Value;
                    }

                    int count; bool hasKey = gatherer.TryGetValue(tmp, out count);
                    count++;

                    if (hasKey)
                    {
                        gatherer[tmp] = count;
                    }
                    else
                    {
                        gatherer.Add(tmp, count);
                    }
                }
            }

            csproj.RootNamespace = gatherer.Keys.MostCommon().Trim('.');
        }
Exemple #2
0
        public override void Execute()
        {
            LoadInput();

            Project            project = inputPins[0].Data as Project;
            VisualSharpProject csproj  = new VisualSharpProject(version, project.Files.Nodes.Select(x => x.File), project.Location, project.Name);

            csproj.AssemblyName = project.AssemblyName;

            csproj.IsModule = project.IsModule;
            using (new Scope(builtStateCompleteLock))
                builtStateComplete.Add(project, csproj);

            foreach (BuildMode configuration in SharpAnalyzer.Analyzer.GetProjectConfigurations())
            {
                csproj.BuildTargets.Add(new BuildTarget(ToolsPlatform, TargetArchitecture.x64, configuration));
            }
            csproj.OutputType = project.AssemblyType;

            csproj.OutputPath = Application.GetDeploymentPath(project.Location);

            HashSet <Project> references = new HashSet <Project>();

            foreach (Project reference in project.References)
            {
                AddReference(csproj, reference, references);
            }

            foreach (FileDescriptor assembly in project.Externals)
            {
                if (!csproj.Dependencies.Contains(assembly))
                {
                    csproj.Dependencies.Add(assembly);
                }
            }

            Application.Log(SeverityFlags.Minimal, "Creating {0} project {1}", version.Flag.ToString(), csproj.FullName);

            SetBasicNamespace(project, csproj);
            csproj.CreateFile();

            outputPins[0].Data = csproj;
        }
Exemple #3
0
        void AddReference(VisualSharpProject csproj, Project reference, HashSet <Project> references)
        {
            if (reference.IsModule)
            {
                if (!references.Contains(reference))
                {
                    references.Add(reference);

                    bool appDirectory = reference.Name == "App";
                    foreach (ReferenceNode node in reference.Files.Nodes)
                    {
                        if (appDirectory)
                        {
                            csproj.Links.Add(node.File, node.File.GetRelativePath(reference.Location.Parent));
                        }
                        else
                        {
                            csproj.Links.Add(node.File, node.File.GetRelativePath(ModulesPath.Parent));
                        }
                    }

                    foreach (Project tmp in reference.References)
                    {
                        AddReference(csproj, tmp, references);
                    }
                }
            }
            else if (!references.Contains(reference))
            {
                references.Add(reference);

                VisualSharpProject tmp; if (builtStateComplete.TryGetValue(reference, out tmp))
                {
                    csproj.ProjectReferences.Add(tmp);
                }
            }
        }