コード例 #1
0
        private ProjectFileInfo CreateProjectFileInfo(MSB.Execution.ProjectInstance project)
        {
            var commandLineArgs = GetCommandLineArgs(project);

            var outputFilePath = project.ReadPropertyString(PropertyNames.TargetPath);

            if (!RoslynString.IsNullOrWhiteSpace(outputFilePath))
            {
                outputFilePath = GetAbsolutePathRelativeToProject(outputFilePath);
            }

            var outputRefFilePath = project.ReadPropertyString(PropertyNames.TargetRefPath);

            if (!RoslynString.IsNullOrWhiteSpace(outputRefFilePath))
            {
                outputRefFilePath = GetAbsolutePathRelativeToProject(outputRefFilePath);
            }

            // Right now VB doesn't have the concept of "default namespace". But we conjure one in workspace
            // by assigning the value of the project's root namespace to it. So various feature can choose to
            // use it for their own purpose.
            // In the future, we might consider officially exposing "default namespace" for VB project
            // (e.g. through a <defaultnamespace> msbuild property)
            var defaultNamespace = project.ReadPropertyString(PropertyNames.RootNamespace) ?? string.Empty;

            var targetFramework = project.ReadPropertyString(PropertyNames.TargetFramework);

            if (RoslynString.IsNullOrWhiteSpace(targetFramework))
            {
                targetFramework = null;
            }

            var docs = project.GetDocuments()
                       .Where(IsNotTemporaryGeneratedFile)
                       .Select(MakeDocumentFileInfo)
                       .ToImmutableArray();

            var additionalDocs = project.GetAdditionalFiles()
                                 .Select(MakeNonSourceFileDocumentFileInfo)
                                 .ToImmutableArray();

            var analyzerConfigDocs = project.GetEditorConfigFiles()
                                     .Select(MakeNonSourceFileDocumentFileInfo)
                                     .ToImmutableArray();

            return(ProjectFileInfo.Create(
                       Language,
                       project.FullPath,
                       outputFilePath,
                       outputRefFilePath,
                       defaultNamespace,
                       targetFramework,
                       commandLineArgs,
                       docs,
                       additionalDocs,
                       analyzerConfigDocs,
                       project.GetProjectReferences().ToImmutableArray(),
                       Log));
        }