public void does_not_throw_for_unimplemented_roslyn_elements()
        {
            const string errorCode = "CS8000";
            var newComp = compilation.AddSyntaxTrees(SyntaxFactory.ParseSyntaxTree("namespace cs8000test { using System; }"));
            MilSemanticAnalyzer newSut = null;
            Assert.DoesNotThrow(() => newSut = new MilSemanticAnalyzer(newComp));

            var result = sut.ExtractMessagingSyntax();
        }
        public void when_valid_compilation_includes_all_references()
        {
            var newComp =
                compilation.AddSyntaxTrees(
                    SyntaxFactory.ParseSyntaxTree(
                        @"
namespace refTest 
{ 
    using System.ComponentModel.DataAnnotations; 
    public class RefTest { 
        [Required]
        public string Name { get; set;}
    }
}"))
                    .AddReferences(new MetadataFileReference(typeof(RequiredAttribute).Assembly.Location));

            MilSemanticAnalyzer newSut;

            Assert.DoesNotThrow(() => newSut = new MilSemanticAnalyzer(newComp));
        }
Esempio n. 3
0
        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();
        }
 public void when_compilation_errors_in_code_throws()
 {
     var newComp = compilation.AddSyntaxTrees(SyntaxFactory.ParseSyntaxTree("private class Jar { public string Name { get; set; }}"));
     MilSemanticAnalyzer newSut = null;
     var ex = Assert.Throws(typeof(InvalidOperationException), () => newSut = new MilSemanticAnalyzer(newComp));
 }
 public MilSemanticAnalyzerTestFixture()
 {
     sut = new MilSemanticAnalyzer(compilation);
 }
 public void when_send_is_not_prefixed_by_member_access_walker_ignores()
 {
     var analysis = new MilSemanticAnalyzer(compilation);
     var walker = analysis.ExtractMessagingSyntax();
     Assert.True(walker.PublicationCalls.Count == 1);
 }
 public void walker_correctly_finds_publications_in_complete_program()
 {
     var analysis = new MilSemanticAnalyzer(compilation);
     var walker = analysis.ExtractMessagingSyntax();
     Assert.NotEmpty(walker.Publications);
 }