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)); }
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()); }
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); }
public static int ReadPropertyInt(this ErgonProjectInstance executedProject, string propertyName) => Conversions.ToInt(executedProject.ReadPropertyString(propertyName));
public static bool ReadPropertyBool(this ErgonProjectInstance executedProject, string propertyName) => Conversions.ToBool(executedProject.ReadPropertyString(propertyName));
public static string ReadPropertyString(this ErgonProjectInstance executedProject, string propertyName) => executedProject.GetProperty(propertyName)?.EvaluatedValue;
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()); }
protected override IEnumerable <ITaskItem> GetCompilerCommandLineArgs(ErgonProjectInstance executedProject) => executedProject.GetItems(ItemNames.StarkcCommandLineArgs);
public static IEnumerable <ITaskItem> GetAdditionalFiles(this ErgonProjectInstance executedProject) => executedProject.GetItems(ItemNames.AdditionalFiles);
protected abstract ImmutableArray <string> ReadCommandLineArgs(ErgonProjectInstance project);
protected abstract IEnumerable <ITaskItem> GetCompilerCommandLineArgs(ErgonProjectInstance executedProject);
protected CommandLineArgumentReader(ErgonProjectInstance project) { Project = project; _builder = ImmutableArray.CreateBuilder <string>(); }
public static ulong ReadPropertyULong(this ErgonProjectInstance executedProject, string propertyName) => Conversions.ToULong(executedProject.ReadPropertyString(propertyName));
public static IEnumerable <ITaskItem> GetAnalyzers(this ErgonProjectInstance executedProject) => executedProject.GetItems(ItemNames.Analyzer);
public static TEnum?ReadPropertyEnum <TEnum>(this ErgonProjectInstance executedProject, string propertyName, bool ignoreCase) where TEnum : struct => Conversions.ToEnum <TEnum>(executedProject.ReadPropertyString(propertyName), ignoreCase);
public static IEnumerable <ITaskItem> GetDocuments(this ErgonProjectInstance executedProject) => executedProject.GetItems(ItemNames.Compile);
public static IEnumerable <ITaskItem> GetTaskItems(this ErgonProjectInstance executedProject, string itemType) => executedProject.GetItems(itemType);
public static IEnumerable <ITaskItem> GetMetadataReferences(this ErgonProjectInstance executedProject) => executedProject.GetItems(ItemNames.ReferencePath);
protected override ImmutableArray <string> ReadCommandLineArgs(ErgonProjectInstance project) => ErgonCommandLineArgumentReader.Read(project);
private ErgonCommandLineArgumentReader(ErgonProjectInstance project) : base(project) { }