public static void Verify(ProjectExtensionsElement viewXml, ProjectExtensionsElement realXml, ValidationContext context = null) { if (viewXml == null && realXml == null) { return; } VerifyProjectElement(viewXml, realXml, context); Assert.Equal(realXml.Content, viewXml.Content); }
public void SetInvalidNull() { Assert.Throws <ArgumentNullException>(() => { ProjectExtensionsElement extensions = GetEmptyProjectExtensions(); extensions.Content = null; } ); }
public void SetValid() { ProjectExtensionsElement extensions = GetEmptyProjectExtensions(); Helpers.ClearDirtyFlag(extensions.ContainingProject); extensions.Content = "a<b/>c"; Assert.Equal(@"a<b xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"" />c", extensions.Content); Assert.Equal(true, extensions.ContainingProject.HasUnsavedChanges); }
public void SetValid() { ProjectExtensionsElement extensions = GetEmptyProjectExtensions(); Helpers.ClearDirtyFlag(extensions.ContainingProject); extensions.Content = "a<b/>c"; Assert.Equal(@"a<b />c", extensions.Content); Assert.True(extensions.ContainingProject.HasUnsavedChanges); }
/// <summary> /// Helper to get an empty ProjectExtensionsElement object /// </summary> private static ProjectExtensionsElement GetEmptyProjectExtensions() { string content = @" <Project xmlns='http://schemas.microsoft.com/developer/msbuild/2003'> <ProjectExtensions/> </Project> "; ProjectRootElement project = ProjectRootElement.Create(XmlReader.Create(new StringReader(content))); ProjectExtensionsElement extensions = (ProjectExtensionsElement)Helpers.GetFirst(project.Children); return(extensions); }
private static ProjectExtensionsElement GetEmptyProjectExtensions() { string content = @" <Project> <ProjectExtensions/> </Project> "; ProjectRootElement project = ProjectRootElement.Create(XmlReader.Create(new StringReader(content))); ProjectExtensionsElement extensions = (ProjectExtensionsElement)Helpers.GetFirst(project.Children); return(extensions); }
public void Read() { string content = @" <Project xmlns='http://schemas.microsoft.com/developer/msbuild/2003'> <ProjectExtensions> <a/> </ProjectExtensions> </Project> "; ProjectRootElement project = ProjectRootElement.Create(XmlReader.Create(new StringReader(content))); ProjectExtensionsElement extensions = (ProjectExtensionsElement)Helpers.GetFirst(project.Children); Assert.Equal(@"<a xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"" />", extensions.Content); }
public void Read() { string content = @" <Project> <ProjectExtensions> <a/> </ProjectExtensions> </Project> "; ProjectRootElement project = ProjectRootElement.Create(XmlReader.Create(new StringReader(content))); ProjectExtensionsElement extensions = (ProjectExtensionsElement)Helpers.GetFirst(project.Children); Assert.Equal(@"<a />", extensions.Content); }
public void SetByIdWhereItAlreadyExists() { string content = @" <Project xmlns='http://schemas.microsoft.com/developer/msbuild/2003'> <ProjectExtensions> <a>x</a> <b>y</b> </ProjectExtensions> </Project> "; ProjectRootElement project = ProjectRootElement.Create(XmlReader.Create(new StringReader(content))); ProjectExtensionsElement extensions = (ProjectExtensionsElement)Helpers.GetFirst(project.Children); extensions["b"] = "y2"; Assert.Equal("y2", extensions["b"]); }
public void SetByIdWhereItAlreadyExists() { string content = @" <Project> <ProjectExtensions> <a>x</a> <b>y</b> </ProjectExtensions> </Project> "; ProjectRootElement project = ProjectRootElement.Create(XmlReader.Create(new StringReader(content))); ProjectExtensionsElement extensions = (ProjectExtensionsElement)Helpers.GetFirst(project.Children); extensions["b"] = "y2"; Assert.Equal("y2", extensions["b"]); }
public void GetById() { string content = @" <Project xmlns='http://schemas.microsoft.com/developer/msbuild/2003'> <ProjectExtensions> <a>x</a> <b>y</b> </ProjectExtensions> </Project> "; ProjectRootElement project = ProjectRootElement.Create(XmlReader.Create(new StringReader(content))); ProjectExtensionsElement extensions = (ProjectExtensionsElement)Helpers.GetFirst(project.Children); content = extensions["b"]; Assert.Equal("y", content); content = extensions["nonexistent"]; Assert.Equal(String.Empty, content); }
public void GetById() { string content = @" <Project> <ProjectExtensions> <a>x</a> <b>y</b> </ProjectExtensions> </Project> "; ProjectRootElement project = ProjectRootElement.Create(XmlReader.Create(new StringReader(content))); ProjectExtensionsElement extensions = (ProjectExtensionsElement)Helpers.GetFirst(project.Children); content = extensions["b"]; Assert.Equal("y", content); content = extensions["nonexistent"]; Assert.Equal(String.Empty, content); }
public void DeleteById() { string content = @" <Project xmlns='http://schemas.microsoft.com/developer/msbuild/2003'> <ProjectExtensions> <a>x</a> <b>y</b> </ProjectExtensions> </Project> "; ProjectRootElement project = ProjectRootElement.Create(XmlReader.Create(new StringReader(content))); ProjectExtensionsElement extensions = (ProjectExtensionsElement)Helpers.GetFirst(project.Children); extensions["a"] = String.Empty; content = extensions["a"]; Assert.Equal(String.Empty, content); extensions["a"] = String.Empty; // make sure it doesn't die or something Assert.Equal("y", extensions["b"]); }
public bool Load(Microsoft.Build.Evaluation.Project project, bool remove) { bool loaded = false; foreach (ProjectElement element in project.Xml.Children) { ProjectExtensionsElement extension = element as ProjectExtensionsElement; if (extension != null && !string.IsNullOrEmpty(extension.Content)) { try { XmlDocument doc = new XmlDocument(); doc.LoadXml(extension.Content); XmlNamespaceManager ns = new XmlNamespaceManager(doc.NameTable); ns.AddNamespace("msb", "http://schemas.microsoft.com/developer/msbuild/2003"); XmlNode userProperties = doc.DocumentElement.SelectSingleNode("/msb:VisualStudio/msb:UserProperties", ns); if (userProperties != null) { if (userProperties.Attributes[PropertyIce] != null) { loaded = true; Enabled = userProperties.Attributes[PropertyIce].Value.Equals("True"); } if (userProperties.Attributes[PropertyIceOutputDir] != null) { loaded = true; OutputDir = userProperties.Attributes[PropertyIceOutputDir].Value; } if (userProperties.Attributes[PropertyIceHeaderExt] != null) { loaded = true; HeaderExt = userProperties.Attributes[PropertyIceHeaderExt].Value; } if (userProperties.Attributes[PropertyIceSourceExt] != null) { loaded = true; SourceExt = userProperties.Attributes[PropertyIceSourceExt].Value; } if (userProperties.Attributes[PropertyIceExtraOptions] != null) { loaded = true; AdditionalOptions = userProperties.Attributes[PropertyIceExtraOptions].Value; } if (userProperties.Attributes[PropertyIceIncludePath] != null) { loaded = true; IncludeDirectories = userProperties.Attributes[PropertyIceIncludePath].Value; } if (userProperties.Attributes[PropertyIceStreaming] != null) { loaded = true; Stream = userProperties.Attributes[PropertyIceStreaming].Value.Equals("True"); } if (userProperties.Attributes[PropertyIceChecksum] != null) { loaded = true; Checksum = userProperties.Attributes[PropertyIceChecksum].Value.Equals("True"); } if (userProperties.Attributes[PropertyIceTie] != null) { loaded = true; Tie = userProperties.Attributes[PropertyIceTie].Value.Equals("True"); } if (userProperties.Attributes[PropertyIcePrefix] != null) { loaded = true; Ice = userProperties.Attributes[PropertyIcePrefix].Value.Equals("True"); } if (userProperties.Attributes[PropertyIceDllExport] != null) { loaded = true; DLLExport = userProperties.Attributes[PropertyIceDllExport].Value; } if (remove) { foreach (string name in OldPropertyNames) { if (userProperties.Attributes[name] != null) { userProperties.Attributes.Remove(userProperties.Attributes[name]); } } if (userProperties.Attributes.Count == 0) { project.Xml.RemoveChild(extension); } } break; } } catch (XmlException) { } } } return(loaded); }
public void SetInvalidNull() { ProjectExtensionsElement extensions = GetEmptyProjectExtensions(); extensions.Content = null; }