Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incremental parsing producing an invalid tree #47610

Closed
sharwell opened this issue Sep 11, 2020 · 1 comment
Closed

Incremental parsing producing an invalid tree #47610

sharwell opened this issue Sep 11, 2020 · 1 comment

Comments

@sharwell
Copy link
Member

sharwell commented Sep 11, 2020

Version Used: 8adbb93

Steps to Reproduce:

Run the test CSharpCompletionCommandHandlerTests.LocalFunctionAttributeNamedPropertyCompletionCommitWithTab and wait for an assertion failure in SyntaxTreeExtensions.VerifySource.

The test attempts to apply this change and incrementally parse the result:

 
 class MyAttribute : System.Attribute
 {
     public string Name { get; set; }
 }
 
 public class Goo
 {
     void M()
     {
-        [MyAttribute(Nam
+        [MyAttribute(Name =
         void local1() { }
     }
 }
                             

Expected Behavior:

The full text of the CompilationUnitSyntax should match this original SyntaxTree text:


class MyAttribute : System.Attribute
{
    public string Name { get; set; }
}

public class Goo
{
    void M()
    {
        [MyAttribute(Name =
        void local1() { }
    }
}
                            

Actual Behavior:

The full text of the CompilationUnitSyntax is this:


class MyAttribute : System.Attribute
{
    public string Name { get; set; }
}

public class Goo
{
    void M()
    {
{ }
    }
}
                            
@sharwell
Copy link
Member Author

I was able to narrow down the location where the invalid tree is produced to this:

using var lexer = new InternalSyntax.Lexer(newText, this.Options);
using var parser = new InternalSyntax.LanguageParser(lexer, oldTree?.GetRoot(), workingChanges);
var compilationUnit = (CompilationUnitSyntax)parser.ParseCompilationUnit().CreateRed();

sharwell added a commit to sharwell/roslyn that referenced this issue Sep 12, 2020
Currently the incremental parser is not producing trees with the correct
text. However, this bug was introduced in the past and is failing now
that debug assertions are checked in builds.

See dotnet#47610
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant