Esempio n. 1
0
 public void FindSolutionFile()
 {
     Assert.AreEqual(true, CodeFactory.TryFindSolutionFile("Gu.Roslyn.Asserts.sln", out var sln));
     Assert.AreEqual("Gu.Roslyn.Asserts.sln", sln.Name);
     sln = CodeFactory.FindSolutionFile("Gu.Roslyn.Asserts.sln");
     Assert.AreEqual("Gu.Roslyn.Asserts.sln", sln.Name);
 }
Esempio n. 2
0
        private static MetadataReference CreateDllReference(string dllName)
        {
            // ReSharper disable once PossibleNullReferenceException
            var dll = CodeFactory.FindSolutionFile("PropertyChangedAnalyzers.sln")
                      .Directory.EnumerateFiles(dllName, SearchOption.AllDirectories)
                      .First();

            return(MetadataReference.CreateFromFile(dll.FullName));
        }
Esempio n. 3
0
        public async Task Solution()
        {
            var analyzer = new FieldNameMustNotBeginWithUnderscore();
            var sln      = CodeFactory.CreateSolution(
                CodeFactory.FindSolutionFile("Gu.Roslyn.Asserts.sln"),
                MetadataReferences.Transitive(typeof(BenchmarkTests).Assembly).ToArray());
            var benchmark = await Benchmark.CreateAsync(sln, analyzer).ConfigureAwait(false);

            CollectionAssert.IsNotEmpty(benchmark.SyntaxNodeActions);
            CollectionAssert.AllItemsAreInstancesOfType(benchmark.SyntaxNodeActions.Select(x => x.Context.Node), typeof(FieldDeclarationSyntax));
            CollectionAssert.AllItemsAreInstancesOfType(benchmark.SyntaxNodeActions.Select(x => x.Context.ContainingSymbol), typeof(IFieldSymbol));
            Assert.AreSame(analyzer, benchmark.Analyzer);
            benchmark.Run();
            benchmark.Run();
        }