Exemplo n.º 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));
        }
Exemplo n.º 2
0
        private ProjectFileInfo CreateProjectFileInfo(MSB.Execution.ProjectInstance project)
        {
            var commandLineArgs = GetCommandLineArgs(project);

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

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

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

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

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

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

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

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

            return(ProjectFileInfo.Create(
                       Language,
                       project.FullPath,
                       outputFilePath,
                       outputRefFilePath,
                       targetFramework,
                       commandLineArgs,
                       docs,
                       additionalDocs,
                       project.GetProjectReferences().ToImmutableArray(),
                       Log));
        }
Exemplo n.º 3
0
        private ProjectFileInfo CreateProjectFileInfo(MSB.Execution.ProjectInstance project)
        {
            var commandLineArgs = GetCommandLineArgs(project);

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

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

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

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

            // Get the default namespace for C# project, which is a C# only concept at the moment.
            // We need the language check because "rootnamespace" property is also used in VB for
            // completely different purpose.
            string defaultNamespace = null;

            if (Language == LanguageNames.CSharp)
            {
                defaultNamespace = project.ReadPropertyString(PropertyNames.RootNamespace);
                if (string.IsNullOrWhiteSpace(defaultNamespace))
                {
                    defaultNamespace = string.Empty;
                }
            }

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

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

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

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

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