Skip to content

Incremental parsing when editing attribute drops attribute #37663

@jasonmalinowski

Description

@jasonmalinowski

Version Used: 16.2.0 (debug build will assert so you can easily see the problem)

Steps to Reproduce:

  1. Create a new console application.
  2. In the blank line between the using statements and the namespace, quickly type [assembly:. The IDE will complete the ] and that's OK. If it doesn't assert, then try deleting and retyping the :.

Expected Behavior: no asserts

Actual Behavior: the compiler asserts, producing a syntax tree that seems to entirely drop the assembly attribute. The IDE may crash or just act strangely beyond here.

This is one bug found by digging through a bug bucket of 16.2 crashes.

Assert:

---------------------------
Assertion Failed: Abort=Quit, Retry=Debug, Ignore=Continue
---------------------------
Unexpected difference at offset 150: Line 8, Column 16 "namespace ClassLibrary15"  (Found: [ ] Expected: [L])

   at Microsoft.CodeAnalysis.SyntaxTreeExtensions.VerifySource(SyntaxTree tree, IEnumerable`1 changes)
   at Microsoft.CodeAnalysis.CSharp.CSharpSyntaxTree.WithChanges(SourceText newText, IReadOnlyList`1 changes)
   at Microsoft.CodeAnalysis.CSharp.CSharpSyntaxTree.WithChangedText(SourceText newText)
   at Microsoft.CodeAnalysis.DocumentState.IncrementallyParse(TextAndVersion newTextAndVersion, TreeAndVersion oldTreeAndVersion, CancellationToken cancellationToken)
   at Microsoft.CodeAnalysis.DocumentState.<IncrementallyParseTreeAsync>d__15.MoveNext()
   at System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1.Start[TStateMachine](TStateMachine& stateMachine)
   at Microsoft.CodeAnalysis.DocumentState.IncrementallyParseTreeAsync(ValueSource`1 oldTreeSource, ValueSource`1 newTextSource, CancellationToken cancellationToken)
   at Microsoft.CodeAnalysis.DocumentState.<>c__DisplayClass14_0.<CreateLazyIncrementallyParsedTree>b__0(CancellationToken c)
   at Roslyn.Utilities.AsyncLazy`1.StartAsynchronousComputation(AsynchronousComputationToStart computationToStart, Request requestToCompleteSynchronously, CancellationToken callerCancellationToken)
   at Roslyn.Utilities.AsyncLazy`1.GetValueAsync(CancellationToken cancellationToken)
   at Microsoft.CodeAnalysis.DocumentState.<GetSyntaxTreeAsync>d__42.MoveNext()
   at System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1.Start[TStateMachine](TStateMachine& stateMachine)
   at System.Runtime.CompilerServices.AsyncValueTaskMethodBuilder`1.Start[TStateMachine](TStateMachine& stateMachine)
   at Microsoft.CodeAnalysis.DocumentState.GetSyntaxTreeAsync(CancellationToken cancellationToken)
   at Microsoft.CodeAnalysis.Document.GetSyntaxTreeAsync(CancellationToken cancellationToken)
   at Microsoft.CodeAnalysis.Host.BackgroundParser.<>c__DisplayClass20_0.<ParseDocumentAsync>b__0()
   at System.Threading.Tasks.Task`1.InnerInvoke()
   at System.Threading.Tasks.Task.Execute()
   at System.Threading.Tasks.Task.ExecutionContextCallback(Object obj)
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot)
   at System.Threading.Tasks.Task.ExecuteEntry(Boolean bPreventDoubleExecution)
   at System.Threading.Tasks.Task.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem()
   at System.Threading.ThreadPoolWorkQueue.Dispatch()

Metadata

Metadata

Assignees

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions