private void DumpSyntaxData(MilSyntaxWalker treeData) { SendMessage(Environment.NewLine + "# Aggregate roots" + Environment.NewLine); SendMessage((treeData.AggregateRoots.Any() ? treeData.DumpAggregateRoots() : new[] { "-- none --" } as dynamic)); SendMessage(Environment.NewLine + "# Commands" + Environment.NewLine); SendMessage((treeData.Commands.Any() || treeData.CommandHandlers.Any() ? treeData.DumpCommandData() : new[] { "-- none --" } as dynamic)); SendMessage(Environment.NewLine + "# Events" + Environment.NewLine); SendMessage((treeData.Events.Any() || treeData.EventHandlers.Any() ? treeData.DumpEventData() : new[] { "-- none --" } as dynamic)); SendMessage(Environment.NewLine + "# Message publications" + Environment.NewLine); SendMessage(treeData.PublicationCalls.Any() ? treeData.DumpPublicationData() : new[] { "-- none --" }); }
public given_a_syntax_tree() { declarationTree = SyntaxFactory.ParseSyntaxTree(declarationCode); logicTree = SyntaxFactory.ParseSyntaxTree(programCode); infraTree = SyntaxFactory.ParseSyntaxTree(infraCode); compilation = CSharpCompilation.Create("test.exe") .AddSyntaxTrees(infraTree) .AddSyntaxTrees(declarationTree) .AddSyntaxTrees(logicTree) .AddReferences(new MetadataFileReference(typeof(object).Assembly.Location)); sut = new MilSyntaxWalker(); }
public void Run() { Solution sln = LoadSolution(); //var externalProject = sln.Projects.FirstOrDefault(x => x.AssemblyName == externalNs); //if (externalProject == null) //{ // var msg = string.Format("Project for given external-facing namespace of {0} not found.", externalNs); // messagePump.OnError(new ArgumentException(msg)); // return; //} SendMessage(string.Format("{1}Using {0} for process discovery{1}", processTypeName ?? DefaultProcessIfxName, Environment.NewLine)); var token = new CancellationToken(); var analyzer = new MIL.Services.ProcessAnalysisService(processIName); //ProcessDefinition processDefinition = null; var excludeList = sln.Projects.Where(x => ExcludedAssemblies.Any(e => x.AssemblyName.Contains(e))).ToList(); if (excludeList.Any()) { SendMessage(string.Format("Ignoring {0} Assemblies{1}", excludeList.Count, Environment.NewLine), () => "Ignored assemblies: " + Environment.NewLine + string.Join(Environment.NewLine, excludeList.Select(x => x.AssemblyName)) + Environment.NewLine); } MilSyntaxWalker treeData = new MilSyntaxWalker(); foreach (var proj in sln.Projects.Except(excludeList)) { SendMessage(".", () => Environment.NewLine + "# Processing assembly " + proj.AssemblyName + Environment.NewLine); MilSemanticAnalyzer semantics = null; MetadataFileReferenceProvider provider = new MetadataFileReferenceProvider(); Compilation compilation = (Compilation)proj.GetCompilationAsync(token).Result .AddReferences(new MetadataFileReference(typeof(object).Assembly.Location)) .AddReferences(new MetadataFileReference(typeof(IEnumerable <>).Assembly.Location));; try { semantics = new MilSemanticAnalyzer(compilation); } catch (InvalidOperationException ex) { SendMessage("x", () => string.Join(Environment.NewLine, compilation.GetDeclarationDiagnostics().Select(x => x.ToString())) + Environment.NewLine); continue; } semantics.ExtractMessagingSyntax(treeData); //if (proj.AssemblyName == externalProject.AssemblyName) // continue; //processDefinition = analyzer.GetProcessDefinition(compilation, processTypeName); //if (processDefinition != null) //{ // var procToke = ProcessDefinition.GetTokenFromDefinition(processDefinition); // if (procToke.Token != MilTypeConstant.EmptyToken) // SendMessage(procToke.ToString()); //} //foreach (var pubCall in semantics.GetMessagePublicationData()) //{ // SendMessage(pubCall.ToString()); //} } DumpSyntaxData(treeData); messagePump.OnCompleted(); }