public static int Main(string[] args) { int errorCount = 0; MessageEngine.Trace(Severity.Notification, Resources.VulcanStart, Assembly.GetAssembly(typeof(XmlIR)).GetName().Version); try { var workflowLoader = new PhaseWorkflowLoader(); PhaseWorkflow workflow = workflowLoader.PhaseWorkflowsByName[workflowLoader.DefaultWorkflowName]; var cmdLineParser = new SimpleCommandLineParser("-/", args); if (args.Length == 0 || cmdLineParser["?"] != null) { DisplayHelpMenu(); return errorCount; } if (cmdLineParser["t"] != null && cmdLineParser["t"].Count > 0) { PathManager.TargetPath = Path.GetFullPath(cmdLineParser["t"][0]); //// +Path.DirectorySeparatorChar; } else { PathManager.TargetPath = Path.GetFullPath("."); } var xmlIR = new XmlIR(); foreach (string filename in cmdLineParser.NoSwitchArguments) { if (File.Exists(filename)) { xmlIR.AddXml(Path.GetFullPath(filename), XmlIRDocumentType.Source, true); } else { MessageEngine.Trace(Severity.Error, new FileNotFoundException("Vulcan File Not Found", filename), Resources.VulcanFileNotFound, filename); } } IList<string> includedFiles = cmdLineParser["i"]; if (includedFiles != null) { foreach (string filename in includedFiles) { if (File.Exists(filename)) { xmlIR.AddXml(Path.GetFullPath(filename), XmlIRDocumentType.Include, true); } } } workflow.ExecutePhaseWorkflowGraph(xmlIR); } catch (Exception ex) { MessageEngine.Trace(Severity.Error, ex, "One or more fatal errors were encountered!"); } errorCount = (MessageEngine.ErrorCount + MessageEngine.WarningCount) * -1; return errorCount; } // end main
public void CheckFrameworkItemsNoLowering(string file) { Assert.IsTrue(File.Exists(file), "File was not found"); // TODO: Fix this hack MessageEngine.ClearMessages(); var parser = new XmlToAstParserPhase("TestParser", _defaultXmlNamespace); var lowerer = new AstLowererPhase("TestLowerer"); var unloweredXmlIR = new XmlIR(); unloweredXmlIR.AddXml(file, XmlIRDocumentType.Source, true); var unloweredAstRootNode = ((AstIR)parser.Execute(unloweredXmlIR)).AstRootNode; Assert.IsTrue(MessageEngine.ErrorCount == 0, "There were parse errors in the unlowered file pass."); // TODO: Fix this hack MessageEngine.ClearMessages(); var loweredXmlIR = new XmlIR(); loweredXmlIR.AddXml(file, XmlIRDocumentType.Source, true); IIR loweredParsed = parser.Execute(loweredXmlIR); Assert.IsTrue(MessageEngine.ErrorCount == 0, "There were parse errors in the lowered file pass."); // TODO: Fix this hack MessageEngine.ClearMessages(); var loweredAstRootNode = ((AstIR)lowerer.Execute(loweredParsed)).AstRootNode; Assert.IsTrue(MessageEngine.ErrorCount == 0, "There were lowering errors in the file."); CheckFrameworkItems(unloweredAstRootNode, loweredAstRootNode, false); }
private void CheckFrameworkItems(string parentFile, string subFile, bool isSubsetOf) { Assert.IsTrue(File.Exists(parentFile), "PRE file was not found"); Assert.IsTrue(File.Exists(subFile), "POST file was not found"); // TODO: Fix this hack MessageEngine.ClearMessages(); var parser = new XmlToAstParserPhase("TestParser", _defaultXmlNamespace); var lowerer = new AstLowererPhase("TestLowerer"); var parentXmlIR = new XmlIR(); parentXmlIR.AddXml(parentFile, XmlIRDocumentType.Source, true); IIR parentParsed = parser.Execute(parentXmlIR); Assert.IsTrue(MessageEngine.ErrorCount == 0, "There were parse errors in the PRE file."); // TODO: Fix this hack MessageEngine.ClearMessages(); var parentAstRootNode = ((AstIR)lowerer.Execute(parentParsed)).AstRootNode; Assert.IsTrue(MessageEngine.ErrorCount == 0, "There were lowering errors in the PRE file."); // TODO: Fix this hack MessageEngine.ClearMessages(); var subXmlIR = new XmlIR(); subXmlIR.AddXml(subFile, XmlIRDocumentType.Source, true); IIR subParsed = parser.Execute(subXmlIR); Assert.IsTrue(MessageEngine.ErrorCount == 0, "There were parse errors in the POST file."); // TODO: Fix this hack MessageEngine.ClearMessages(); var subAstRootNode = ((AstIR)lowerer.Execute(subParsed)).AstRootNode; Assert.IsTrue(MessageEngine.ErrorCount == 0, "There were lowering errors in the POST file."); CheckFrameworkItems(parentAstRootNode, subAstRootNode, isSubsetOf); }
public override bool Execute() { MessageEngine.Reset(); MessageEngine Message = MessageEngine.Create("__VULCAN MAIN"); Message.Trace(Severity.Notification, Resources.VulcanStart + Assembly.GetExecutingAssembly().GetName().Version); #if DEBUG Message.Trace(Severity.Notification, "DEBUG VERSION"); #endif PhaseWorkflowLoader WorkflowLoader = new PhaseWorkflowLoader(); PhaseWorkflow Workflow = WorkflowLoader.PhaseWorkflowsByName[WorkflowLoader.DefaultWorkflowName]; PathManager.TargetPath = Path.GetFullPath(OutputPath) + Path.DirectorySeparatorChar; XmlIR xmlIR = new XmlIR(); foreach (ITaskItem item in Sources) { string filename = item.ItemSpec; if (File.Exists(filename)) { xmlIR.AddXml(Path.GetFullPath(filename),XmlIRDocumentType.SOURCE); } else { Message.Trace(Severity.Error, new FileNotFoundException("Vulcan File Not Found", filename), Resources.VulcanFileNotFound, filename); } } foreach (ITaskItem item in Includes) { string filename = item.ItemSpec; if (File.Exists(filename)) { xmlIR.AddXml(Path.GetFullPath(filename), XmlIRDocumentType.INCLUDE); } else { Message.Trace(Severity.Error, new FileNotFoundException("Vulcan File Not Found", filename), Resources.VulcanFileNotFound, filename); } } Workflow.ExecutePhaseWorkflowGraph(xmlIR); return (MessageEngine.AllEnginesErrorCount + MessageEngine.AllEnginesWarningCount) <= 0; }
public VulcanEngine.IR.IIR Execute(IIR PredecessorIR) { XmlIR xmlIR = PredecessorIR as XmlIR; if (xmlIR == null) { _message.Trace(Severity.Error, Resources.ErrorPhaseWorkflowIncorrectInputIRType, PredecessorIR.GetType().ToString(), this.Name); } string XsltFolderPath = PathManager.GetToolSubpath(Settings.Default.SubPathXsltTransformFolder); string[] XsltFileNames = Directory.GetFiles(XsltFolderPath, "*.xsl"); if (XsltFileNames.Length <= 0) { _message.Trace(Severity.Warning, Resources.WarningNoPreProcessorFound); return null; } XsltSettings settings = new XsltSettings(true, false); XmlIR output = new XmlIR(); // REVIEW: The approach I take here is to pipeline XSLT transforms using a MemoryStream. This isn't great. // In the next .NET Fx, they are expecting to fix XslCompiledTransform so it can pipeline more resonably. This should be changed at that time. foreach (XmlIRDocumentType docType in xmlIR.XDocuments.Keys) { foreach (XDocument xDocument in xmlIR.XDocuments[docType]) { XmlDocument intermediateXMLDocument = new XmlDocument(); intermediateXMLDocument.Load(xDocument.CreateReader()); foreach (string s in XsltFileNames) { XslCompiledTransform xslt = new XslCompiledTransform(); XsltArgumentList args = new XsltArgumentList(); args.AddParam("XSLTFolderPath", String.Empty, XsltFolderPath); xslt.Load(s, settings, new XmlUrlResolver()); MemoryStream intermediateMemoryStream = new MemoryStream(); xslt.Transform(intermediateXMLDocument, args, intermediateMemoryStream); intermediateMemoryStream.Position = 0; intermediateXMLDocument = new XmlDocument(); intermediateXMLDocument.Load(intermediateMemoryStream); } output.AddXml(intermediateXMLDocument,docType); } } return output; }
public static int Main(string[] args) { int errorCount = 0; MessageEngine Message = MessageEngine.Create("__VULCAN MAIN"); Message.Trace(Severity.Notification, Resources.VulcanStart + Assembly.GetAssembly(typeof(XmlIR)).GetName().Version); #if DEBUG Message.Trace(Severity.Notification, "DEBUG VERSION"); #endif // TODO: Can we set permissions so that only PhaseworkflowLoader can see the workflow editing methods? (Vsabella: yes you can if you make it its own dll and mark the classes internal) PhaseWorkflowLoader WorkflowLoader = new PhaseWorkflowLoader(); PhaseWorkflow Workflow = WorkflowLoader.PhaseWorkflowsByName[WorkflowLoader.DefaultWorkflowName]; SimpleCommandLineParser cmdLineParser = new SimpleCommandLineParser("-/", args); if (args.Length == 0 || cmdLineParser["?"] != null) { DisplayHelpMenu(); return errorCount; } if (cmdLineParser["t"] != null && cmdLineParser["t"].Count > 0) { PathManager.TargetPath = Path.GetFullPath(cmdLineParser["t"][0]);// +Path.DirectorySeparatorChar; } else { PathManager.TargetPath = Path.GetFullPath("."); } XmlIR xmlIR = new XmlIR(); if (cmdLineParser["r"] != null && cmdLineParser["r"].Count > 0) { string[] rootPath = cmdLineParser["r"][0].Split(new char[] { '=' }); if (rootPath != null && rootPath.Length == 2 && Directory.Exists(rootPath[1])) { xmlIR.SetDocumentRoot(rootPath[0].ToUpperInvariant(), Path.GetFullPath(rootPath[1])); } } foreach (string filename in cmdLineParser.NoSwitchArguments) { if (File.Exists(filename)) { VulcanEngine.IR.XmlIRDocumentType docType = XmlIRDocumentType.SOURCE; xmlIR.AddXml(Path.GetFullPath(filename), docType); } else { Message.Trace(Severity.Error, new FileNotFoundException("Vulcan File Not Found", filename), Resources.VulcanFileNotFound, filename); } } IList<string> includedFiles = cmdLineParser["i"]; if (includedFiles != null) { foreach (string filename in includedFiles) { if (File.Exists(filename)) { VulcanEngine.IR.XmlIRDocumentType docType = XmlIRDocumentType.INCLUDE; xmlIR.AddXml(Path.GetFullPath(filename), docType); } } } Workflow.ExecutePhaseWorkflowGraph(xmlIR); errorCount = (MessageEngine.AllEnginesErrorCount + MessageEngine.AllEnginesWarningCount) * -1; return errorCount; }// end main
public IIR Execute(IIR predecessorIR) { var xmlIR = predecessorIR as XmlIR; if (xmlIR == null) { MessageEngine.Trace(Severity.Error, Resources.ErrorPhaseWorkflowIncorrectInputIRType, predecessorIR.GetType().ToString(), Name); } var xsltFileList = new List<string>(); string xsltFolderPath = PathManager.GetToolSubpath(Settings.Default.SubPathXsltTransformFolder); foreach (string xsltFile in _xsltFiles.Split(';')) { if (!String.IsNullOrEmpty(xsltFile)) { xsltFileList.Add(Path.Combine(xsltFolderPath, xsltFile)); } } var settings = new XsltSettings(true, false); var output = new XmlIR(); // REVIEW: The approach I take here is to pipeline XSLT transforms using a MemoryStream. This isn't great. // In the next .NET Fx, they are expecting to fix XslCompiledTransform so it can pipeline more resonably. This should be changed at that time. foreach (BimlFile bimlFile in xmlIR.BimlFiles) { XDocument document = bimlFile.XDocument; var intermediateXmlDocument = new XmlDocument(); intermediateXmlDocument.Load(document.CreateReader()); if (!String.IsNullOrEmpty(xmlIR.TemplatePath)) { foreach (string s in xsltFileList) { var xslt = new XslCompiledTransform(); var args = new XsltArgumentList(); args.AddParam("TemplatePath", String.Empty, xmlIR.TemplatePath); xslt.Load(s, settings, new XmlUrlResolver()); var intermediateMemoryStream = new MemoryStream(); xslt.Transform(intermediateXmlDocument, args, intermediateMemoryStream); intermediateMemoryStream.Position = 0; intermediateXmlDocument = new XmlDocument(); intermediateXmlDocument.Load(intermediateMemoryStream); } } output.AddXml(bimlFile.FilePath, intermediateXmlDocument, bimlFile.EmitType, true); } output.SchemaSet = xmlIR.SchemaSet; output.DefaultXmlNamespace = xmlIR.DefaultXmlNamespace; return output; }
public override bool Execute() { MessageEngine.MSBuildTask = this; MessageEngine.Trace(Severity.Notification, Resources.VulcanStart + Assembly.GetExecutingAssembly().GetName().Version); try { InitializeVulcanParameters(); var workflowLoader = new PhaseWorkflowLoader(); PhaseWorkflow workflow = workflowLoader.PhaseWorkflowsByName[workflowLoader.DefaultWorkflowName]; PathManager.TargetPath = Path.GetFullPath(OutputPath) + Path.DirectorySeparatorChar + Path.DirectorySeparatorChar; var xmlIR = new XmlIR(); if (!String.IsNullOrEmpty(TemplatePath)) { xmlIR.TemplatePath = Path.GetFullPath(TemplatePath) + Path.DirectorySeparatorChar; } if (Sources != null) { foreach (ITaskItem item in Sources) { string filename = item.ItemSpec; if (File.Exists(filename)) { xmlIR.AddXml(Path.GetFullPath(filename), XmlIRDocumentType.Source, true); } else { MessageEngine.Trace(Severity.Error, new FileNotFoundException("Vulcan File Not Found", filename), Resources.VulcanFileNotFound, filename); } } } if (Includes != null) { foreach (ITaskItem item in Includes) { string filename = item.ItemSpec; if (File.Exists(filename)) { xmlIR.AddXml(Path.GetFullPath(filename), XmlIRDocumentType.Include, true); } else { MessageEngine.Trace(Severity.Error, new FileNotFoundException("Vulcan File Not Found", filename), Resources.VulcanFileNotFound, filename); } } } workflow.ExecutePhaseWorkflowGraph(xmlIR); } catch (Exception e) { MessageEngine.Trace(Severity.Error, e, "One or more fatal errors were encountered!"); } return (MessageEngine.ErrorCount + MessageEngine.WarningCount) <= 0; }