razor icon indicating copy to clipboard operation
razor copied to clipboard

[Cohost] Auto Insert tests for C# fail with the source generator turned on

Open davidwengier opened this issue 1 year ago • 2 comments

When the source generator is turned on the On Auto Insert tests in cohosting fail to deal with C# correctly. This doesn't seem to be a FUSE issue though, as existing LSP server tests for auto insert pass when forced to runtime code gen.

davidwengier avatar Sep 10 '24 02:09 davidwengier

Found an issue in RemoteDocumentSnapshot which caused some parts of formatting to run on an older SourceText because the project snapshot was old, which means the generator didn't re-run. Have pushed that fix to the branch, but now we hit this exception from the generator on that path:

System.ArgumentException: An element with the same key but a different value already exists. Key: 'File1.razor'
   at System.Collections.Immutable.ImmutableDictionary`2.HashBucket.Add(TKey key, TValue value, IEqualityComparer`1 keyOnlyComparer, IEqualityComparer`1 valueComparer, KeyCollisionBehavior behavior, OperationResult& result)
   at System.Collections.Immutable.ImmutableDictionary`2.Add(TKey key, TValue value, KeyCollisionBehavior behavior, MutationInput origin)
   at System.Collections.Immutable.ImmutableDictionary`2.Builder.Add(TKey key, TValue value)
   at Microsoft.CodeAnalysis.HostOutputNode`1.AppendOutputs(IncrementalExecutionContext context, CancellationToken cancellationToken) in D:\Code\roslyn\src\Compilers\Core\Portable\SourceGeneration\Nodes\HostOutputNode.cs:line 82
-----

Help me Obi Wan @chsienki you're my only hope. I don't know what i'm doing wrong :)

davidwengier avatar Sep 16 '24 01:09 davidwengier

@davidwengier Something very strange is going on deep in the generator driver code. It's actually very possibly a bug in the driver's host output logic. Will keep digging.

chsienki avatar Sep 18 '24 22:09 chsienki

This seems to be fixed now, all tests are passing. I think the simplified host outputs did it.

davidwengier avatar Mar 02 '25 21:03 davidwengier