public ProjectImportElement AddImport(string project) { var import = ContainingProject.CreateImportElement(project); AppendChild(import); return(import); }
public UsingTaskParameterGroupElement AddParameterGroup() { var @group = ContainingProject.CreateUsingTaskParameterGroupElement(); PrependChild(@group); return(@group); }
internal override ProjectElement LoadChildElement(XmlReader reader) { var item = ContainingProject.CreateItemElement(reader.LocalName); AppendChild(item); return(item); }
public ProjectPropertyGroupElement AddPropertyGroup() { var property = ContainingProject.CreatePropertyGroupElement(); AppendChild(property); return(property); }
public ProjectUsingTaskBodyElement AddUsingTaskBody(string evaluate, string taskBody) { var body = ContainingProject.CreateUsingTaskBodyElement(evaluate, taskBody); AppendChild(body); return(body); }
public ProjectMetadataElement AddMetadata(string name, string unevaluatedValue) { var metadata = ContainingProject.CreateMetadataElement(name, unevaluatedValue); AppendChild(metadata); return(metadata); }
internal override ProjectElement LoadChildElement(string name) { var item = ContainingProject.CreateItemElement(name); AppendChild(item); return(item); }
internal override ProjectElement LoadChildElement(XmlReader reader) { var metadata = ContainingProject.CreateMetadataElement(reader.LocalName); AppendChild(metadata); return(metadata); }
public ProjectItemGroupElement AddItemGroup() { var item = ContainingProject.CreateItemGroupElement(); AppendChild(item); return(item); }
public ProjectTaskElement AddTask(string taskName) { var task = ContainingProject.CreateTaskElement(taskName); AppendChild(task); return(task); }
public ProjectItemDefinitionElement AddItemDefinition(string itemType) { var definition = ContainingProject.CreateItemDefinitionElement(itemType); AppendChild(definition); return(definition); }
internal override ProjectElement LoadChildElement(string name) { var metadata = ContainingProject.CreateMetadataElement(name); AppendChild(metadata); return(metadata); }
public ProjectPropertyElement AddProperty(string name, string unevaluatedValue) { var property = ContainingProject.CreatePropertyElement(name); property.Value = unevaluatedValue; AppendChild(property); return(property); }
public ProjectUsingTaskParameterElement AddParameter(string name, string output, string required, string parameterType) { var parameter = ContainingProject.CreateUsingTaskParameterElement(name, output, required, parameterType); AppendChild(parameter); return(parameter); }
/// <summary> /// Convenience method to add a task to this target. /// Adds after any existing task. /// </summary> public ProjectTaskElement AddTask(string taskName) { ErrorUtilities.VerifyThrowArgumentLength(taskName, nameof(taskName)); ProjectTaskElement task = ContainingProject.CreateTaskElement(taskName); AppendChild(task); return(task); }
public ProjectImportElement AddImport(string project) { ErrorUtilities.VerifyThrowArgumentLength(project, nameof(project)); ProjectImportElement newImport = ContainingProject.CreateImportElement(project); AppendChild(newImport); return(newImport); }
/// <summary> /// Convenience method that picks a location based on a heuristic: /// </summary> public ProjectUsingTaskParameterElement AddParameter(string name, string output, string required, string parameterType) { ErrorUtilities.VerifyThrowArgumentLength(name, "name"); ProjectUsingTaskParameterElement newParameter = ContainingProject.CreateUsingTaskParameterElement(name, output, required, parameterType); AppendChild(newParameter); return(newParameter); }
Document GetOpenDocument() { IViewContent view = ContainingProject.GetOpenFile(FileName); if (view != null) { return(new Document(FileName, view)); } return(null); }
public ProjectPropertyElement AddProperty(string name, string unevaluatedValue) { ErrorUtilities.VerifyThrowArgumentLength(name, nameof(name)); ErrorUtilities.VerifyThrowArgumentNull(unevaluatedValue, nameof(unevaluatedValue)); ProjectPropertyElement newProperty = ContainingProject.CreatePropertyElement(name); newProperty.Value = unevaluatedValue; AppendChild(newProperty); return(newProperty); }
public EnumerationMapping GetReferencedEnumerationMapping() { if (!this.IsReference) { return(null); } return(ContainingProject .FindTableMapping(this.ReferencedConnectionName, this.ReferencedTableMappingSchemaName, this.ReferencedTableMappingName) .FindColumnMapping(this.ReferencedColumnName) .EnumerationMapping); }
/// <summary> /// Convenience method to add a piece of metadata to this item definition. /// Adds after any existing metadata. Does not modify any existing metadata. /// </summary> public ProjectMetadataElement AddMetadata(string name, string unevaluatedValue) { ErrorUtilities.VerifyThrowArgumentLength(name, "name"); ErrorUtilities.VerifyThrowArgumentNull(unevaluatedValue, "unevaluatedValue"); ProjectMetadataElement metadata = ContainingProject.CreateMetadataElement(name); metadata.Value = unevaluatedValue; AppendChild(metadata); return(metadata); }
/// <summary> /// Convenience method to add a conditioned Output Item to this task. /// Adds after the last child. /// </summary> public ProjectOutputElement AddOutputItem(string taskParameter, string itemType, string condition) { ProjectOutputElement outputItem = ContainingProject.CreateOutputElement(taskParameter, itemType, null); if (condition != null) { outputItem.Condition = condition; } AppendChild(outputItem); return(outputItem); }
/// <summary> /// Convenience method to add a conditioned Output Property to this task. /// Adds after the last child. /// </summary> public ProjectOutputElement AddOutputProperty(string taskParameter, string propertyName, string condition) { ProjectOutputElement outputProperty = ContainingProject.CreateOutputElement(taskParameter, null, propertyName); if (condition != null) { outputProperty.Condition = condition; } AppendChild(outputProperty); return(outputProperty); }
/// <summary> /// Convenience method that picks a location based on a heuristic: /// Adds a new item ordered by include. /// Metadata may be null, indicating no metadata. /// </summary> public ProjectItemElement AddItem(string itemType, string include, IEnumerable <KeyValuePair <string, string> > metadata) { ErrorUtilities.VerifyThrowArgumentLength(itemType, "itemType"); ErrorUtilities.VerifyThrowArgumentLength(include, "include"); // If there are no items, or it turns out that there are only items with // item types that sort earlier, then we should go after the last child ProjectElement reference = LastChild; foreach (ProjectItemElement item in Items) { // If it's the same item type, and if (MSBuildNameIgnoreCaseComparer.Default.Equals(itemType, item.ItemType)) { // the include sorts after us, if (String.Compare(include, item.Include, StringComparison.OrdinalIgnoreCase) < 0) { // then insert before it (ie. after the previous sibling) reference = item.PreviousSibling; break; } // Otherwise go to the next item continue; } // If it's an item type that sorts after us, if (String.Compare(itemType, item.ItemType, StringComparison.OrdinalIgnoreCase) < 0) { // then insert before it (ie. after the previous sibling) reference = item.PreviousSibling; break; } } ProjectItemElement newItem = ContainingProject.CreateItemElement(itemType, include); // If reference is null, this will prepend InsertAfterChild(newItem, reference); if (metadata != null) { foreach (KeyValuePair <string, string> metadatum in metadata) { newItem.AddMetadata(metadatum.Key, metadatum.Value); } } return(newItem); }
internal override ProjectElement LoadChildElement(string name) { switch (name) { case "Output": var output = ContainingProject.CreateOutputElement(null, null, null); AppendChild(output); return(output); default: throw new InvalidProjectFileException(string.Format( "Child \"{0}\" is not a known node type.", name)); } }
internal override ProjectElement LoadChildElement(string name) { switch (name) { case "Otherwise": var other = ContainingProject.CreateOtherwiseElement(); AppendChild(other); return(other); case "When": var when = ContainingProject.CreateWhenElement(null); PrependChild(when); return(when); default: throw new InvalidProjectFileException(string.Format( "Child \"{0}\" is not a known node type.", name)); } }
public ProjectMetadataElement AddMetadata(string name, string unevaluatedValue, bool expressAsAttribute) { ErrorUtilities.VerifyThrowArgumentLength(name, nameof(name)); ErrorUtilities.VerifyThrowArgumentNull(unevaluatedValue, nameof(unevaluatedValue)); if (expressAsAttribute) { ProjectMetadataElement.ValidateValidMetadataAsAttributeName(name, ElementName, Location); } ProjectMetadataElement metadata = ContainingProject.CreateMetadataElement(name); metadata.Value = unevaluatedValue; metadata.ExpressedAsAttribute = expressAsAttribute; AppendChild(metadata); return(metadata); }
public ProjectItemElement AddItem(string itemType, string include, IEnumerable <KeyValuePair <string, string> > metadata) { var item = ContainingProject.CreateItemElement(itemType, include); if (metadata != null) { foreach (var data in metadata) { item.AddMetadata(data.Key, data.Value); } } var lastChild = LastChild; foreach (var existingItem in Items) { var compare = string.Compare(item.ItemType, existingItem.ItemType, StringComparison.OrdinalIgnoreCase); if (compare == 0) { if (string.Compare(item.Include, existingItem.Include, StringComparison.OrdinalIgnoreCase) >= 0) { continue; } lastChild = existingItem.PreviousSibling; break; } if (compare < 0) { lastChild = existingItem.PreviousSibling; break; } } InsertAfterChild(item, lastChild); return(item); }
//TODO: Test what happens if multiple instances of VisualStudio run... public RoslynIntrospector(Project project) { if (workspace == null) { workspace = project.Solution.Workspace; } if (solution == null) { solution = workspace.CurrentSolution; UpdateProjectCompilations(project); } else if (ContainingProject.Equals(project.Id)) { var changes = project.Solution.GetChanges(solution); foreach (var removedProject in changes.GetRemovedProjects()) { projectCompilations.Remove(removedProject.Id); } foreach (var addedProject in changes.GetAddedProjects()) { projectCompilations.Add(addedProject.Id, GetCompilationForProject(addedProject)); } foreach (var projectChanges in changes.GetProjectChanges()) { //Bruteforce way: Just get the new compilation... //If that does not scale try adding documents to the compilation (incremental update) projectCompilations[projectChanges.ProjectId] = GetCompilationForProject(projectChanges.NewProject); } solution = project.Solution; } else {//Solution and workspace does not change but project does and so do the dependencies. //We then need different projects in the projectCompilations Dictionary UpdateProjectCompilations(project); workspace = project.Solution.Workspace; solution = workspace.CurrentSolution; } ContainingProject = project.Id; }
internal override ProjectElement LoadChildElement(XmlReader reader) { switch (reader.LocalName) { case "PropertyGroup": var property = ContainingProject.CreatePropertyGroupElement(); AppendChild(property); return(property); case "ItemGroup": var item = ContainingProject.CreateItemGroupElement(); AppendChild(item); return(item); case "When": var when = ContainingProject.CreateWhenElement(null); AppendChild(when); return(when); default: throw new InvalidProjectFileException(string.Format( "Child \"{0}\" is not a known node type.", reader.LocalName)); } }