/// <summary> /// Saving C# ASG to the target path. /// </summary> /// <param name="project">Project file's object</param> /// <param name="output">Output file path</param> /// <param name="Factory">C# ASG's factory object</param> private static void SaveCsharpASG(Project project, string output, Csharp.Asg.Factory Factory) { List <IHeaderData> header = new List <IHeaderData>(); PropertyData propertyData = new PropertyData(); propertyData.add(PropertyData.csih_OriginalLocation, Commons.Common.ProcessPath(project.OutputFilePath)); header.Add(propertyData); string basePath = string.IsNullOrEmpty(Path.GetDirectoryName(output)) ? output : Path.GetDirectoryName(output) + Path.DirectorySeparatorChar + project.Name + Constants.PROJECTEXTENSION; Factory.save(basePath + MainDeclaration.Instance.CSSIExtension, header); Factory.saveFilter(basePath + Constants.FILTEREDCSSIEXTENSION); outfiles.Add(basePath + MainDeclaration.Instance.CSSIExtension); if (MainDeclaration.Instance.DumpCsharpml) { using (StreamWriter sw = new StreamWriter(basePath + Constants.CSHARPDUMPEXTENSION, false, utf8Encoding)) { var visitor = new Csharp.Asg.Visitors.VisitorCSHARPML(sw, project.Name, true, x => { }, false); //message writer seems to be unused var ap = new Csharp.Asg.Algorithms.AlgorithmPreorder(); ap.run(Factory, visitor); } } }
/// <summary> /// Project file analysis phase /// </summary> /// <param name="project">Porject file object</param> /// <param name="output">C# ASG output path</param> /// <param name="fxCopPath">FxCopCmd.exe path</param> /// <param name="fXCopOut">FxCop result directory</param> private static void Analyse(Project project, string output, string fxCopPath, string fXCopOut) { if (!string.IsNullOrEmpty(fxCopPath)) { MainDeclaration.Instance.FxCopTasks.Add(Task.Run(() => StartFxCopAnalysis(project.OutputFilePath, (string.IsNullOrEmpty(fXCopOut)) ? output : fXCopOut, fxCopPath))); } CreateComponent(project); Csharp.Asg.Factory Factory = new Csharp.Asg.Factory(new StrTable()); Dictionary <Microsoft.CodeAnalysis.CSharp.CSharpSyntaxNode, uint> CSharpMap = new Dictionary <Microsoft.CodeAnalysis.CSharp.CSharpSyntaxNode, uint>(); NodeBuilder mapBuilder = new NodeBuilder(Factory, CSharpMap); TreeEdgeBuilder edgeBuilder = new TreeEdgeBuilder(Factory, CSharpMap); CrossEdgeFiller crossEdgeFiller = new CrossEdgeFiller(Factory, CSharpMap); foreach (var document in project.Documents) { if (Commons.Common.CheckOuterFilters(document.FilePath)) { continue; } MainDeclaration.Instance.RoslynWatch.Start(); MainDeclaration.Instance.Model = document.GetSemanticModelAsync().Result; MainDeclaration.Instance.RoslynWatch.Stop(); MainDeclaration.Instance.CSSIWatch.Start(); BuildCSSIASG(document, mapBuilder, edgeBuilder); MainDeclaration.Instance.CSSIWatch.Stop(); MainDeclaration.Instance.LIMWatch.Start(); BuildLIMASG(CSharpMap, crossEdgeFiller); MainDeclaration.Instance.LIMWatch.Stop(); } SaveCsharpASG(project, output, Factory); }