public SyntaxWalker(Solution solution, string project) { if (solution == null) throw new ArgumentException("solution"); if (project == null) throw new ArgumentException("classProject"); var solutionTrees = solution.GetTrees(); _solutionCompilation = CSharpCompilation.Create("SolutionCompilation") .AddSyntaxTrees(solutionTrees) .WithReferences(new List<MetadataReference>() { MetadataReference.CreateFromFile(typeof(object).Assembly.Location), MetadataReference.CreateFromFile(typeof(IEnumerable).Assembly.Location), MetadataReference.CreateFromFile(typeof(Task).Assembly.Location) }); _allTrees = solution.GetTrees(new[] {project}).ToList(); _projectCompilation = CSharpCompilation.Create("ProjectCompilation") .AddSyntaxTrees(_allTrees) .WithReferences(new List<MetadataReference>() { MetadataReference.CreateFromFile(typeof(object).Assembly.Location), MetadataReference.CreateFromFile(typeof(IEnumerable).Assembly.Location), MetadataReference.CreateFromFile(typeof(Task).Assembly.Location) }); }