예제 #1
0
        private ProjectFileInfo CreateProjectFileInfo(ErgonProjectInstance 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);
            }

            // 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 (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));
        }
예제 #2
0
        public static string ReadItemsAsString(this ErgonProjectInstance executedProject, string itemType)
        {
            var pooledBuilder = PooledStringBuilder.GetInstance();
            var builder       = pooledBuilder.Builder;

            foreach (var item in executedProject.GetItems(itemType))
            {
                if (builder.Length > 0)
                {
                    builder.Append(" ");
                }

                builder.Append(item.EvaluatedInclude);
            }

            return(pooledBuilder.ToStringAndFree());
        }
예제 #3
0
        private ImmutableArray <string> GetCommandLineArgs(ErgonProjectInstance project)
        {
            var commandLineArgs = GetCompilerCommandLineArgs(project)
                                  .Select(item => item.ItemSpec)
                                  .ToImmutableArray();

            if (commandLineArgs.Length == 0)
            {
                // We didn't get any command-line args, which likely means that the build
                // was not successful. In that case, try to read the command-line args from
                // the ProjectInstance that we have. This is a best effort to provide something
                // meaningful for the user, though it will likely be incomplete.
                commandLineArgs = ReadCommandLineArgs(project);
            }

            return(commandLineArgs);
        }
예제 #4
0
 public static int ReadPropertyInt(this ErgonProjectInstance executedProject, string propertyName)
 => Conversions.ToInt(executedProject.ReadPropertyString(propertyName));
예제 #5
0
 public static bool ReadPropertyBool(this ErgonProjectInstance executedProject, string propertyName)
 => Conversions.ToBool(executedProject.ReadPropertyString(propertyName));
예제 #6
0
 public static string ReadPropertyString(this ErgonProjectInstance executedProject, string propertyName)
 => executedProject.GetProperty(propertyName)?.EvaluatedValue;
예제 #7
0
 public static IEnumerable <ProjectFileReference> GetProjectReferences(this ErgonProjectInstance executedProject)
 => executedProject
 .GetItems(ItemNames.ProjectReference)
 .Where(i => i.ReferenceOutputAssemblyIsTrue())
 .Select(CreateProjectFileReference);
 public static ImmutableArray <string> Read(ErgonProjectInstance project)
 {
     return(new ErgonCommandLineArgumentReader(project).Read());
 }
예제 #9
0
 protected override IEnumerable <ITaskItem> GetCompilerCommandLineArgs(ErgonProjectInstance executedProject)
 => executedProject.GetItems(ItemNames.StarkcCommandLineArgs);
예제 #10
0
 public static IEnumerable <ITaskItem> GetAdditionalFiles(this ErgonProjectInstance executedProject)
 => executedProject.GetItems(ItemNames.AdditionalFiles);
예제 #11
0
 protected abstract ImmutableArray <string> ReadCommandLineArgs(ErgonProjectInstance project);
예제 #12
0
 protected abstract IEnumerable <ITaskItem> GetCompilerCommandLineArgs(ErgonProjectInstance executedProject);
예제 #13
0
 protected CommandLineArgumentReader(ErgonProjectInstance project)
 {
     Project  = project;
     _builder = ImmutableArray.CreateBuilder <string>();
 }
예제 #14
0
 public static ulong ReadPropertyULong(this ErgonProjectInstance executedProject, string propertyName)
 => Conversions.ToULong(executedProject.ReadPropertyString(propertyName));
예제 #15
0
 public static IEnumerable <ITaskItem> GetAnalyzers(this ErgonProjectInstance executedProject)
 => executedProject.GetItems(ItemNames.Analyzer);
예제 #16
0
 public static TEnum?ReadPropertyEnum <TEnum>(this ErgonProjectInstance executedProject, string propertyName, bool ignoreCase)
     where TEnum : struct
 => Conversions.ToEnum <TEnum>(executedProject.ReadPropertyString(propertyName), ignoreCase);
예제 #17
0
 public static IEnumerable <ITaskItem> GetDocuments(this ErgonProjectInstance executedProject)
 => executedProject.GetItems(ItemNames.Compile);
예제 #18
0
 public static IEnumerable <ITaskItem> GetTaskItems(this ErgonProjectInstance executedProject, string itemType)
 => executedProject.GetItems(itemType);
예제 #19
0
 public static IEnumerable <ITaskItem> GetMetadataReferences(this ErgonProjectInstance executedProject)
 => executedProject.GetItems(ItemNames.ReferencePath);
예제 #20
0
 protected override ImmutableArray <string> ReadCommandLineArgs(ErgonProjectInstance project)
 => ErgonCommandLineArgumentReader.Read(project);
 private ErgonCommandLineArgumentReader(ErgonProjectInstance project)
     : base(project)
 {
 }