Example #1
0
        private static ProjectData CreateProjectData(ProjectInstance projectInstance, ImmutableArray <string> targetFrameworks)
        {
            var guid              = PropertyConverter.ToGuid(projectInstance.GetPropertyValue(PropertyNames.ProjectGuid));
            var name              = projectInstance.GetPropertyValue(PropertyNames.ProjectName);
            var assemblyName      = projectInstance.GetPropertyValue(PropertyNames.AssemblyName);
            var targetPath        = projectInstance.GetPropertyValue(PropertyNames.TargetPath);
            var outputPath        = projectInstance.GetPropertyValue(PropertyNames.OutputPath);
            var projectAssetsFile = projectInstance.GetPropertyValue(PropertyNames.ProjectAssetsFile);

            var targetFramework = new FrameworkName(projectInstance.GetPropertyValue(PropertyNames.TargetFrameworkMoniker));

            var languageVersion           = PropertyConverter.ToLanguageVersion(projectInstance.GetPropertyValue(PropertyNames.LangVersion));
            var allowUnsafeCode           = PropertyConverter.ToBoolean(projectInstance.GetPropertyValue(PropertyNames.AllowUnsafeBlocks), defaultValue: false);
            var outputKind                = PropertyConverter.ToOutputKind(projectInstance.GetPropertyValue(PropertyNames.OutputType));
            var documentationFile         = projectInstance.GetPropertyValue(PropertyNames.DocumentationFile);
            var preprocessorSymbolNames   = PropertyConverter.ToPreprocessorSymbolNames(projectInstance.GetPropertyValue(PropertyNames.DefineConstants));
            var suppressDiagnosticIds     = PropertyConverter.ToSuppressDiagnosticIds(projectInstance.GetPropertyValue(PropertyNames.NoWarn));
            var signAssembly              = PropertyConverter.ToBoolean(projectInstance.GetPropertyValue(PropertyNames.SignAssembly), defaultValue: false);
            var assemblyOriginatorKeyFile = projectInstance.GetPropertyValue(PropertyNames.AssemblyOriginatorKeyFile);

            var sourceFiles       = GetFullPaths(projectInstance.GetItems(ItemNames.Compile));
            var projectReferences = GetFullPaths(projectInstance.GetItems(ItemNames.ProjectReference));
            var references        = GetFullPaths(
                projectInstance.GetItems(ItemNames.ReferencePath).Where(ReferenceSourceTargetIsNotProjectReference));
            var packageReferences = GetPackageReferences(projectInstance.GetItems(ItemNames.PackageReference));
            var analyzers         = GetFullPaths(projectInstance.GetItems(ItemNames.Analyzer));

            return(new ProjectData(guid, name,
                                   assemblyName, targetPath, outputPath, projectAssetsFile,
                                   targetFramework, targetFrameworks,
                                   outputKind, languageVersion, allowUnsafeCode, documentationFile, preprocessorSymbolNames, suppressDiagnosticIds,
                                   signAssembly, assemblyOriginatorKeyFile,
                                   sourceFiles, projectReferences, references, packageReferences, analyzers));
        }