Exemplo n.º 1
0
 public void Bug684860_XmlText()
 {
     const int n = 100000;
     // 100000 instances of "<" in:
     // /// <x a="&lt;&lt;&lt;..."/>
     // class { }
     var builder = new System.Text.StringBuilder();
     builder.Append("/// <x a=\"");
     for (int i = 0; i < n; i++)
     {
         builder.Append("&lt;");
     }
     builder.AppendLine("\"/>");
     builder.AppendLine("class C { }");
     var text = builder.ToString();
     var tree = SyntaxFactory.ParseSyntaxTree(text, options: new CSharpParseOptions(documentationMode: DocumentationMode.Parse));
     var root = tree.GetRoot();
     var walker = new TokenAndTriviaWalker();
     walker.Visit(root);
     Assert.True(walker.Tokens > n);
     var tokens = root.DescendantTokens(descendIntoTrivia: true).ToArray();
     Assert.True(tokens.Length > n);
 }
Exemplo n.º 2
0
 public void Bug684860_SkippedTokens()
 {
     const int n = 100000;
     // 100000 instances of "0+" in:
     // #pragma warning disable 1 0+0+0+...
     var builder = new System.Text.StringBuilder();
     builder.Append("#pragma warning disable 1 ");
     for (int i = 0; i < n; i++)
     {
         builder.Append("0+");
     }
     builder.AppendLine();
     var text = builder.ToString();
     var tree = SyntaxFactory.ParseSyntaxTree(text);
     var root = tree.GetRoot();
     var walker = new TokenAndTriviaWalker();
     walker.Visit(root);
     Assert.True(walker.Tokens > n);
     var tokens1 = root.DescendantTokens(descendIntoTrivia: false).ToArray();
     var tokens2 = root.DescendantTokens(descendIntoTrivia: true).ToArray();
     Assert.True((tokens2.Length - tokens1.Length) > n);
 }