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

Override completion broken for Razor documents with code behind #77976

Open
davidwengier opened this issue Apr 3, 2025 · 1 comment
Open
Assignees
Labels
Milestone

Comments

@davidwengier
Copy link
Member

Version Used: Version 17.14.0 Preview 2.0

Steps to Reproduce:

  1. Create a new Blazor Web App
  2. Open Counter.razor
  3. Navigate to the @code block and run Extract to code behind
  4. Go back to Counter.razor
  5. Add an empty @code { } block.
  6. Inside the block, type override so override completion comes up
  7. Observe yellow bar

Stack trace:

System.InvalidOperationException : Unexpected null - file AbstractMemberInsertingCompletionProvider.cs line 162
   at Microsoft.CodeAnalysis.Contract.Fail(String message,Int32 lineNumber,String filePath)
   at Microsoft.CodeAnalysis.Contract.ThrowIfNull[T](Nullable`1 value,Int32 lineNumber,String filePath)
   at Microsoft.CodeAnalysis.Completion.Providers.AbstractMemberInsertingCompletionProvider.ComputeDestinationSpan(SyntaxNode insertionRoot)
   at async Microsoft.CodeAnalysis.Completion.Providers.AbstractMemberInsertingCompletionProvider.RemoveDestinationNodeAsync(<Unknown Parameters>)
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at async Microsoft.CodeAnalysis.Completion.Providers.AbstractMemberInsertingCompletionProvider.DetermineNewDocumentAsync(<Unknown Parameters>)
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at async Microsoft.CodeAnalysis.Completion.Providers.AbstractMemberInsertingCompletionProvider.GetChangeAsync(<Unknown Parameters>)
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at async Microsoft.CodeAnalysis.Extensions.IExtensionManagerExtensions.PerformFunctionAsync[T](<Unknown Parameters>)

From a quick debug it seems like its trying to generated the override method into the code behind file. Perhaps fall out from #76821

/cc @CyrusNajmabadi @arunchndr @phil-allen-msft as this is probably 17.14 worthy

@dotnet-issue-labeler dotnet-issue-labeler bot added Area-IDE untriaged Issues and PRs which have not yet been triaged by a lead labels Apr 3, 2025
@davidwengier
Copy link
Member Author

Also seeing other weirdness with override completion in general. In a razor file with a lot of C# code in a @code block, I can bring up override completion at the top of the code block, and when accepting it, the implementation ends up 500 lines lower down in the file. Seems like maybe something has lost a "if completion then context position is really important" check.

@arunchndr arunchndr added this to the 17.14 P3 milestone Apr 3, 2025
@dotnet-policy-service dotnet-policy-service bot removed the untriaged Issues and PRs which have not yet been triaged by a lead label Apr 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants