/// <summary> /// Given a string representing the contents of the project file, create a project file /// on disk with those contents. Then call the method to find the line/column number of /// a particular node in the project file, based on the element/attribute number of that node. /// </summary> /// <param name="projectFileContents"></param> /// <returns>an instance of our special line-number-enabled reader</returns> /// <owner>RGoel</owner> private void GetLineColumnFromProjectFileContentsHelper ( string projectFileContents, int xmlElementNumberToSearchFor, int xmlAttributeNumberToSearchFor, out int foundLineNumber, out int foundColumnNumber ) { string projectFile = ObjectModelHelpers.CreateTempFileOnDisk(projectFileContents); XmlSearcher.GetLineColumnByNodeNumber(projectFile, xmlElementNumberToSearchFor, xmlAttributeNumberToSearchFor, out foundLineNumber, out foundColumnNumber); // Delete the temp file. File.Delete(projectFile); }
public void VerifyInvalidImportNotCaughtBySchema ( ) { string[] msbuildTempXsdFilenames = new string[] {}; string importedProjectFilename = ObjectModelHelpers.CreateTempFileOnDisk(@" <Project xmlns=`msbuildnamespace`> <PropertyGroup><UnknownProperty/></PropertyGroup> <Target Name=`Build` /> </Project> "); string projectFilename = ObjectModelHelpers.CreateTempFileOnDisk(@" <Project xmlns=`msbuildnamespace`> <Import Project=`{0}` /> </Project> ", importedProjectFilename); try { // Create schema files in the temp folder msbuildTempXsdFilenames = PrepareSchemaFiles(); Project p = new Project(new Engine(@"c:\")); p.IsValidated = true; p.SchemaFile = msbuildTempXsdFilenames[0]; p.Load(projectFilename); } finally { CleanupSchemaFiles(msbuildTempXsdFilenames); File.Delete(projectFilename); File.Delete(importedProjectFilename); } }