private static void CheckCompilationSyntaxTrees(CSharpCompilation compilation, params SyntaxTree[] expectedSyntaxTrees)
        {
            ImmutableArray<SyntaxTree> actualSyntaxTrees = compilation.SyntaxTrees;

            int numTrees = expectedSyntaxTrees.Length;

            Assert.Equal(numTrees, actualSyntaxTrees.Length);
            for (int i = 0; i < numTrees; i++)
            {
                Assert.Equal(expectedSyntaxTrees[i], actualSyntaxTrees[i]);
            }

            for (int i = 0; i < numTrees; i++)
            {
                for (int j = 0; j < numTrees; j++)
                {
                    Assert.Equal(Math.Sign(compilation.CompareSyntaxTreeOrdering(expectedSyntaxTrees[i], expectedSyntaxTrees[j])), Math.Sign(i.CompareTo(j)));
                }
            }

            var types = expectedSyntaxTrees.Select(tree => compilation.GetSemanticModel(tree).GetDeclaredSymbol(tree.GetCompilationUnitRoot().Members.Single())).ToArray();
            for (int i = 0; i < numTrees; i++)
            {
                for (int j = 0; j < numTrees; j++)
                {
                    Assert.Equal(Math.Sign(compilation.CompareSourceLocations(types[i].Locations[0], types[j].Locations[0])), Math.Sign(i.CompareTo(j)));
                }
            }
        }
Beispiel #2
0
 private int CompareLocations(Location x, Location y)
 {
     if (x == y)
     {
         return(0);
     }
     else if (x == Location.None)
     {
         return(-1);
     }
     else if (y == Location.None)
     {
         return(1);
     }
     else
     {
         return(_compilation.CompareSourceLocations(x, y));
     }
 }
Beispiel #3
0
 private int CompareLocations(Location x, Location y)
 {
     if (x == y)
     {
         return 0;
     }
     else if (x == Location.None)
     {
         return -1;
     }
     else if (y == Location.None)
     {
         return 1;
     }
     else
     {
         return _compilation.CompareSourceLocations(x, y);
     }
 }